Using zoomed preview images in iOS ScanTest

188 views
Skip to first unread message

shamy

unread,
Jun 15, 2012, 3:27:56 AM6/15/12
to zx...@googlegroups.com
Hi, 

In my project I need to scan very small datamatrix codes and in Android I could achieve it by using the setZoom() method to get 2x preview frames and decoding them. Now I am trying the same for the iOS version but I am not able to find any Camera APIs I can use to achieve this. I tried affine transform on the preview buffer and scaled it but the quality is not good. Can anyone please tell me of there is any camera API which I can use or what is the best way to scale the barcode preview frames in ScanTest?

Thanks,
Shamy 

Sean Owen

unread,
Jun 15, 2012, 5:01:24 AM6/15/12
to zx...@googlegroups.com
Zoom (digital) doesn't help in theory as you aren't gaining any information. It can distort the image instead.

shamy

unread,
Jun 15, 2012, 5:16:14 AM6/15/12
to zx...@googlegroups.com
Hi Sean, I understand that. But my testcases are really small and zooming really helped me make the decoding really faster in the Anroid case. I want to know if I can make a similar modification of the iOS app (ScanTest).

Sean Owen

unread,
Jun 15, 2012, 7:40:29 AM6/15/12
to zx...@googlegroups.com
Yes I've had mixed experience with it. Perfect digital zoom doesn't help or hurt. In practice it introduces some noise. Sometimes it hurts and sometimes paradoxically it introduces some smoothing that helps.
Optical zoom can definitely help.

(Sorry I don't know the iPhone API, Steven probably does)

Steven Parkes

unread,
Jun 15, 2012, 9:41:04 AM6/15/12
to shamy, zx...@googlegroups.com

On Jun 15, 2012, at 12:27 AM, shamy wrote:

> Hi,
>
> In my project I need to scan very small datamatrix codes and in Android I could achieve it by using the setZoom() method to get 2x preview frames and decoding them. Now I am trying the same for the iOS version but I am not able to find any Camera APIs I can use to achieve this. I tried affine transform on the preview buffer and scaled it but the quality is not good. Can anyone please tell me of there is any camera API which I can use or what is the best way to scale the barcode preview frames in ScanTest?

You probably want to increase the resolution of the capture.
Look for the line

self.captureSession.sessionPreset = preset;

in ZXingWidgetController.m (iphone) or ZXCapture.m (objc). It currently uses AVCaptureSessionPresetMedium on everything except the retina iPad. Medium is around 480x360 on an iPhone 4.

shamy

unread,
Jun 20, 2012, 12:44:38 AM6/20/12
to zx...@googlegroups.com, shamy
Thank you Steven. That is what I was exactly looking for.

 Isn't better to add supportsAVCaptureSessionPreset check for AVCaptureSessionPresetiFrame960x540 in all cases and switch to AVCaptureSessionPresetiFrame960x540 if it is supported by the device than doing it only for the retina iPad? I feel it will help in the case of iPhone 4S like it did in my case. Or do you see any side effects to that approach?

Thanks,
Shamy

Steven Parkes

unread,
Jun 20, 2012, 2:00:10 AM6/20/12
to shamy, zx...@googlegroups.com

On Jun 19, 2012, at 9:44 PM, shamy wrote:

> Isn't better to add supportsAVCaptureSessionPreset check for AVCaptureSessionPresetiFrame960x540 in all cases and switch to AVCaptureSessionPresetiFrame960x540 if it is supported by the device than doing it only for the retina iPad?

I didn't want to commit a change like that without testing, testing that I didn't have time to do.

There is a chance this would lower performance in some cases since a larger image requires more CPU to process.

There are also sometimes downsides to higher resolutions with zxing. For example, a full res image taken from an LCD will often not decode because at that resolution, the individual LCD pixels are resolvable and the zxing algorithms are not designed for that; a lower resolution gives you low pass filtering for free. The issue is less with lower res images but we haven't done much testing/experimenting.

So we can make the change, but it'd be best to see first if there are really are cases it helps and make sure it doesn't hurt others.

shamy

unread,
Jun 20, 2012, 4:18:19 AM6/20/12
to zx...@googlegroups.com, shamy
Thank you for the clarification. I will be testing the app with this modification on several types of barcodes and will update here if I see some issues with this approach.

Thanks,
Shamy

Reply all
Reply to author
Forward
0 new messages