Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChecksumException in zxing QRCodeReader when NOT reading a QR-code with an URL

The following code works perfectly and fast if I am scanning a QR code with an URL. However, if I am decoding a QR code with a simple string or number sequence (which is what I would like to do), it randomly works sometimes, but 99% of the time it keeps failing with a ChecksumException.

if (webcam.isOpen()) {

            if ((image = webcam.getImage()) == null) {
                continue;
            }

            LuminanceSource source = new BufferedImageLuminanceSource(image);
            BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

            try {
                result = new QRCodeReader().decode(bitmap);
            } catch (NotFoundException e) {
                 //exception handling omitted
            } catch (ChecksumException ex) {
                //exception handling omitted
            } catch (FormatException ex) {
               //exception handling omitted
            }
        }

Has anybody experienced this before? What could be the solution?

BTW I am generating the codes with http://goqr.me/

like image 637
Peter Avatar asked Dec 22 '13 17:12

Peter


2 Answers

This issue was actually a little misleading. The reason for simple qr codes with number sequences failing was that their patterns were bigger, as the code contained less information. URL QR codes had more information and thus a higher resolution and smaller "patterns". The source of the issue was that the webcam I was testing with was extremely sensitive to focus issues (or chromatical aberration, I do not know), so QR codes with low resolution had to be moved FURTHER away from the webcam in order to be read correctly, than URL QR codes... This issue was only this significant with my development PC's Asus webcam, all other webcams I tried basically worked with all my test QR codes.

like image 167
Peter Avatar answered Sep 30 '22 08:09

Peter


ChecksumException generally means it began to decode correctly, but the encoding of the QR code was invalid. It could indicate a problem with how the QR code was created, especially if it happens consistently.

However the QR codes you link to here looks OK, in that it decodes fine:

http://zxing.org/w/decode?u=http%3A%2F%2Fapi.qrserver.com%2Fv1%2Fcreate-qr-code%2F%3Fdata%3D12345%26size%3D250x250 http://zxing.org/w/decode?u=http%3A%2F%2Fgoqrme.remotefile.net%2Fimg%2Fact%2Fqrcode_generator%2Fqr_default.png

It also scans instantly with Barcode Scanner. Both are from zxing.

I wonder if you are flipping the image -- or, not un-flipping the flipped image that a webcam typically gives you.

like image 39
Sean Owen Avatar answered Sep 30 '22 07:09

Sean Owen