ArrayIndexOutOfBoundsException

92 views
Skip to first unread message

Alan

unread,
Oct 20, 2009, 12:57:30 PM10/20/09
to zxing
Sean,
Remember the images with a barcode and other stuff in them I
was trying to decode? I downloaded a new version of zxing, because
you thought a fix you did might help, but I still get an
ArrayIndexOutOfBoundsException, as follows:

--- Processing input file: C:\Users\thomasja\Documents\NetBeans
Projects\FilePdf\Test Files\\Pages from waddell3[1]-1.pdf
java.lang.ArrayIndexOutOfBoundsException: 3865883
at java.awt.image.BufferedImage.getRGB(BufferedImage.java:941)
at
com.google.zxing.client.j2se.BufferedImageLuminanceSource.getMatrix
(BufferedImageLuminanceSource.java:92)
at
com.google.zxing.common.GlobalHistogramBinarizer.getBlackMatrix
(GlobalHistogramBinarizer.java:104)
at com.google.zxing.BinaryBitmap.getBlackMatrix
(BinaryBitmap.java:84)
at com.google.zxing.qrcode.QRCodeReader.decode
(QRCodeReader.java:69)
at com.google.zxing.MultiFormatReader.decodeInternal
(MultiFormatReader.java:146)
at com.google.zxing.MultiFormatReader.decode
(MultiFormatReader.java:64)
at com.google.zxing.multi.ByQuadrantReader.decode
(ByQuadrantReader.java:56)
at filepdf.FilePdf.decode(FilePdf.java:448)
at filepdf.FilePdf.MovePdf(FilePdf.java:248)
at filepdf.FilePdf.main(FilePdf.java:58)
--- Processing input file: C:\Users\thomasja\Documents\NetBeans
Projects\FilePdf\Test Files\\Pages from waddell3[1]-2.pdf
java.lang.ArrayIndexOutOfBoundsException: 3865883
at java.awt.image.BufferedImage.getRGB(BufferedImage.java:941)
at
com.google.zxing.client.j2se.BufferedImageLuminanceSource.getMatrix
(BufferedImageLuminanceSource.java:92)
at
com.google.zxing.common.GlobalHistogramBinarizer.getBlackMatrix
(GlobalHistogramBinarizer.java:104)
at com.google.zxing.BinaryBitmap.getBlackMatrix
(BinaryBitmap.java:84)
at com.google.zxing.qrcode.QRCodeReader.decode
(QRCodeReader.java:69)
at com.google.zxing.MultiFormatReader.decodeInternal
(MultiFormatReader.java:146)
at com.google.zxing.MultiFormatReader.decode
(MultiFormatReader.java:64)
at com.google.zxing.multi.ByQuadrantReader.decode
(ByQuadrantReader.java:56)
at filepdf.FilePdf.decode(FilePdf.java:448)
at filepdf.FilePdf.MovePdf(FilePdf.java:248)
at filepdf.FilePdf.main(FilePdf.java:58)
--- Processing input file: C:\Users\thomasja\Documents\NetBeans
Projects\FilePdf\Test Files\\Pages from waddell3[1]-3.pdf
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at
com.google.zxing.client.j2se.BufferedImageLuminanceSource.getMatrix
(BufferedImageLuminanceSource.java:91)
at
com.google.zxing.common.GlobalHistogramBinarizer.getBlackMatrix
(GlobalHistogramBinarizer.java:104)
at com.google.zxing.BinaryBitmap.getBlackMatrix
(BinaryBitmap.java:84)
at com.google.zxing.qrcode.QRCodeReader.decode
(QRCodeReader.java:69)
at com.google.zxing.MultiFormatReader.decodeInternal
(MultiFormatReader.java:146)
at com.google.zxing.MultiFormatReader.decode
(MultiFormatReader.java:64)
at com.google.zxing.multi.ByQuadrantReader.decode
(ByQuadrantReader.java:56)
at filepdf.FilePdf.decode(FilePdf.java:448)
at filepdf.FilePdf.MovePdf(FilePdf.java:248)
at filepdf.FilePdf.main(FilePdf.java:58)




Sean Owen

unread,
Oct 20, 2009, 2:03:58 PM10/20/09
to zxing
I fixed the immediate issue though the image is still not quite
decoding. I believe it's that it is interpreting too much of the
lighter parts of the black bars as white noise here and there which
disrupts the decoding.

If you can raise the contrast on the scans, it will help. Or you can
tinker with the library itself.

Alan

unread,
Oct 20, 2009, 2:45:28 PM10/20/09
to zxing
The scans are archived data (a lot of it) that need to be processed.

Where would you suggest I start with tinkering with the library
itself?

If I used smoothing to fill in the lighter parts, perhaps that would
increase the contrast?

Also, is anyone aware of any packages that can decode barcodes from
cluttered images?

Thanks, Alan

Alan

unread,
Oct 20, 2009, 3:06:54 PM10/20/09
to zxing
Sean,
It seems like a more graceful result (or a more definitive
exception that could be caught) would be a good idea for zxing in this
case.

Alan



Sean Owen

unread,
Oct 20, 2009, 3:19:40 PM10/20/09
to zxing
I don't think the issue is clutter at all, just that these are sorta
low contrast images. The library has no problem with other junk in the
image, in general.

For example, I added the following quick hack and it made the image
decode, to the very end of GlobalHistogramBinarizer:

bestValley = (bestValley + secondPeak) / 2; // new line

return bestValley << LUMINANCE_SHIFT;

This just bumps the black point up a bit and this happens to work much
better on your image. This is the kind of tweak I mean -- this may
well do the trick for lots of your images. Try it. You don't need
ByQuadrantReader anymore.

Alan

unread,
Oct 20, 2009, 3:46:00 PM10/20/09
to zxing
Sean,
Thanks much. As usual, you were right on the money. One
odd thing is that it does not decode if I use ByQuadrantReader.

I think zxing is a great product.

Alan
Reply all
Reply to author
Forward
0 new messages