At last, removing SKIP_N_BARCODES and separating this logic out in a way that individ...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 3 Apr 2008 16:39:44 +0000 (16:39 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 3 Apr 2008 16:39:44 +0000 (16:39 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@340 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/DecodeHintType.java
core/src/com/google/zxing/oned/AbstractOneDReader.java

index 20c30c0..a8e1c83 100644 (file)
@@ -52,13 +52,6 @@ public final class DecodeHintType {
    */
   public static final DecodeHintType TRY_HARDER = new DecodeHintType();
 
-  /**
-   * Skip the first n barcodes found. Currently applies only to 1D formats. This
-   * enables a caller to repeatedly decode and find multiple barcodes. Maps
-   * to an {@link Integer}.
-   */
-  public static final DecodeHintType SKIP_N_BARCODES = new DecodeHintType();
-
   private DecodeHintType() {
   }
 
index a818cbb..1b858f6 100644 (file)
@@ -79,23 +79,12 @@ public abstract class AbstractOneDReader implements OneDReader {
     int middle = height >> 1;
     int rowStep = Math.max(1, height >> (tryHarder ? 7 : 4));
     int maxLines;
-    //if (tryHarder || barcodesToSkip > 0) {
     if (tryHarder) {
       maxLines = height; // Look at the whole image; looking for more than one barcode
     } else {
       maxLines = 7;
     }
 
-    // Remember last barcode to avoid thinking we've found a new barcode when
-    // we just rescanned the last one. Actually remember two, the last one
-    // found above and below.
-    String lastResultAboveText = null;
-    String lastResultBelowText = null;
-    boolean skippingSomeBarcodes =
-      hints != null &&
-      hints.containsKey(DecodeHintType.SKIP_N_BARCODES) &&
-      ((Integer) hints.get(DecodeHintType.SKIP_N_BARCODES)).intValue() > 0;
-
     for (int x = 0; x < maxLines; x++) {
 
       // Scanning from the middle out. Determine which row we're looking at next:
@@ -117,7 +106,6 @@ public abstract class AbstractOneDReader implements OneDReader {
 
       // We may try twice for each row, if "trying harder":
       for (int attempt = 0; attempt < 2; attempt++) {
-
         if (attempt == 1) { // trying again?
           if (tryHarder) { // only if "trying harder"
             row.reverse(); // reverse the row and continue
@@ -125,55 +113,18 @@ public abstract class AbstractOneDReader implements OneDReader {
             break;
           }
         }
-
         try {
-
           // Look for a barcode
           Result result = decodeRow(rowNumber, row, hints);
-          String resultText = result.getText();
-
-          // make sure we terminate inner loop after this because we found something
-          attempt = 1;
-          // See if we should skip and keep looking
-          if (( isAbove && resultText.equals(lastResultAboveText)) ||
-              (!isAbove && resultText.equals(lastResultBelowText))) {
-            // Just saw the last barcode again, proceed
-            continue;
-          }
-
-          if (skippingSomeBarcodes) {
-            int oldValue = ((Integer) hints.get(DecodeHintType.SKIP_N_BARCODES)).intValue();
-            if (oldValue > 1) {
-              hints.put(DecodeHintType.SKIP_N_BARCODES, new Integer(oldValue - 1));
-            } else {
-              hints.remove(DecodeHintType.SKIP_N_BARCODES);
-              skippingSomeBarcodes = false;
-            }
-            if (isAbove) {
-              lastResultAboveText = resultText;
-            } else {
-              lastResultBelowText = resultText;
-            }
-          } else {
-            // We found our barcode
-            if (attempt == 1) {
-              // But it was upside down, so note that
-              result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
-            }
-            return result;
+          // We found our barcode
+          if (attempt == 1) {
+            // But it was upside down, so note that
+            result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
           }
-
+          return result;
         } catch (ReaderException re) {
           // continue -- just couldn't decode this row
-          if (skippingSomeBarcodes) {
-            if (isAbove) {
-              lastResultAboveText = null;
-            } else {
-              lastResultBelowText = null;
-            }
-          }
         }
-
       }
     }