mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
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:
parent
e44cc99359
commit
ae379e56e9
|
@ -235,11 +235,11 @@ public final class Detector {
|
||||||
}
|
}
|
||||||
error += dy;
|
error += dy;
|
||||||
if (error > 0) {
|
if (error > 0) {
|
||||||
y += ystep;
|
|
||||||
error -= dx;
|
|
||||||
if (y == toY) {
|
if (y == toY) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
y += ystep;
|
||||||
|
error -= dx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResultPointsAndTransitions(from, to, transitions);
|
return new ResultPointsAndTransitions(from, to, transitions);
|
||||||
|
|
|
@ -260,17 +260,15 @@ public class Detector {
|
||||||
// Now count other way -- don't run off image though of course
|
// Now count other way -- don't run off image though of course
|
||||||
int otherToX = fromX - (toX - fromX);
|
int otherToX = fromX - (toX - fromX);
|
||||||
if (otherToX < 0) {
|
if (otherToX < 0) {
|
||||||
// "to" should the be the first value not included, so, the first value off
|
otherToX = 0;
|
||||||
// the edge is -1
|
} else if (otherToX >= image.getWidth()) {
|
||||||
otherToX = -1;
|
otherToX = image.getWidth() - 1;
|
||||||
} else if (otherToX > image.getWidth()) {
|
|
||||||
otherToX = image.getWidth();
|
|
||||||
}
|
}
|
||||||
int otherToY = fromY - (toY - fromY);
|
int otherToY = fromY - (toY - fromY);
|
||||||
if (otherToY < 0) {
|
if (otherToY < 0) {
|
||||||
otherToY = -1;
|
otherToY = 0;
|
||||||
} else if (otherToY > image.getHeight()) {
|
} else if (otherToY >= image.getHeight()) {
|
||||||
otherToY = image.getHeight();
|
otherToY = image.getHeight() - 1;
|
||||||
}
|
}
|
||||||
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
|
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
|
||||||
return result - 1.0f; // -1 because we counted the middle pixel twice
|
return result - 1.0f; // -1 because we counted the middle pixel twice
|
||||||
|
@ -324,11 +322,11 @@ public class Detector {
|
||||||
}
|
}
|
||||||
error += dy;
|
error += dy;
|
||||||
if (error > 0) {
|
if (error > 0) {
|
||||||
y += ystep;
|
|
||||||
error -= dx;
|
|
||||||
if (y == toY) {
|
if (y == toY) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
y += ystep;
|
||||||
|
error -= dx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int diffX = toX - fromX;
|
int diffX = toX - fromX;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
||||||
addTest(36, 36, 0.0f);
|
addTest(36, 36, 0.0f);
|
||||||
addTest(37, 37, 90.0f);
|
addTest(37, 37, 90.0f);
|
||||||
addTest(35, 35, 180.0f);
|
addTest(35, 35, 180.0f);
|
||||||
addTest(37, 37, 270.0f);
|
addTest(36, 36, 270.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue