mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 11:47:26 -08:00
Ignore additional PDF417 barcode rows
Some barcode generators (e.g. Okapi) seem to generate additional barcode rows at the end of the barcode, which can be decoded as valid barcode rows, but actually contain garbage. The barcode metadata states that these additional rows are not part of the barcode. So we ignore those addional rows when parsing the barcode. This could potentially also happen (though quite unlikely) if data after the barcode looks like a barcode row.
This commit is contained in:
parent
585667bc31
commit
825a31e4b5
|
@ -122,7 +122,8 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
|||
if (codeword != null) {
|
||||
int rowNumber = codeword.getRowNumber();
|
||||
if (rowNumber >= result.length) {
|
||||
throw FormatException.getFormatInstance();
|
||||
// We have more rows than the barcode metadata allows for, ignore them.
|
||||
continue;
|
||||
}
|
||||
result[rowNumber]++;
|
||||
} // else throw exception?
|
||||
|
|
|
@ -343,7 +343,8 @@ public final class PDF417ScanningDecoder {
|
|||
int rowNumber = codeword.getRowNumber();
|
||||
if (rowNumber >= 0) {
|
||||
if (rowNumber >= barcodeMatrix.length) {
|
||||
throw FormatException.getFormatInstance();
|
||||
// We have more rows than the barcode metadata allows for, ignore them.
|
||||
continue;
|
||||
}
|
||||
barcodeMatrix[rowNumber][column].setValue(codeword.getValue());
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ public final class PDF417BlackBox1TestCase extends AbstractBlackBoxTestCase {
|
|||
|
||||
public PDF417BlackBox1TestCase() {
|
||||
super("src/test/resources/blackbox/pdf417-1", new MultiFormatReader(), BarcodeFormat.PDF_417);
|
||||
addTest(9, 9, 0.0f);
|
||||
addTest(9, 9, 180.0f);
|
||||
addTest(10, 10, 0.0f);
|
||||
addTest(10, 10, 180.0f);
|
||||
}
|
||||
|
||||
}
|
BIN
core/src/test/resources/blackbox/pdf417-1/11.png
Normal file
BIN
core/src/test/resources/blackbox/pdf417-1/11.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
1
core/src/test/resources/blackbox/pdf417-1/11.txt
Normal file
1
core/src/test/resources/blackbox/pdf417-1/11.txt
Normal file
|
@ -0,0 +1 @@
|
|||
This is just a test.
|
Loading…
Reference in a new issue