Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Implemented coverage test for decode close #28

Merged
merged 2 commits into from Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,6 +20,8 @@
import com.google.zxing.ResultPoint;
import com.google.zxing.common.BitMatrix;

import com.google.zxing.CoverageTool2000;

/**
* <p>
* Detects a candidate barcode-like rectangular region within an image. It
Expand Down Expand Up @@ -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);

// .....
// . .
Expand All @@ -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);

// .....
// | .
Expand All @@ -147,42 +161,53 @@ 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);
// .___.
// . .
// .....
boolean topBorderNotWhite = true;
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;

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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();
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/test/java/com/google/zxing/TestSuite.java
Expand Up @@ -11,7 +11,7 @@
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({Code39ExtendedModeTestCase.class, Code39ExtendedBlackBox2TestCase.class})
@SuiteClasses({Code39ExtendedModeTestCase.class, Code39ExtendedBlackBox2TestCase.class, DetectorTest.class})
public class TestSuite extends TestCase {
/**
* One time setup before the tests are run.
Expand All @@ -20,6 +20,7 @@ public class TestSuite extends TestCase {
public static void setup() {
CoverageTool2000.initCoverageMatrix(0, 24);
CoverageTool2000.initCoverageMatrix(1, 18);
CoverageTool2000.initCoverageMatrix(6, 30);
}
/**
* One time teardown after all the tests are run.
Expand Down