mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Issue 511
git-svn-id: https://zxing.googlecode.com/svn/trunk@1522 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b7f70012ca
commit
6c9812e9bb
|
@ -266,9 +266,9 @@ public class Detector {
|
||||||
if (otherToX < 0) {
|
if (otherToX < 0) {
|
||||||
scale = (float) fromX / (float) (fromX - otherToX);
|
scale = (float) fromX / (float) (fromX - otherToX);
|
||||||
otherToX = 0;
|
otherToX = 0;
|
||||||
} else if (otherToX >= image.getWidth()) {
|
} else if (otherToX > image.getWidth()) {
|
||||||
scale = (float) (image.getWidth() - 1 - fromX) / (float) (otherToX - fromX);
|
scale = (float) (image.getWidth() - fromX) / (float) (otherToX - fromX);
|
||||||
otherToX = image.getWidth() - 1;
|
otherToX = image.getWidth();
|
||||||
}
|
}
|
||||||
int otherToY = (int) (fromY - (toY - fromY) * scale);
|
int otherToY = (int) (fromY - (toY - fromY) * scale);
|
||||||
|
|
||||||
|
@ -276,14 +276,14 @@ public class Detector {
|
||||||
if (otherToY < 0) {
|
if (otherToY < 0) {
|
||||||
scale = (float) fromY / (float) (fromY - otherToY);
|
scale = (float) fromY / (float) (fromY - otherToY);
|
||||||
otherToY = 0;
|
otherToY = 0;
|
||||||
} else if (otherToY >= image.getHeight()) {
|
} else if (otherToY > image.getHeight()) {
|
||||||
scale = (float) (image.getHeight() - 1 - fromY) / (float) (otherToY - fromY);
|
scale = (float) (image.getHeight() - fromY) / (float) (otherToY - fromY);
|
||||||
otherToY = image.getHeight() - 1;
|
otherToY = image.getHeight();
|
||||||
}
|
}
|
||||||
otherToX = (int) (fromX + (otherToX - fromX) * scale);
|
otherToX = (int) (fromX + (otherToX - fromX) * scale);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -330,6 +330,9 @@ public class Detector {
|
||||||
if (state == 3) { // Found black, white, black, and stumbled back onto white; done
|
if (state == 3) { // Found black, white, black, and stumbled back onto white; done
|
||||||
int diffX = x - fromX;
|
int diffX = x - fromX;
|
||||||
int diffY = y - fromY;
|
int diffY = y - fromY;
|
||||||
|
if (xstep < 0) {
|
||||||
|
diffX++;
|
||||||
|
}
|
||||||
return (float) Math.sqrt((double) (diffX * diffX + diffY * diffY));
|
return (float) Math.sqrt((double) (diffX * diffX + diffY * diffY));
|
||||||
}
|
}
|
||||||
error += dy;
|
error += dy;
|
||||||
|
|
BIN
core/test/data/blackbox/qrcode-2/32.gif
Normal file
BIN
core/test/data/blackbox/qrcode-2/32.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 708 B |
12
core/test/data/blackbox/qrcode-2/32.txt
Normal file
12
core/test/data/blackbox/qrcode-2/32.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
BEGIN:VCARD
|
||||||
|
N:Kennedy;Steve
|
||||||
|
TEL:+44 (0)7775 755503
|
||||||
|
ADR;HOME:;;Flat 2, 43 Howitt Road, Belsize Park;London;;NW34LU;UK
|
||||||
|
ORG:NetTek Ltd;
|
||||||
|
TITLE:Consultant
|
||||||
|
EMAIL:steve@nettek.co.uk
|
||||||
|
URL:www.nettek.co.uk
|
||||||
|
EMAIL;IM:MSN:steve@gbnet.net
|
||||||
|
NOTE:Testing 1 2 3
|
||||||
|
BDAY:19611105
|
||||||
|
END:VCARD
|
|
@ -27,10 +27,10 @@ public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public QRCodeBlackBox2TestCase() {
|
public QRCodeBlackBox2TestCase() {
|
||||||
super("test/data/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
super("test/data/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||||
addTest(23, 23, 0.0f);
|
addTest(26, 26, 0.0f);
|
||||||
addTest(21, 21, 90.0f);
|
addTest(24, 24, 90.0f);
|
||||||
addTest(23, 23, 180.0f);
|
addTest(24, 24, 180.0f);
|
||||||
addTest(20, 21, 270.0f);
|
addTest(22, 23, 270.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,9 +185,9 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX,
|
||||||
if (otherToX < 0) {
|
if (otherToX < 0) {
|
||||||
scale = (float) fromX / (float) (fromX - otherToX);
|
scale = (float) fromX / (float) (fromX - otherToX);
|
||||||
otherToX = 0;
|
otherToX = 0;
|
||||||
} else if (otherToX >= (int)image_->getWidth()) {
|
} else if (otherToX > (int)image_->getWidth()) {
|
||||||
scale = (float) (image_->getWidth() - 1 - fromX) / (float) (otherToX - fromX);
|
scale = (float) (image_->getWidth() - fromX) / (float) (otherToX - fromX);
|
||||||
otherToX = image_->getWidth() - 1;
|
otherToX = image_->getWidth();
|
||||||
}
|
}
|
||||||
int otherToY = (int) (fromY - (toY - fromY) * scale);
|
int otherToY = (int) (fromY - (toY - fromY) * scale);
|
||||||
|
|
||||||
|
@ -195,14 +195,14 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX,
|
||||||
if (otherToY < 0) {
|
if (otherToY < 0) {
|
||||||
scale = (float) fromY / (float) (fromY - otherToY);
|
scale = (float) fromY / (float) (fromY - otherToY);
|
||||||
otherToY = 0;
|
otherToY = 0;
|
||||||
} else if (otherToY >= (int)image_->getHeight()) {
|
} else if (otherToY > (int)image_->getHeight()) {
|
||||||
scale = (float) (image_->getHeight() - 1 - fromY) / (float) (otherToY - fromY);
|
scale = (float) (image_->getHeight() - fromY) / (float) (otherToY - fromY);
|
||||||
otherToY = image_->getHeight() - 1;
|
otherToY = image_->getHeight();
|
||||||
}
|
}
|
||||||
otherToX = (int) (fromX + (otherToX - fromX) * scale);
|
otherToX = (int) (fromX + (otherToX - fromX) * scale);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) {
|
float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) {
|
||||||
|
@ -241,6 +241,9 @@ float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY)
|
||||||
if (state == 3) { // Found black, white, black, and stumbled back onto white; done
|
if (state == 3) { // Found black, white, black, and stumbled back onto white; done
|
||||||
int diffX = x - fromX;
|
int diffX = x - fromX;
|
||||||
int diffY = y - fromY;
|
int diffY = y - fromY;
|
||||||
|
if (xstep < 0) {
|
||||||
|
diffX++;
|
||||||
|
}
|
||||||
return (float)sqrt((double)(diffX * diffX + diffY * diffY));
|
return (float)sqrt((double)(diffX * diffX + diffY * diffY));
|
||||||
}
|
}
|
||||||
error += dy;
|
error += dy;
|
||||||
|
|
Loading…
Reference in a new issue