diff --git a/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java b/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java index 8d77b0de56..1fad27b0ad 100644 --- a/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java +++ b/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java @@ -20,6 +20,8 @@ import com.google.zxing.ResultPoint; import com.google.zxing.common.BitMatrix; +import com.google.zxing.CoverageTool2000; + /** *

* Detects a candidate barcode-like rectangular region within an image. It @@ -107,18 +109,24 @@ public ResultPoint[] detect() throws NotFoundException { while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < width) { rightBorderNotWhite = containsBlackPoint(up, down, right, false); if (rightBorderNotWhite) { + ConverageTool2000.setCoverageMatrix(6, 0); right++; aBlackPointFoundOnBorder = true; atLeastOneBlackPointFoundOnRight = true; } else if (!atLeastOneBlackPointFoundOnRight) { + ConverageTool2000.setCoverageMatrix(6, 1); right++; + } else { + ConverageTool2000.setCoverageMatrix(6, 2); } } if (right >= width) { + ConverageTool2000.setCoverageMatrix(6, 3); sizeExceeded = true; break; } + ConverageTool2000.setCoverageMatrix(6, 4); // ..... // . . @@ -127,18 +135,24 @@ public ResultPoint[] detect() throws NotFoundException { while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < height) { bottomBorderNotWhite = containsBlackPoint(left, right, down, true); if (bottomBorderNotWhite) { + ConverageTool2000.setCoverageMatrix(6, 5); down++; aBlackPointFoundOnBorder = true; atLeastOneBlackPointFoundOnBottom = true; } else if (!atLeastOneBlackPointFoundOnBottom) { + ConverageTool2000.setCoverageMatrix(6, 6); down++; + } else { + ConverageTool2000.setCoverageMatrix(6, 7); } } if (down >= height) { + ConverageTool2000.setCoverageMatrix(6, 8); sizeExceeded = true; break; } + ConverageTool2000.setCoverageMatrix(6, 9); // ..... // | . @@ -147,19 +161,24 @@ public ResultPoint[] detect() throws NotFoundException { while ((leftBorderNotWhite || !atLeastOneBlackPointFoundOnLeft) && left >= 0) { leftBorderNotWhite = containsBlackPoint(up, down, left, false); if (leftBorderNotWhite) { + ConverageTool2000.setCoverageMatrix(6, 10); left--; aBlackPointFoundOnBorder = true; atLeastOneBlackPointFoundOnLeft = true; } else if (!atLeastOneBlackPointFoundOnLeft) { + ConverageTool2000.setCoverageMatrix(6, 11); left--; + } else { + ConverageTool2000.setCoverageMatrix(6, 12); } } if (left < 0) { + ConverageTool2000.setCoverageMatrix(6, 13); sizeExceeded = true; break; } - + ConverageTool2000.setCoverageMatrix(6, 14); // .___. // . . // ..... @@ -167,22 +186,28 @@ public ResultPoint[] detect() throws NotFoundException { while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) { topBorderNotWhite = containsBlackPoint(left, right, up, true); if (topBorderNotWhite) { + ConverageTool2000.setCoverageMatrix(6, 15); up--; aBlackPointFoundOnBorder = true; atLeastOneBlackPointFoundOnTop = true; } else if (!atLeastOneBlackPointFoundOnTop) { + ConverageTool2000.setCoverageMatrix(6, 16); up--; + } else { + ConverageTool2000.setCoverageMatrix(6, 17); } } if (up < 0) { + ConverageTool2000.setCoverageMatrix(6, 18); sizeExceeded = true; break; } - + ConverageTool2000.setCoverageMatrix(6, 19); } if (!sizeExceeded) { + ConverageTool2000.setCoverageMatrix(6, 20); int maxSize = right - left; @@ -192,8 +217,10 @@ public ResultPoint[] detect() throws NotFoundException { } if (z == null) { + ConverageTool2000.setCoverageMatrix(6, 21); throw NotFoundException.getNotFoundInstance(); } + ConverageTool2000.setCoverageMatrix(6, 22); ResultPoint t = null; //go down right @@ -202,8 +229,10 @@ public ResultPoint[] detect() throws NotFoundException { } if (t == null) { + ConverageTool2000.setCoverageMatrix(6, 23); throw NotFoundException.getNotFoundInstance(); } + ConverageTool2000.setCoverageMatrix(6, 24); ResultPoint x = null; //go down left @@ -212,8 +241,10 @@ public ResultPoint[] detect() throws NotFoundException { } if (x == null) { + ConverageTool2000.setCoverageMatrix(6, 25); throw NotFoundException.getNotFoundInstance(); } + ConverageTool2000.setCoverageMatrix(6, 26); ResultPoint y = null; //go up left @@ -222,12 +253,15 @@ public ResultPoint[] detect() throws NotFoundException { } if (y == null) { + ConverageTool2000.setCoverageMatrix(6, 27); throw NotFoundException.getNotFoundInstance(); } + ConverageTool2000.setCoverageMatrix(6, 28); return centerEdges(y, z, x, t); } else { + ConverageTool2000.setCoverageMatrix(6, 29); throw NotFoundException.getNotFoundInstance(); } } diff --git a/core/src/test/java/com/google/zxing/TestSuite.java b/core/src/test/java/com/google/zxing/TestSuite.java index f347ab183e..67462fd01c 100644 --- a/core/src/test/java/com/google/zxing/TestSuite.java +++ b/core/src/test/java/com/google/zxing/TestSuite.java @@ -12,7 +12,7 @@ @RunWith(Suite.class) -@SuiteClasses({Code39ExtendedModeTestCase.class, Code39ExtendedBlackBox2TestCase.class, StringUtilsTestCase.class, DecoderTest.class}) +@SuiteClasses({Code39ExtendedModeTestCase.class, Code39ExtendedBlackBox2TestCase.class, StringUtilsTestCase.class, DetectorTest.class}) public class TestSuite extends TestCase { /** @@ -24,6 +24,7 @@ public static void setup() { CoverageTool2000.initCoverageMatrix(1, 18); CoverageTool2000.initCoverageMatrix(2, 12); CoverageTool2000.initCoverageMatrix(5, 51); + CoverageTool2000.initCoverageMatrix(6, 30); } /** * One time teardown after all the tests are run.