Re: Cannot scan QR code

181 views
Skip to first unread message

Sean Owen

unread,
Jun 19, 2012, 4:33:51 AM6/19/12
to zx...@googlegroups.com
If you are scanning only for QR codes, use QRCodeReader. TRY_HARDER is good.

Not every image can decode. This image has some weird damage in the critical areas that encode version/format info. Can you avoid that noise in the QR code?
The QR code scans just fine.

Do you know the region of the image where to expect the code? then tell it to only scan that cropped region.

Strangely, introducing a light blur onto the image can make it decode sometimes.

On Tuesday, June 19, 2012 9:09:08 AM UTC+1, Mihael wrote:
Hi,

I have a form and am putting a QR code on it for later scanning. The file is written to disk as a JPEG image with the ImageIO java class.

  ImageIO.write(image, "jpg", myFile);

The encoded data is always 33 characters long. The size of the QR code is 300px.

In another process I read the images and out of 100 images around 3% cannot be read/decoded (sometimes more, sometimes less). The QR code itself seems ok. If I copy the QR code on another blank page it can be read and decoded.

        Map<DecodeHintType, Object> hints = new HashMap<DecodeHintType, Object>();
        hints.put(DecodeHintType.POSSIBLE_FORMATS, Arrays.asList(BarcodeFormat.QR_CODE));
        hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
        
        MultiFormatReader reader = new MultiFormatReader();
        reader.setHints(hints);
        Result decodeResult = null;
        
        try {
            decodeResult = reader.decode(image);
        }
        catch(NotFoundException nfe) {
            throw new ApplicationException(Type.noBarcodeFound);
        }

What can I do so that all QR codes can be read? Another size? Another place on the form/page?

Attached is a part of that form.

Thanx in advance

Mihael

Mihael

unread,
Jun 19, 2012, 4:54:19 AM6/19/12
to zx...@googlegroups.com
Am Dienstag, 19. Juni 2012 10:33:51 UTC+2 schrieb Sean Owen:
If you are scanning only for QR codes, use QRCodeReader. TRY_HARDER is good.
 
Not every image can decode. This image has some weird damage in the critical areas that encode version/format info.
Can you tell me what/where those critical areas are?
 
Can you avoid that noise in the QR code?
I think the noise comes from the JPEG compression. The original image doesn't have any noise.
 
The QR code scans just fine.

Do you know the region of the image where to expect the code? then tell it to only scan that cropped region.
The document will be generated by scanning it at a print/fax/copy/scan machine via a document feeder. So the QR code won't be exactly at the same place. But I'll give that a try. If that doesn't work I'll use the whole document.


Strangely, introducing a light blur onto the image can make it decode sometimes.

I'll give that also a try in a third pass if all other things doesn't work.

Thanx

Mihael 

Sean Owen

unread,
Jun 19, 2012, 6:29:23 AM6/19/12
to zx...@googlegroups.com
The area just around the finder pattern at the top-left and bottom-right has this info. It is not part of error correction and so is 'vulnerable'.
Is it really JPEG aliasing? that's pretty extreme. Try a bit less aggressive compression. 
Yes it's a good idea to try scanning the region you expect to have it in 90% of cases and fallback otherwise.

Mihael

unread,
Jun 19, 2012, 7:24:48 AM6/19/12
to zx...@googlegroups.com


Am Dienstag, 19. Juni 2012 12:29:23 UTC+2 schrieb Sean Owen:
The area just around the finder pattern at the top-left and bottom-right has this info. It is not part of error correction and so is 'vulnerable'.
Is it really JPEG aliasing? that's pretty extreme. Try a bit less aggressive compression. 
Ok. Thanx for the suggestion. I'll see if the configuration for the compression can be adjusted at the scanner (don't think so though). Would TIFF be a better more 
 
Yes it's a good idea to try scanning the region you expect to have it in 90% of cases and fallback otherwise.
Ok. Doing it already and will keep that.

I found that the different passes and the combination of cropping and blurring gave me a 100% success rate with my test codes. That should suffice (at least atm =).

I used the following for blurring (from http://www.jhlabs.com/ip/blurring.html ): 

    float[] matrix = {
        0.111f, 0.111f, 0.111f, 
        0.111f, 0.111f, 0.111f, 
        0.111f, 0.111f, 0.111f, 
    };

    BufferedImageOp op = new ConvolveOp( new Kernel(3, 3, matrix) );
	blurredImage = op.filter(sourceImage, destImage);


Thanx for the great and quick help.

Mihael

Sean Owen

unread,
Jun 19, 2012, 7:34:14 AM6/19/12
to zx...@googlegroups.com
Yes the original image is probably better to deal with, if possible. A TIFF would be a very high quality, but large, original. See if it's feasible; worth a try.
Thanks for the notes, and the code snippet. Yes that's a fine simple blur kernel.
Reply all
Reply to author
Forward
0 new messages