mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Improve correctness of black-run logic in case where patterns are very close to edge
git-svn-id: https://zxing.googlecode.com/svn/trunk@124 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
f7ef069a47
commit
6fed049a2c
|
@ -172,8 +172,23 @@ public final class Detector {
|
|||
* of another point (another finder pattern center), and in the opposite direction too.</p>
|
||||
*/
|
||||
private float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) {
|
||||
|
||||
float result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
|
||||
result += sizeOfBlackWhiteBlackRun(fromX, fromY, fromX - (toX - fromX), fromY - (toY - fromY));
|
||||
|
||||
// Now count other way -- don't run off image though of course
|
||||
int otherToX = fromX - (toX - fromX);
|
||||
if (otherToX < 0) {
|
||||
otherToX = 0;
|
||||
} else if (otherToX >= image.getWidth()) {
|
||||
otherToX = image.getWidth();
|
||||
}
|
||||
int otherToY = fromY - (toY - fromY);
|
||||
if (otherToY < 0) {
|
||||
otherToY = 0;
|
||||
} else if (otherToY >= image.getHeight()) {
|
||||
otherToY = image.getHeight();
|
||||
}
|
||||
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
|
||||
return result - 1.0f; // -1 because we counted the middle pixel twice
|
||||
}
|
||||
|
||||
|
@ -229,8 +244,9 @@ public final class Detector {
|
|||
error -= dx;
|
||||
}
|
||||
}
|
||||
// Hmm, couldn't find all of what we wanted -- don't know
|
||||
return Float.NaN;
|
||||
int diffX = toX - fromX;
|
||||
int diffY = toY - fromY;
|
||||
return (float) Math.sqrt((double) (diffX * diffX + diffY * diffY));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue