Finished work on the local binarizer and renamed it to HybridBinarizer. It uses the...
[zxing.git] / core / test / src / com / google / zxing / common / AbstractNegativeBlackBoxTestCase.java
index db55393..88f8249 100644 (file)
 
 package com.google.zxing.common;
 
-import com.google.zxing.MonochromeBitmapSource;
+import com.google.zxing.BinaryBitmap;
+import com.google.zxing.LuminanceSource;
 import com.google.zxing.MultiFormatReader;
 import com.google.zxing.ReaderException;
 import com.google.zxing.Result;
-import com.google.zxing.client.j2se.BufferedImageMonochromeBitmapSource;
+import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
 
-import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
 
 /**
  * This abstract class looks for negative results, i.e. it only allows a certain number of false
@@ -54,12 +57,12 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
     }
   }
 
-  private Vector<TestResult> testResults;
+  private final List<TestResult> testResults;
 
   // Use the multiformat reader to evaluate all decoders in the system.
-  protected AbstractNegativeBlackBoxTestCase(File testBase) {
-    super(testBase, new MultiFormatReader(), null);
-    testResults = new Vector<TestResult>();
+  protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
+    super(testBasePathSuffix, new MultiFormatReader(), null);
+    testResults = new ArrayList<TestResult>();
   }
 
   protected void addTest(int falsePositivesAllowed, float rotation) {
@@ -105,25 +108,27 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
    */
   private boolean checkForFalsePositives(BufferedImage image, float rotationInDegrees) {
     BufferedImage rotatedImage = rotateImage(image, rotationInDegrees);
-    MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(rotatedImage);
+    LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
+    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
     Result result;
     try {
-      result = getReader().decode(source);
+      result = getReader().decode(bitmap);
       System.out.println("Found false positive: '" + result.getText() + "' with format '" +
           result.getBarcodeFormat() + "' (rotation: " + rotationInDegrees + ')');
       return false;
     } catch (ReaderException re) {
     }
 
-    // Try "try harder" mode
+    // Try "try harder" getMode
     try {
-      result = getReader().decode(source, TRY_HARDER_HINT);
-      System.out.println("Try harder found false positive: '" + result.getText() + "' with format '" +
-          result.getBarcodeFormat() + "' (rotation: " + rotationInDegrees + ')');
+      result = getReader().decode(bitmap, TRY_HARDER_HINT);
+      System.out.println("Try harder found false positive: '" + result.getText() +
+          "' with format '" + result.getBarcodeFormat() + "' (rotation: " +
+          rotationInDegrees + ')');
       return false;
     } catch (ReaderException re) {
     }
     return true;
   }
 
-}
\ No newline at end of file
+}