decoderResult = decoder.decode(bits);
points = NO_POINTS;
} else {
- DetectorResult result = new Detector(image).detect();
+ DetectorResult result = new Detector(image).detect(hints);
decoderResult = decoder.decode(result.getBits());
points = result.getPoints();
}
import com.google.zxing.common.GridSampler;
import com.google.zxing.qrcode.decoder.Version;
+import java.util.Hashtable;
+
/**
* <p>Encapsulates logic that can detect a QR Code in an image, even if the QR Code
* is rotated or skewed, or partially obscured.</p>
* @throws ReaderException if no QR Code can be found
*/
public DetectorResult detect() throws ReaderException {
+ return detect(null);
+ }
+
+ /**
+ * <p>Detects a QR Code in an image, simply.</p>
+ *
+ * @param hints optional hints to detector
+ * @return {@link DetectorResult} encapsulating results of detecting a QR Code
+ * @throws ReaderException if no QR Code can be found
+ */
+ public DetectorResult detect(Hashtable hints) throws ReaderException {
MonochromeBitmapSource image = this.image;
if (!BlackPointEstimationMethod.TWO_D_SAMPLING.equals(image.getLastEstimationMethod())) {
}
FinderPatternFinder finder = new FinderPatternFinder(image);
- FinderPatternInfo info = finder.find();
+ FinderPatternInfo info = finder.find(hints);
FinderPattern topLeft = info.getTopLeft();
FinderPattern topRight = info.getTopRight();
\r
package com.google.zxing.qrcode.detector;\r
\r
+import com.google.zxing.DecodeHintType;\r
import com.google.zxing.MonochromeBitmapSource;\r
import com.google.zxing.ReaderException;\r
import com.google.zxing.ResultPoint;\r
import com.google.zxing.common.Collections;\r
import com.google.zxing.common.Comparator;\r
\r
+import java.util.Hashtable;\r
import java.util.Vector;\r
\r
/**\r
this.possibleCenters = new Vector();\r
}\r
\r
- FinderPatternInfo find() throws ReaderException {\r
+ FinderPatternInfo find(Hashtable hints) throws ReaderException {\r
+ boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);\r
int maxI = image.getHeight();\r
int maxJ = image.getWidth();\r
// We are looking for black/white/black/white/black modules in\r
boolean done = false;\r
// We can afford to examine every few lines until we've started finding\r
// the patterns\r
- int iSkip = BIG_SKIP;\r
+ int iSkip = tryHarder ? 1 : BIG_SKIP;\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