Better version of revision 1166 and 1165 -- corrects behavior, by changing code such that points are always within image. Happens to make one test image fail at one rotation, but think that was a 'false gain' so accepted that tiny step backwards.

git-svn-id: https://zxing.googlecode.com/svn/trunk@1178 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-01-06 14:02:16 +00:00
parent e44cc99359
commit ae379e56e9
3 changed files with 11 additions and 13 deletions

View file

@ -235,11 +235,11 @@ public final class Detector {
}
error += dy;
if (error > 0) {
y += ystep;
error -= dx;
if (y == toY) {
break;
}
y += ystep;
error -= dx;
}
}
return new ResultPointsAndTransitions(from, to, transitions);

View file

@ -260,17 +260,15 @@ public class Detector {
// Now count other way -- don't run off image though of course
int otherToX = fromX - (toX - fromX);
if (otherToX < 0) {
// "to" should the be the first value not included, so, the first value off
// the edge is -1
otherToX = -1;
} else if (otherToX > image.getWidth()) {
otherToX = image.getWidth();
otherToX = 0;
} else if (otherToX >= image.getWidth()) {
otherToX = image.getWidth() - 1;
}
int otherToY = fromY - (toY - fromY);
if (otherToY < 0) {
otherToY = -1;
} else if (otherToY > image.getHeight()) {
otherToY = image.getHeight();
otherToY = 0;
} else if (otherToY >= image.getHeight()) {
otherToY = image.getHeight() - 1;
}
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
return result - 1.0f; // -1 because we counted the middle pixel twice
@ -324,11 +322,11 @@ public class Detector {
}
error += dy;
if (error > 0) {
y += ystep;
error -= dx;
if (y == toY) {
break;
}
y += ystep;
error -= dx;
}
}
int diffX = toX - fromX;

View file

@ -30,7 +30,7 @@ public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase {
addTest(36, 36, 0.0f);
addTest(37, 37, 90.0f);
addTest(35, 35, 180.0f);
addTest(37, 37, 270.0f);
addTest(36, 36, 270.0f);
}
}