Re: QRcode decoding from an image not working

Skip to first unread message

Sean Owen

Sep 17, 2012, 8:18:19 AM9/17/12
The message from the online decoder tells you the issue -- it's too large. To prevent DoS attacks and such the upload size is limited. The QR code itself is readable. This particular image of the QR code may or may not be; your code looks OK. Try a different binarizer or TRY_HARDER mode hint.

Lachezar Dobrev

Sep 17, 2012, 8:44:28 AM9/17/12
to mabicha,
Having the image with this big a resolution is not good.
Resizing the image down to one quarter (0.5 x 0.5) makes it readable.
Large images commonly fail to decode.
You should take that into consideration when building your application.

2012/9/17 mabicha <>:
> Hi,
> I am trying to write a java application where if the user provides me with
> an image containing a QRcode then the application detects and decodes the
> QRcode in the image and outputs the decoded text.
> So I wrote a java class similar to
> RGBLuminance(zxing-2.0/androidtest/src/com/google/zxing/client/androidtest/
> which extends LuminanceSource. Then I use following code to decode the
> QRcode in the image:-
> ----------------------
> RGBLuminance rgb = new RGBLuminance(pngReader);
> HybridBinarizer rgbHB = new HybridBinarizer(rgb);
> BinaryBitmap bitmap = new BinaryBitmap(rgbHB);
> QRCodeReader reader = new QRCodeReader();
> Result result = reader.decode(bitmap);
> String contents = result.getText();
> ----------------------
> Now my application works fine on QRcode images I download from the internet.
> But if I take a picture of the same image from my camera and try to decode
> it using my application I get error: ""
> I found the same behavior when I use zxing online decoder:
> . When I use this online decoder to decode a
> QRcode in a photo taken from my camera I get error saying: "Bad Image. The
> image you uploaded could not be decoded, or was too large. Go "Back" in your
> browser and try another image."
> Also, I am able to decode all these QRcodes using Zxing's Barcode scanner
> app on my Nexus S, including the ones on the photo I took from my camera.
> I am attaching some sample QRcode images which I can't decode using my java
> application or zxing online decoder, but can decode it using Zxing's Barcode
> scanner app.
> Can somebody please tell me what I might be doing wrong here and how can I
> make this work ?
> Thanks!!
> Manas
> --


Sep 24, 2012, 3:15:55 AM9/24/12
to, mabicha
Thanks guys for your help! Resizing the image to lower resolution did the trick... But I am also using TRY_HARDER just to increase the reliability of the app.
Also, I saw that online decoder: , was able to detect if the image had any QRCode or not by throwing a different error if the image does not contain any QRcode: "No barcode was found in this image. Either it did not contain a barcode, or did not contain one in a supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image."

But in my app I am only getting "NotFoundException" in both the cases:
1) QRcode was present but was unreadable
2) QRcode was not even present.

How can I differentiate between the above 2 cases in my app ?

Sean Owen

Sep 24, 2012, 3:47:53 AM9/24/12
to, mabicha
This is the same situation -- NotFoundException. Read the list of things this generic message applies to.

What is the difference between 1 and 2, to a program? Maybe it found some region that looked like a barcode but didn't decode. Is it a barcode or not? It's not distinguishable.
It will throw ChecksumException or FormatException if the barcode appears to have been found, but the contents aren't valid. This can still really mean that something that wasn't a barcode looked like a barcode.
Reply all
Reply to author
0 new messages