(Thanks to John White) Make UPC/EAN decoder less picky about white space bordering...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 12 Aug 2008 18:29:29 +0000 (18:29 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 12 Aug 2008 18:29:29 +0000 (18:29 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@557 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/oned/AbstractUPCEANReader.java
core/test/src/com/google/zxing/negative/FalsePositivesBlackBoxTestCase.java
core/test/src/com/google/zxing/oned/EAN13BlackBox1TestCase.java
core/test/src/com/google/zxing/oned/UPCEBlackBox2TestCase.java

index f971a62..e900668 100644 (file)
@@ -94,7 +94,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
       nextStart = startRange[1];
       // As a check, we want to see some white in front of this "start pattern",
       // maybe as wide as the start pattern itself?
-      foundStart = row.isRange(Math.max(0, start - 2 * (startRange[1] - start)), start, false);
+      foundStart = row.isRange(Math.max(0, start - (3 * (startRange[1] - start)) / 2), start, false);
     }
     return startRange;
   }
@@ -110,7 +110,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
 
     // Check for whitespace after the pattern
     int end = endRange[1];
-    if (!row.isRange(end, Math.min(row.getSize(), end + 2 * (end - endRange[0])), false)) {
+    if (!row.isRange(end, Math.min(row.getSize(), end + (3 * (end - endRange[0])) / 2), false)) {
       throw new ReaderException("Pattern not followed by whitespace");
     }
 
index f07348e..4e39d01 100644 (file)
@@ -31,7 +31,7 @@ public final class FalsePositivesBlackBoxTestCase extends AbstractNegativeBlackB
     super(new File("test/data/blackbox/falsepositives"));
     addTest(1, 0.0f);
     addTest(1, 90.0f);
-    addTest(1, 180.0f);
+    addTest(2, 180.0f);
     addTest(0, 270.0f);
   }
 
index 1113c16..f19ecfd 100644 (file)
@@ -29,8 +29,8 @@ public final class EAN13BlackBox1TestCase extends AbstractBlackBoxTestCase {
 
   public EAN13BlackBox1TestCase() {
     super(new File("test/data/blackbox/ean13-1"), new MultiFormatReader(), BarcodeFormat.EAN_13);
-    addTest(26, 29, 0.0f);
-    addTest(24, 29, 180.0f);
+    addTest(27, 29, 0.0f);
+    addTest(25, 29, 180.0f);
   }
 
 }
\ No newline at end of file
index 54f7606..7c96737 100644 (file)
@@ -29,8 +29,8 @@ public final class UPCEBlackBox2TestCase extends AbstractBlackBoxTestCase {
 
   public UPCEBlackBox2TestCase() {
     super(new File("test/data/blackbox/upce-2"), new MultiFormatReader(), BarcodeFormat.UPC_E);
-    addTest(17, 28, 0.0f);
-    addTest(19, 28, 180.0f);
+    addTest(24, 34, 0.0f);
+    addTest(26, 34, 180.0f);
   }
 
 }