Re: ZXing for iOS: Can't recognize QR code on some photos.

294 views
Skip to first unread message

Pavel Sergeyev

unread,
Mar 27, 2013, 1:46:07 AM3/27/13
to zx...@googlegroups.com
Hi All.

Just one more update.

I've tried to recognize image taken from the iPhone (just slightly compressed) using following link:
http://zxing.org/w/decode.jspx
You can find my test image by following link : https://www.dropbox.com/s/7nhafdquderwkxi/IMG_0448_Pack.jpg

But it says "The image you uploaded could not be decoded, or was too large."
The same image is not recognizable in my iOS app too. (As you can see in post above.)

Size of the image is 587K so it should be ok.(link says that allowed size is <2MB).

Please let me know if I'm doing something wrong.

Thanks.


On Monday, March 25, 2013 12:18:01 PM UTC+3, Pavel Sergeyev wrote:
I can't recognize QR code on some photos taken from standart iPhone Camera.

Steps I did:

1) I Made a photo with standart iPhone Camera application and saved it to standart photo gallery. ( IPhone 4s. Resolution of the photo is 3264 : 2448. QR code is taking 70% of the photo.)

2) I took this photo into my variable photoImage of type UIImage* in my application. I used this UIImgePickerControllerDelegate method:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
   
    self.photoImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    [self dismissViewControllerAnimated:YES completion:nil];
}
3) Then I tried to decode this UIImage using zXing decoder. I used this part of my code:
Decoder *decoder = [Decoder new];
NSMutableSet *readers = [NSMutableSet set];
QRCodeReader* qrcodeReader = [QRCodeReader new];
[readers addObject:qrcodeReader];
[qrcodeReader release];
       
decoder.readers = readers;
decoder.delegate = self;
       
[decoder decodeImage:photoImage];
           
[decoder release];

Then DecoderDelegate method was called:
- (void)decoder:(Decoder *)decoder failedToDecodeImage:(UIImage *)image usingSubset:(UIImage *)subset reason:(NSString *)reason

But I am sure my photo has high quality and QR code. So, the question is: why didn't zXing decoder recognize my photoImage?
Is there any way to improve my code for avoiding this?

Thanks in advance.

Sean Owen

unread,
Mar 27, 2013, 5:52:03 AM3/27/13
to zx...@googlegroups.com
The image is too large in pixel dimension; I think the limit is about 2MP. If you resize it to 25% of the original dimensions for example, it's fine: QM:40,40,0 UID:12345678

I can update the text on the page to more accurately reflect that. I don't mind raising the limit a little too.

Sean

Steven Parkes

unread,
Mar 27, 2013, 11:21:20 AM3/27/13
to Pavel Sergeyev, zx...@googlegroups.com
Some of the heuristics in zxing fail on high resolution photos. The primary zxing use case is a relatively low res preview from a camera phone. The heuristics will sometimes misinterpret various kinds of noise in higher res images. The solution is to low-pass filter the images. Naive downsampling will usually do well enough.

See also: https://groups.google.com/d/msg/zxing/0G76LDWn3cA/OhVIU5pWZAIJ

On Mar 25, 2013, at 2:18 AM, Pavel Sergeyev <xblxt...@gmail.com> wrote:

> I can't recognize QR code on some photos taken from standart iPhone Camera.
>
> Steps I did:
>
> 1) I Made a photo with standart iPhone Camera application and saved it to standart photo gallery. ( IPhone 4s. Resolution of the photo is 3264 : 2448. QR code is taking 70% of the photo.)
>
> 2) I took this photo into my variable photoImage of type UIImage* in my application. I used this UIImgePickerControllerDelegate method:
> - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
>
> self.photoImage = [info objectForKey:UIImagePickerControllerOriginalImage];
> [self dismissViewControllerAnimated:YES completion:nil];
> }
> 3) Then I tried to decode this UIImage using zXing decoder. I used this part of my code:
> Decoder *decoder = [Decoder new];
> NSMutableSet *readers = [NSMutableSet set];
> QRCodeReader* qrcodeReader = [QRCodeReader new];
> [readers addObject:qrcodeReader];
> [qrcodeReader release];
>
> decoder.readers = readers;
> decoder.delegate = self;
>
> [decoder decodeImage:photoImage];
>
> [decoder release];
>
> Then DecoderDelegate method was called:
> - (void)decoder:(Decoder *)decoder failedToDecodeImage:(UIImage *)image usingSubset:(UIImage *)subset reason:(NSString *)reason
>
> But I am sure my photo has high quality and QR code. So, the question is: why didn't zXing decoder recognize my photoImage?
> Is there any way to improve my code for avoiding this?
>
> Thanks in advance.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages