mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Another user-suggested fix - misdetecting rectangular matrices in corner cases
git-svn-id: https://zxing.googlecode.com/svn/trunk@1761 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b02b2b55b7
commit
e1fda03246
|
@ -142,7 +142,6 @@ public final class Detector {
|
||||||
// adjacent to the white module at the top right. Tracing to that corner from either the top left
|
// adjacent to the white module at the top right. Tracing to that corner from either the top left
|
||||||
// or bottom right should work here.
|
// or bottom right should work here.
|
||||||
|
|
||||||
|
|
||||||
int dimensionTop = transitionsBetween(topLeft, topRight).getTransitions();
|
int dimensionTop = transitionsBetween(topLeft, topRight).getTransitions();
|
||||||
int dimensionRight = transitionsBetween(bottomRight, topRight).getTransitions();
|
int dimensionRight = transitionsBetween(bottomRight, topRight).getTransitions();
|
||||||
|
|
||||||
|
@ -161,7 +160,10 @@ public final class Detector {
|
||||||
BitMatrix bits;
|
BitMatrix bits;
|
||||||
ResultPoint correctedTopRight;
|
ResultPoint correctedTopRight;
|
||||||
|
|
||||||
if (dimensionTop >= dimensionRight * 2 || dimensionRight >= dimensionTop * 2){
|
// Rectanguar symbols are 6x16, 6x28, 10x24, 10x32, 14x32, or 14x44. If one dimension is more
|
||||||
|
// than twice the other, it's certainly rectangular, but to cut a bit more slack we accept it as
|
||||||
|
// rectangular if the bigger side is at least 7/4 times the other:
|
||||||
|
if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) {
|
||||||
// The matrix is rectangular
|
// The matrix is rectangular
|
||||||
|
|
||||||
correctedTopRight =
|
correctedTopRight =
|
||||||
|
@ -195,7 +197,7 @@ public final class Detector {
|
||||||
correctedTopRight = topRight;
|
correctedTopRight = topRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//We redetermine the dimension using the corrected top right point
|
// Redetermine the dimension using the corrected top right point
|
||||||
int dimensionCorrected = Math.max(transitionsBetween(topLeft, correctedTopRight).getTransitions(),
|
int dimensionCorrected = Math.max(transitionsBetween(topLeft, correctedTopRight).getTransitions(),
|
||||||
transitionsBetween(bottomRight, correctedTopRight).getTransitions());
|
transitionsBetween(bottomRight, correctedTopRight).getTransitions());
|
||||||
dimensionCorrected++;
|
dimensionCorrected++;
|
||||||
|
@ -212,7 +214,6 @@ public final class Detector {
|
||||||
dimensionCorrected);
|
dimensionCorrected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new DetectorResult(bits, new ResultPoint[]{topLeft, bottomLeft, bottomRight, correctedTopRight});
|
return new DetectorResult(bits, new ResultPoint[]{topLeft, bottomLeft, bottomRight, correctedTopRight});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
core/test/data/blackbox/datamatrix-1/GUID.jpg
Normal file
BIN
core/test/data/blackbox/datamatrix-1/GUID.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
1
core/test/data/blackbox/datamatrix-1/GUID.txt
Normal file
1
core/test/data/blackbox/datamatrix-1/GUID.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
10f27ce-acb7-4e4e-a7ae-a0b98da6ed4a
|
|
@ -27,10 +27,10 @@ public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase
|
||||||
|
|
||||||
public DataMatrixBlackBox1TestCase() {
|
public DataMatrixBlackBox1TestCase() {
|
||||||
super("test/data/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
super("test/data/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
||||||
addTest(17, 17, 0.0f);
|
addTest(18, 18, 0.0f);
|
||||||
addTest(17, 17, 90.0f);
|
addTest(18, 18, 90.0f);
|
||||||
addTest(17, 17, 180.0f);
|
addTest(18, 18, 180.0f);
|
||||||
addTest(17, 17, 270.0f);
|
addTest(18, 18, 270.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue