mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix/improvement from Jiayong
git-svn-id: https://zxing.googlecode.com/svn/trunk@1184 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
30c41e5182
commit
c2a6255e19
|
@ -255,24 +255,33 @@ public class Detector {
|
|||
*/
|
||||
private float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) {
|
||||
|
||||
float result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
|
||||
float result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
|
||||
|
||||
// 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() - 1;
|
||||
}
|
||||
int otherToY = fromY - (toY - fromY);
|
||||
if (otherToY < 0) {
|
||||
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
|
||||
}
|
||||
// Now count other way -- don't run off image though of course
|
||||
float scale = 1.0f;
|
||||
int otherToX = fromX - (toX - fromX);
|
||||
if (otherToX < 0) {
|
||||
scale = (float) fromX / (float) (fromX - otherToX);
|
||||
otherToX = 0;
|
||||
} else if (otherToX >= image.getWidth()) {
|
||||
scale = (float) (image.getWidth() - 1 - fromX) / (float) (otherToX - fromX);
|
||||
otherToX = image.getWidth() - 1;
|
||||
}
|
||||
int otherToY = (int) (fromY - (toY - fromY) * scale);
|
||||
|
||||
scale = 1.0f;
|
||||
if (otherToY < 0) {
|
||||
scale = (float) fromY / (float) (fromY - otherToY);
|
||||
otherToY = 0;
|
||||
} else if (otherToY >= image.getHeight()) {
|
||||
scale = (float) (image.getHeight() - 1 - fromY) / (float) (otherToY - fromY);
|
||||
otherToY = image.getHeight() - 1;
|
||||
}
|
||||
otherToX = (int) (fromX + (otherToX - fromX) * scale);
|
||||
|
||||
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
|
||||
return result - 1.0f; // -1 because we counted the middle pixel twice
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>This method traces a line from a point in the image, in the direction towards another point.
|
||||
|
|
|
@ -28,9 +28,9 @@ public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
|||
public QRCodeBlackBox3TestCase() {
|
||||
super("test/data/blackbox/qrcode-3", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||
addTest(36, 36, 0.0f);
|
||||
addTest(37, 37, 90.0f);
|
||||
addTest(35, 35, 180.0f);
|
||||
addTest(36, 36, 270.0f);
|
||||
addTest(38, 38, 90.0f);
|
||||
addTest(36, 36, 180.0f);
|
||||
addTest(37, 37, 270.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue