<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
<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>
<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>
public final class WhiteRectangleDetector {
private static final int INIT_SIZE = 40;
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;
private final BitMatrix image;
private final int height;
*/
public ResultPoint[] detect() throws NotFoundException {
*/
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;
boolean sizeExceeded = false;
boolean aBlackPointFoundOnBorder = true;
boolean atLeastOneBlackPointFoundOnBorder = false;
if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
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;
z = getBlackPointOnSegment(left, down - i, left + i, down);
if (z != null) {
break;
throw NotFoundException.getNotFoundInstance();
}
throw NotFoundException.getNotFoundInstance();
}
- 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;
t = getBlackPointOnSegment(left, up + i, left + i, up);
if (t != null) {
break;
throw NotFoundException.getNotFoundInstance();
}
throw NotFoundException.getNotFoundInstance();
}
- 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;
x = getBlackPointOnSegment(right, up + i, right - i, up);
if (x != null) {
break;
throw NotFoundException.getNotFoundInstance();
}
throw NotFoundException.getNotFoundInstance();
}
- 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;
y = getBlackPointOnSegment(right, down - i, right - i, down);
if (y != null) {
break;
float ti = t.getX();
float tj = t.getY();
float ti = t.getX();
float tj = t.getY();
if (yi < width / 2) {
return new ResultPoint[]{
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[]{
} 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)};