mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Another fix to ensure that 2 barcodes with the same info are counted separately.
git-svn-id: https://zxing.googlecode.com/svn/trunk@338 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
01075819c5
commit
0e7872020c
|
@ -86,7 +86,11 @@ public abstract class AbstractOneDReader implements OneDReader {
|
||||||
maxLines = 7;
|
maxLines = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable lastResults = null;
|
// 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 =
|
boolean skippingSomeBarcodes =
|
||||||
hints != null &&
|
hints != null &&
|
||||||
hints.containsKey(DecodeHintType.SKIP_N_BARCODES) &&
|
hints.containsKey(DecodeHintType.SKIP_N_BARCODES) &&
|
||||||
|
@ -126,13 +130,18 @@ public abstract class AbstractOneDReader implements OneDReader {
|
||||||
|
|
||||||
// Look for a barcode
|
// Look for a barcode
|
||||||
Result result = decodeRow(rowNumber, row, hints);
|
Result result = decodeRow(rowNumber, row, hints);
|
||||||
|
String resultText = result.getText();
|
||||||
|
|
||||||
if (lastResults != null && lastResults.containsKey(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
|
// Just saw the last barcode again, proceed
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skippingSomeBarcodes) { // See if we should skip and keep looking
|
if (skippingSomeBarcodes) {
|
||||||
int oldValue = ((Integer) hints.get(DecodeHintType.SKIP_N_BARCODES)).intValue();
|
int oldValue = ((Integer) hints.get(DecodeHintType.SKIP_N_BARCODES)).intValue();
|
||||||
if (oldValue > 1) {
|
if (oldValue > 1) {
|
||||||
hints.put(DecodeHintType.SKIP_N_BARCODES, new Integer(oldValue - 1));
|
hints.put(DecodeHintType.SKIP_N_BARCODES, new Integer(oldValue - 1));
|
||||||
|
@ -140,10 +149,11 @@ public abstract class AbstractOneDReader implements OneDReader {
|
||||||
hints.remove(DecodeHintType.SKIP_N_BARCODES);
|
hints.remove(DecodeHintType.SKIP_N_BARCODES);
|
||||||
skippingSomeBarcodes = false;
|
skippingSomeBarcodes = false;
|
||||||
}
|
}
|
||||||
if (lastResults == null) {
|
if (isAbove) {
|
||||||
lastResults = new Hashtable(3);
|
lastResultAboveText = resultText;
|
||||||
|
} else {
|
||||||
|
lastResultBelowText = resultText;
|
||||||
}
|
}
|
||||||
lastResults.put(result.getText(), Boolean.TRUE); // Remember what we just saw
|
|
||||||
} else {
|
} else {
|
||||||
// We found our barcode
|
// We found our barcode
|
||||||
if (attempt == 1) {
|
if (attempt == 1) {
|
||||||
|
@ -155,6 +165,13 @@ public abstract class AbstractOneDReader implements OneDReader {
|
||||||
|
|
||||||
} catch (ReaderException re) {
|
} catch (ReaderException re) {
|
||||||
// continue -- just couldn't decode this row
|
// continue -- just couldn't decode this row
|
||||||
|
if (skippingSomeBarcodes) {
|
||||||
|
if (isAbove) {
|
||||||
|
lastResultAboveText = null;
|
||||||
|
} else {
|
||||||
|
lastResultBelowText = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue