Detect/decoding PDF417 barcode images

246 views
Skip to first unread message

krome

unread,
Sep 11, 2010, 12:25:52 AM9/11/10
to zxing
Hi,
I am working on the PDF417 error correction code .
Many of the core/test/data/blackbox/pdf417-2 png images cannot be
decoded (also not by the Online Decoder)
ie. 16.png ... 22.png

but when I generate barcodes with the same content, the images can be
decoded.

It seems that there is an issue with detecting the barcode, maybe the
image is too dark or not clear?

Any suggestions as to where to apply code changes that could improve
the image recognition?
Thanks,
Dave

Sean Owen

unread,
Sep 11, 2010, 7:02:06 AM9/11/10
to zxing
I can suggest you look at using the "WhiteRectangleDetector" that
David Olivier added, which does well for detecting Data Matrix. That
could improve detection -- if that's the issue.

krome

unread,
Sep 11, 2010, 1:27:20 PM9/11/10
to zxing
The images are detected ie. the guard patterns (START_PATTERN and
STOP_PATTERN) are found,
but there is a Format Exception.
BitMatrixParser.readCodewords() finds too many low level symbol
decoding errors
(ie. the low level symbols are not found in the SYMBOL_TABLE[])

Sean Owen

unread,
Sep 11, 2010, 1:46:31 PM9/11/10
to zxing
I think this is because PDF417 error correction is not implemented.
This would almost surely fix that.

krome

unread,
Sep 11, 2010, 2:33:40 PM9/11/10
to zxing
In one example there are 156 erasures, and the numECCodewords is 32
therefore the following throws an exception before
rsDecoder.correctErrors() is reached

if ((erasures != null && erasures.length > numECCodewords / 2 +
MAX_ERRORS) ||
(numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS)) {
// Too many errors or EC Codewords is corrupted
throw FormatException.getFormatInstance();
}
// Try to correct the errors
// TODO enable error correction
int result = rsDecoder.correctErrors(codewords, erasures,
numECCodewords);

krome

unread,
Sep 14, 2010, 1:26:39 AM9/14/10
to zxing
It seems that for some images the low level symbols are not read
correctly.
The scanned barcode image is not as 'clean' as the generated barcode
image.
Both images have the same content.
Is it possible to tweak the HybridBinarizer thresholding algorithm (or
another routine) to minimize the decoding errors?

This is the partial symbol output from a scan that was not decoded
successfully (too many errors):
11110101001111000 cw=4 ColumnNumber=0i=0
10100001000010000 cw=109 ColumnNumber=1i=17
11000001000100110 cw=861 ColumnNumber=2i=34
10000010011000110 cw=841 ColumnNumber=3i=51
11010011101110000 cw=-1 ColumnNumber=4i=68
11000011101100001 cw=-1 ColumnNumber=5i=85
11100010100111001 cw=-1 ColumnNumber=6i=102
11010011001111000 cw=-1 ColumnNumber=7i=119
10000010001000100 cw=864 ColumnNumber=8i=136
10001110111001000 cw=865 ColumnNumber=9i=153
11010100001100000 cw=8 ColumnNumber=10i=170
11111000100011000 cw=-1 ColumnNumber=0i=0
11110010101000000 cw=210 ColumnNumber=1i=17
10110001001111110 cw=396 ColumnNumber=2i=34
10011110101111000 cw=853 ColumnNumber=3i=51
11000001011100000 cw=-1 ColumnNumber=4i=68
11111001001011101 cw=-1 ColumnNumber=5i=85
10110001111001001 cw=-1 ColumnNumber=6i=102
11100001000100010 cw=-1 ColumnNumber=7i=119
...

Compare with a partial symbol output from a successfully decoded
generated barcode:
11111010100111110 cw=5 ColumnNumber=0i=0
11010000100000110 cw=112 ColumnNumber=1i=17
11000001000100110 cw=861 ColumnNumber=2i=34
10000010011000110 cw=841 ColumnNumber=3i=51
11010011101111000 cw=61 ColumnNumber=4i=68
11100011010110000 cw=617 ColumnNumber=5i=85
11110011010011100 cw=390 ColumnNumber=6i=102
11101001100111100 cw=54 ColumnNumber=7i=119
10000010001000100 cw=864 ColumnNumber=8i=136
10001110111001000 cw=865 ColumnNumber=9i=153
11010100001100000 cw=8 ColumnNumber=10i=170
11110101000000100 cw=12 ColumnNumber=0i=0
11110010101000000 cw=210 ColumnNumber=1i=17
10110001001111110 cw=396 ColumnNumber=2i=34
10011110101111000 cw=853 ColumnNumber=3i=51
...

The code that manipulates the image:
private static String getDecodeText(File file) {
BufferedImage image;
try {
image = ImageIO.read(file);
} catch (IOException ioe) {
return ioe.toString();
}
if (image == null) {
return "Could not decode image";
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new
HybridBinarizer(source));
Result result;
try {
result = new MultiFormatReader().decode(bitmap);
} catch (ReaderException re) {
return re.toString();
}
return result.getText();

Sean Owen

unread,
Sep 14, 2010, 3:44:05 AM9/14/10
to zxing
These are probably mis-decodes -- the barcode was not found correctly
so the result is garbage.

For those with a few errors, it's likely that error correction would
make them work.
Reply all
Reply to author
Forward
0 new messages