mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Guard against exception case discovered in new DM code, clean up its formatting a bit
git-svn-id: https://zxing.googlecode.com/svn/trunk@1620 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
2cb813b088
commit
345a55c6c7
|
@ -46,6 +46,9 @@ public final class DefaultGridSampler extends GridSampler {
|
||||||
int dimensionX,
|
int dimensionX,
|
||||||
int dimensionY,
|
int dimensionY,
|
||||||
PerspectiveTransform transform) throws NotFoundException {
|
PerspectiveTransform transform) throws NotFoundException {
|
||||||
|
if (dimensionX <= 0 || dimensionY <= 0) {
|
||||||
|
throw NotFoundException.getNotFoundInstance();
|
||||||
|
}
|
||||||
BitMatrix bits = new BitMatrix(dimensionX, dimensionY);
|
BitMatrix bits = new BitMatrix(dimensionX, dimensionY);
|
||||||
float[] points = new float[dimensionX << 1];
|
float[] points = new float[dimensionX << 1];
|
||||||
for (int y = 0; y < dimensionY; y++) {
|
for (int y = 0; y < dimensionY; y++) {
|
||||||
|
|
|
@ -158,13 +158,14 @@ public final class Detector {
|
||||||
}
|
}
|
||||||
dimensionRight += 2;
|
dimensionRight += 2;
|
||||||
|
|
||||||
BitMatrix bits = null;
|
BitMatrix bits;
|
||||||
ResultPoint correctedTopRight = null;
|
ResultPoint correctedTopRight;
|
||||||
|
|
||||||
if (dimensionTop >= dimensionRight * 2 || dimensionRight >= dimensionTop * 2){
|
if (dimensionTop >= dimensionRight * 2 || dimensionRight >= dimensionTop * 2){
|
||||||
//The matrix is rectangular
|
//The matrix is rectangular
|
||||||
|
|
||||||
correctedTopRight = correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight);
|
correctedTopRight =
|
||||||
|
correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight);
|
||||||
if (correctedTopRight == null){
|
if (correctedTopRight == null){
|
||||||
correctedTopRight = topRight;
|
correctedTopRight = topRight;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +203,13 @@ public final class Detector {
|
||||||
dimensionCorrected++;
|
dimensionCorrected++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bits = sampleGrid(image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionCorrected, dimensionCorrected);
|
bits = sampleGrid(image,
|
||||||
|
topLeft,
|
||||||
|
bottomLeft,
|
||||||
|
bottomRight,
|
||||||
|
correctedTopRight,
|
||||||
|
dimensionCorrected,
|
||||||
|
dimensionCorrected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,7 +217,8 @@ public final class Detector {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the position of the white top right module using the output of the rectangle detector for a rectangular matrix
|
* Calculates the position of the white top right module using the output of the rectangle detector
|
||||||
|
* for a rectangular matrix
|
||||||
*/
|
*/
|
||||||
private ResultPoint correctTopRightRectangular(ResultPoint bottomLeft,
|
private ResultPoint correctTopRightRectangular(ResultPoint bottomLeft,
|
||||||
ResultPoint bottomRight, ResultPoint topLeft, ResultPoint topRight,
|
ResultPoint bottomRight, ResultPoint topLeft, ResultPoint topRight,
|
||||||
|
@ -252,7 +260,8 @@ public final class Detector {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the position of the white top right module using the output of the rectangle detector for a square matrix
|
* Calculates the position of the white top right module using the output of the rectangle detector
|
||||||
|
* for a square matrix
|
||||||
*/
|
*/
|
||||||
private ResultPoint correctTopRight(ResultPoint bottomLeft,
|
private ResultPoint correctTopRight(ResultPoint bottomLeft,
|
||||||
ResultPoint bottomRight,
|
ResultPoint bottomRight,
|
||||||
|
|
Loading…
Reference in a new issue