ISSUE: http://code.google.com/p/zxing/issues/detail?id=110
authorkev.sully <kev.sully@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 21 Nov 2008 16:40:40 +0000 (16:40 +0000)
committerkev.sully <kev.sully@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 21 Nov 2008 16:40:40 +0000 (16:40 +0000)
Changes to fix high nbr of false positives.
- Removed requirement that the barcode fills the viewfinder
- Extended the check on the lenght of decoded barcode - now only 6, 10 and 14 digit barcodes are supported.

git-svn-id: http://zxing.googlecode.com/svn/trunk@756 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/oned/ITFReader.java

index 1dddbab..cdc1d2c 100644 (file)
@@ -30,9 +30,8 @@ import java.util.Hashtable;
  * Implements decoding of the ITF format.\r
  * </p>\r
  *<p>\r
- * "ITF" stands for Interleaved Two of Five. This Reader will scan an arbritary\r
- * ITF length barcode. The checksum is optional and is not applied by this\r
- * Reader. The user of the decoded value will have to apply a checksum if\r
+ * "ITF" stands for Interleaved Two of Five. This Reader will scan ITF barcode with 6, 10 or 14 digits. \r
+ * The checksum is optional and is not applied by this Reader. The consumer of the decoded value will have to apply a checksum if\r
  * required.\r
  * </p>\r
  * \r
@@ -43,7 +42,7 @@ import java.util.Hashtable;
  * information.\r
  * </p>\r
  * \r
- * @author kevin.osullivan@sita.aero\r
+ * @author kevin.osullivan@sita.aero, SITA Lab.\r
  */\r
 public class ITFReader extends AbstractOneDReader {\r
 \r
@@ -94,10 +93,11 @@ public class ITFReader extends AbstractOneDReader {
 \r
                String resultString = result.toString();\r
                /**\r
-                * To avoid false positives with 2D barcodes, make\r
-                * an assumption that the decoded string must be at least 6 digits.\r
+                * To avoid false positives with 2D barcodes (and other patterns), make\r
+                * an assumption that the decoded string must be 6, 10 or 14 digits.\r
                 */\r
-               if (resultString.length() < 6 || resultString.length() % 2 == 1)\r
+               if ((resultString.length() != 6 && resultString.length() != 10 && resultString.length() != 14) || \r
+                    resultString.length() % 2 == 1)\r
                        throw ReaderException.getInstance();\r
 \r
                return new Result(resultString,\r
@@ -173,10 +173,6 @@ public class ITFReader extends AbstractOneDReader {
                return startPattern;\r
        }\r
 \r
-       /**\r
-        * \r
-        * \r
-        */\r
        /**\r
         * \r
         *      The start & end patterns must be pre/post fixed by a quiet zone. This\r
@@ -209,15 +205,6 @@ public class ITFReader extends AbstractOneDReader {
                        // Unable to find the necessary number of quiet zone pixels.\r
                        throw ReaderException.getInstance();\r
                }\r
-               \r
-               if (i>this.narrowLineWidth*20)\r
-               {\r
-                       // The distance from the image edge to the start of the quiet zone \r
-                       // is twice the size of the quiet zone. \r
-                       // This is unrealistic as the barcode should mostly fill the camera viewfinder.\r
-                       // This implies that this is a false positive.\r
-                       throw ReaderException.getInstance();\r
-               }\r
        }\r
 \r
        /**\r