Changed how many rows we scan while detecting QR finder patterns. The mobile case...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 10 Apr 2008 20:26:42 +0000 (20:26 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 10 Apr 2008 20:26:42 +0000 (20:26 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@354 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java

index 4bc33d4..029be72 100755 (executable)
@@ -38,7 +38,8 @@ import java.util.Vector;
 final class FinderPatternFinder {\r
 \r
   private static final int CENTER_QUORUM = 2;\r
-  private static final int BIG_SKIP = 3;\r
+  private static final int MIN_SKIP = 3; // 1 pixel/module times 3 modules/center\r
+  private static final int MAX_MODULES = 57; // support up to version 10 for mobile clients\r
 \r
   private final MonochromeBitmapSource image;\r
   private final Vector possibleCenters;\r
@@ -62,9 +63,16 @@ final class FinderPatternFinder {
     // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far\r
     int[] stateCount = new int[5];\r
     boolean done = false;\r
-    // We can afford to examine every few lines until we've started finding\r
-    // the patterns\r
-    int iSkip = tryHarder ? 1 : BIG_SKIP;\r
+\r
+    // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the\r
+    // image, and then account for the center being 3 modules in size. This gives the smallest\r
+    // number of pixels the center could be, so skip this often. When trying harder, look for all\r
+    // QR versions regardless of how dense they are.\r
+    int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3);\r
+    if (iSkip < MIN_SKIP || tryHarder) {\r
+      iSkip = MIN_SKIP;\r
+    }\r
+\r
     for (int i = iSkip - 1; i < maxI && !done; i += iSkip) {\r
       // Get a row of black/white values\r
       BitArray blackRow = image.getBlackRow(i, null, 0, maxJ);\r