Another minor change to WhiteRectangleDetector and update "about" screen in Android to mention Data Matrix

git-svn-id: https://zxing.googlecode.com/svn/trunk@1586 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-09-13 09:12:02 +00:00
parent 05582c4975
commit fd3c38bf70
2 changed files with 25 additions and 22 deletions

View file

@ -4,8 +4,9 @@
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
<p><b>Barcode Scanner</b> also understands how to read two dimensional barcodes, called <em>QR
Codes</em>. For example, the QR Code below contains a hyperlink to the ZXing Project home page:</p>
<p><b>Barcode Scanner</b> also understands how to read two dimensional barcodes, like <em>QR
Codes</em> and <em>Data Matrix codes</em>.
For example, the QR Code below contains a hyperlink to the ZXing Project home page:</p>
<p style="text-align:center"><img src="../images/big-qr.png" alt="QR code"></p>
<p>You can also represent contact information in a QR Code, and put it on a business card or web
site. When you scan it, the results screen provides a choice of actions:</p>

View file

@ -33,6 +33,7 @@ import com.google.zxing.common.BitMatrix;
public final class WhiteRectangleDetector {
private static final int INIT_SIZE = 40;
private static final int CORR = 1;
private final BitMatrix image;
private final int height;
@ -60,10 +61,10 @@ public final class WhiteRectangleDetector {
*/
public ResultPoint[] detect() throws NotFoundException {
int left = (width - INIT_SIZE) / 2;
int right = (width + INIT_SIZE) / 2;
int up = (height - INIT_SIZE) / 2;
int down = (height + INIT_SIZE) / 2;
int left = (width - INIT_SIZE) >> 1;
int right = (width + INIT_SIZE) >> 1;
int up = (height - INIT_SIZE) >> 1;
int down = (height + INIT_SIZE) >> 1;
boolean sizeExceeded = false;
boolean aBlackPointFoundOnBorder = true;
boolean atLeastOneBlackPointFoundOnBorder = false;
@ -148,11 +149,10 @@ public final class WhiteRectangleDetector {
if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
ResultPoint x = null, y = null, z = null, t = null;
int maxSize = right - left;
final int max_size = right - left;
for (int i = 1; i < max_size; i++) {
ResultPoint z = null;
for (int i = 1; i < maxSize; i++) {
z = getBlackPointOnSegment(left, down - i, left + i, down);
if (z != null) {
break;
@ -163,8 +163,9 @@ public final class WhiteRectangleDetector {
throw NotFoundException.getNotFoundInstance();
}
ResultPoint t = null;
//go down right
for (int i = 1; i < max_size; i++) {
for (int i = 1; i < maxSize; i++) {
t = getBlackPointOnSegment(left, up + i, left + i, up);
if (t != null) {
break;
@ -175,8 +176,9 @@ public final class WhiteRectangleDetector {
throw NotFoundException.getNotFoundInstance();
}
ResultPoint x = null;
//go down left
for (int i = 1; i < max_size; i++) {
for (int i = 1; i < maxSize; i++) {
x = getBlackPointOnSegment(right, up + i, right - i, up);
if (x != null) {
break;
@ -187,8 +189,9 @@ public final class WhiteRectangleDetector {
throw NotFoundException.getNotFoundInstance();
}
ResultPoint y = null;
//go up left
for (int i = 1; i < max_size; i++) {
for (int i = 1; i < maxSize; i++) {
y = getBlackPointOnSegment(right, down - i, right - i, down);
if (y != null) {
break;
@ -267,19 +270,18 @@ public final class WhiteRectangleDetector {
float ti = t.getX();
float tj = t.getY();
final int corr = 1;
if (yi < width / 2) {
return new ResultPoint[]{
new ResultPoint(ti - corr, tj + corr),
new ResultPoint(zi + corr, zj + corr),
new ResultPoint(xi - corr, xj - corr),
new ResultPoint(yi + corr, yj - corr)};
new ResultPoint(ti - CORR, tj + CORR),
new ResultPoint(zi + CORR, zj + CORR),
new ResultPoint(xi - CORR, xj - CORR),
new ResultPoint(yi + CORR, yj - CORR)};
} else {
return new ResultPoint[]{
new ResultPoint(ti + corr, tj + corr),
new ResultPoint(zi + corr, zj - corr),
new ResultPoint(xi - corr, xj + corr),
new ResultPoint(yi - corr, yj - corr)};
new ResultPoint(ti + CORR, tj + CORR),
new ResultPoint(zi + CORR, zj - CORR),
new ResultPoint(xi - CORR, xj + CORR),
new ResultPoint(yi - CORR, yj - CORR)};
}
}