* @author dswitkin@google.com (Daniel Switkin)
*/
final class DecodeThread extends Thread {
+
public static final String BARCODE_BITMAP = "barcode_bitmap";
private static final String TAG = "DecodeThread";
doSetDecodeMode(BarcodeFormat.UPC_A,
BarcodeFormat.UPC_E,
BarcodeFormat.EAN_13,
- BarcodeFormat.EAN_8);
+ BarcodeFormat.EAN_8,
+ BarcodeFormat.RSS14);
}
/**
BarcodeFormat.EAN_8,
BarcodeFormat.CODE_39,
BarcodeFormat.CODE_128,
- BarcodeFormat.ITF);
+ BarcodeFormat.ITF,
+ BarcodeFormat.RSS14);
}
private void setDecodeQRMode() {
BarcodeFormat.CODE_39,
BarcodeFormat.CODE_128,
BarcodeFormat.ITF,
+ BarcodeFormat.RSS14,
BarcodeFormat.QR_CODE);
}
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
+ } finally {
+ multiFormatReader.reset();
}
if (rawResult != null) {
/** ITF (Interleaved Two of Five) 1D format. */
public static final BarcodeFormat ITF = new BarcodeFormat("ITF");
+ /** RSS 14 */
+ public static final BarcodeFormat RSS14 = new BarcodeFormat("RSS14");
+
/** PDF417 format. */
public static final BarcodeFormat PDF417 = new BarcodeFormat("PDF417");
formats.contains(BarcodeFormat.EAN_8) ||
formats.contains(BarcodeFormat.CODE_39) ||
formats.contains(BarcodeFormat.CODE_128) ||
- formats.contains(BarcodeFormat.ITF);
+ formats.contains(BarcodeFormat.ITF) ||
+ formats.contains(BarcodeFormat.RSS14);
// Put 1D readers upfront in "normal" mode
if (addOneDReader && !tryHarder) {
readers.addElement(new MultiFormatOneDReader(hints));
}
}
+ public void reset() {
+ int size = readers.size();
+ for (int i = 0; i < size; i++) {
+ Reader reader = (Reader) readers.elementAt(i);
+ reader.reset();
+ }
+ }
+
private Result decodeInternal(BinaryBitmap image) throws ReaderException {
int size = readers.size();
for (int i = 0; i < size; i++) {
*/
Result decode(BinaryBitmap image, Hashtable hints) throws ReaderException;
+ /**
+ * Resets any internal state the implementation has after a decode, to prepare it
+ * for reuse.
+ */
+ void reset();
+
}
\ No newline at end of file
return result;
}
+ public void reset() {
+ // do nothing
+ }
+
/**
* This method detects a Data Matrix code in a "pure" image -- that is, pure monochrome image
* which contains only an unrotated, unskewed, image of a Data Matrix code, with some white border
return delegate.decode(center, hints);
}
+ public void reset() {
+ delegate.reset();
+ }
+
}
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
+import com.google.zxing.Reader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.common.BitArray;
+import com.google.zxing.oned.rss.RSS14Reader;
import java.util.Hashtable;
import java.util.Vector;
if (possibleFormats.contains(BarcodeFormat.ITF)) {
readers.addElement(new ITFReader());
}
+ if (possibleFormats.contains(BarcodeFormat.RSS14)) {
+ // TODO enable later readers.addElement(new RSS14Reader());
+ }
}
if (readers.isEmpty()) {
readers.addElement(new MultiFormatUPCEANReader(hints));
readers.addElement(new Code39Reader());
readers.addElement(new Code128Reader());
readers.addElement(new ITFReader());
+ // TODO enable later readers.addElement(new RSS14Reader());
}
}
throw ReaderException.getInstance();
}
+ public void reset() {
+ int size = readers.size();
+ for (int i = 0; i < size; i++) {
+ Reader reader = (Reader) readers.elementAt(i);
+ reader.reset();
+ }
+ }
+
}
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
+import com.google.zxing.Reader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.common.BitArray;
throw ReaderException.getInstance();
}
+ public void reset() {
+ int size = readers.size();
+ for (int i = 0; i < size; i++) {
+ Reader reader = (Reader) readers.elementAt(i);
+ reader.reset();
+ }
+ }
+
}
public abstract class OneDReader implements Reader {
private static final int INTEGER_MATH_SHIFT = 8;
- static final int PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT;
+ protected static final int PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT;
public Result decode(BinaryBitmap image) throws ReaderException {
return decode(image, null);
}
}
+ public void reset() {
+ // do nothing
+ }
+
/**
* We're going to examine rows from the middle outward, searching alternately above and below the
* middle, and farther out each time. rowStep is the number of rows between each successive
* @throws ReaderException if counters cannot be filled entirely from row before running out
* of pixels
*/
- static void recordPattern(BitArray row, int start, int[] counters) throws ReaderException {
+ protected static void recordPattern(BitArray row, int start, int[] counters) throws ReaderException {
int numCounters = counters.length;
for (int i = 0; i < numCounters; i++) {
counters[i] = 0;
break;
} else {
counters[counterPosition] = 1;
- isWhite ^= true; // isWhite = !isWhite;
+ isWhite = !isWhite;
}
}
i++;
}
}
+ protected static void recordPatternInReverse(BitArray row, int start, int[] counters)
+ throws ReaderException {
+ // This could be more efficient I guess
+ int numTransitionsLeft = counters.length;
+ boolean last = row.get(start);
+ while (start > 0 && numTransitionsLeft >= 0) {
+ if (row.get(--start) != last) {
+ numTransitionsLeft--;
+ last = !last;
+ }
+ }
+ if (numTransitionsLeft >= 0) {
+ throw ReaderException.getInstance();
+ }
+ recordPattern(row, start + 1, counters);
+ }
+
/**
* Determines how closely a set of observed counts of runs of black/white values matches a given
* target pattern. This is reported as the ratio of the total variance from the expected pattern
* the total variance between counters and patterns equals the pattern length, higher values mean
* even more variance
*/
- static int patternMatchVariance(int[] counters, int[] pattern, int maxIndividualVariance) {
+ protected static int patternMatchVariance(int[] counters, int[] pattern, int maxIndividualVariance) {
int numCounters = counters.length;
int total = 0;
int patternLength = 0;
BarcodeFormat.PDF417);\r
}\r
\r
+ public void reset() {\r
+ // do nothing\r
+ }\r
+\r
/**\r
* This method detects a barcode in a "pure" image -- that is, pure monochrome image\r
* which contains only an unrotated, unskewed, image of a barcode, with some white border\r
possibleFormats.add(BarcodeFormat.CODE_39);
possibleFormats.add(BarcodeFormat.CODE_128);
possibleFormats.add(BarcodeFormat.ITF);
+ possibleFormats.add(BarcodeFormat.RSS14);
possibleFormats.add(BarcodeFormat.QR_CODE);
possibleFormats.add(BarcodeFormat.DATAMATRIX);
possibleFormats.add(BarcodeFormat.PDF417);