Re: Optimal Imager type/resolution for best berformance?

971 views
Skip to first unread message

Sean Owen

unread,
Mar 15, 2013, 11:53:57 AM3/15/13
to zx...@googlegroups.com
The camera's picture resolution (the "5MP") doesn't matter, since it will use the preview resolution. This is usually the screen resolution. That's plenty, and processing has more than kept pace with additional pixels, so resolution is not an issue.

Auto focus helps. More specifically, a small minimum focal distance helps since it often needs to focus at close range. Just make sure it can focus at 3" ideally.
Devices that support a few optional features will perform better, though I don't have a list of which ones support these:
  • barcode scene mode
  • exposure control
  • metering control
The Nexus phones are likely to have the most complete support for things like this.

Blur and lighting don't sound like any issue in your setup.

The next-biggest obstacle is camera driver bugs. I would again recommend Nexus phones as they have the highest chance of having no bugs. HTC and Samsung are OK; I'd avoid any off brands, and Huawei in particular.

There's not a lot of point in skipping a frame because you think it's not in focus. By the time you decide whether it's in focus you could have processed a lot of it. If you discard it, you might just be idling while you could have tried the frame anyway.

You are right than only luminance matters. The difference between a good and great CCD is probably not meaningful here. Color information is discarded anyway.




On Friday, March 15, 2013 3:21:49 PM UTC, frantz robinson wrote:
Greetings!

I am designing an embedded android device (medical logistics)  - and have been recently asked to incorporate a barcode scanner; 
Rather than buy an expensive, fully-integrated barcode scan engine, with a proprietary API, as we might normally be expected to do,
It seems like it would be feasible & advantageous to do this using  zxing on our host processor (running Android 4.2 now) and an inexpensive cellphone type camera module,
especially since the processor hardware and current OS port fully support that already.
reliability is a prime concern; since the camera is there only for this function, i would choose the most suitable one for best performance in this task.
If a standard "out of the box" cellphone camera module still leaves a lot to be desired, we might develop our own with better optics and lighting.

From what i have read here, there seems to be an optimum compromise to be found to balance camera resolution and processing power;
there also seems to be a preference for rapidly scanning through many medium-low resolution images vs slower in-depth analysis of a higher-resolution one.

I have also read that some are very successfull with VGA resolution imagery, but most cannot use the VGA front camera, in a typical android device, and the higher resolution ones  (1.3-5Mpixels) work much better in practice.
Thus i have a few related questions:
Using a typical single-core A8 processor @ 1GHz
Given the most challenging bar-code format (say PDF417, datamatrix, QRcode or other ? ) printed B&W on a flat or cylindrically curved label;
    And assuming the width of barcode itself represents 20 to 80% of the captured image width :

1- What would be the ideal imager resolution (with RAW output):
  A- Assuming ideal optics / lighting  / focus / exposure / lack of motion blur etc.
  B- under typical "real-world" conditions with a typical cell-phone / tablet imager ?

2- Autofocus "vanilla" 3-5MPixel camera VS fixed-focus "custom optics" (HD wideangle/flatfield/macro?) @ 0.3 to 2Mpixel
it seems the major downside of the fixed-focus cameras found in may phones etc. is that their optics are designed for typical photography,
with a min. focal distance quite far from camera ( ex. 1-3 feet ) which hampers getting clear focused images without a high-res imager (barcodes would be very small portion of image)
A- Has anyone experimented with using a macro lens to improve this? (there are plenty of cheap ones now that can be bought for a few bucks that clip on or use magnets for cellphone use)

In our case, Camera is fixed, and user will present the object to the scanner (mounted on a wall)
A 7" LCD can optionally be used to display the live video to help guide the user in positioning the object, though we would prefer if this was not necessary.
Ideally the focal range/depth of field of the camera would be on the order of 3" to 24"
Very strong direct LED lighting will be projected on the objects, allowing very fast shutter speeds, thus minimizing motion blur artifacts.

With an appropriate wide-angle fixed-focus lens, the depth of field becomes terribly shallow, even with small apertures (need strong lighting) of f/11 to f/22 , on the order of a few mm to a cm or 2 max.
With a such a camera (at 15 or 30 fps), where a user is "presenting" an object to the camera, we might expect to get only one or very few frames in sharp focus -
as the object approaches the camera and goes through the focal point -
What i'm wondering is,
A - is it possible using zxing to detect and preferentially process only those frames which are in sharp focus ?
      in this case we can give the user audio or color feedback cues to indicate when the object is too far, too close, or in the "butter zone"
B - would this method yield optimal results: high scan speed & accuracy, and an easy / intuitive user experience ?
Or,
Would it be better, and simpler, to simply use a cheap 3-5 megapixel "autofocus" camera module?
   - would 1.3megapixel be sufficient ?

Finally, if we made our own camera, would B&W be better, compared to a typical BAYER format color imager ?
  - i imagine, if necessary, RGB LED lamps could be used to light up the object in different colors to find the one that maximizes contrast on the barcode.

Any and all comments are welcome!
Thanks!



frantz robinson

unread,
Mar 15, 2013, 9:45:04 PM3/15/13
to zx...@googlegroups.com
Hi Sean,
Thanks for your quick and thoughtful reply.

One thing i think i didn't make clear before is that were not using an existing tablet, we've designed our own platform, from the ground up, around a popular processor found in many consumer Android devices.
Thus we don't have to live with the design compromises in consumer devices, we can tailor ours as we see fit.
Ditto if we decide to design our own board-level camera module for barcode scanning if it comes down to that, though i think we might be able to avoid the extra headache.

If necessary we can upgrade to a quad-core processor, but hopefully that wont be-

So as far as preview mode vs picture resolution, well, we get to choose what resolution is used in preview mode, or feed into zxing.
Image sensors under consideration can output the full 5mpixel (2592x1944) RAW images at 30fps. Or any scaled down version of that. Thus the questions about optimal image resolution for zxing -

I went ahead and did a few "back of the envelope" calculations today to try and figure out what is minimum or useful /recommended resolution to safely get a good scan of an imaged barcode every time:

Assuming: typical small printed barcode (linear) with a minimum element width ~ 0.2mm (measured) which gives a "DPI" of ~125 as printed;
multiply that by 2 = 250 (2 pixels per line/space min) average up to 300 for extra margin ;

Now our use case resembles a supermarket price verifier, sometimes seen mounted on the end of an isle or post in a large store. this is not a user-maneuvered, handheld device.
because of that and the large range of objects an codes we need to be able to capture, a generous scan area is mandated - perhaps 8" x 6" at peak focal distance, which will be ~ 30cm from the imager.

8" x 300 DPI = 2400 pixels wide. Thus it seems we actually need the 5MPixel imager to satisfy all requirements. 
Now granted a smaller barcode can be moved in closer if there is autofocus or DOF allows, but i've seen barcodes 4-5" wide on large odd-shaped packages that would not allow that, so we try to design for worst-case conditions.

Given these atypical operating conditions, i'm trying to figure out how to best adapt zxing, if its even possible, to work in this scenario, and give reasonably fast, accurate, and reliable reads.

I guess the biggest unknown for me which can have a big impact here is, how to quantify the time it might take to process an image - which i imagine can vary a lot -
but its useful to get a ballpark number here to figure out what framerate can be supported that wont cause zxing to "give up" and switch to a new frame, if it could have found & read the barcode given more time -
and get a sense of what worst case latency might be.

For example  - (discaimer: i havent dug into zxing internals, so i have no clue if this applies or not)

Say that on a typical VGA preview image, on a typical cheap 7" single-core tablet, zxing can scan the whole image and detect & decode 98% of barcodes in 30mS.
Maybe it does in a linear fashion, scanning top to bottom, left to right.
So in this case even at 30fps (33mS/frame), you get excellent results in general.
How does that scale to a full 5Mpix image stream ?
Assuming image throughput scales linearly with pixel count (which is probably wrong, it may be more exponential)
we have 16.4x the number of pixels compared to VGA. 16.4 * 30mS = 492mS, nearly 1/2 second. (my gut feeling is longer in reality)
If we feed this stream into zxing at 30fs, and it switches to a new frame the instant one is available, well i don't see how this could work.
Less than 1/10 of the frame would get scanned in the allotted time, and we'd have to be very lucky with the barcode size and position (within the frame) to get a good read.
So if this were true, it seems some other strategy or tricks would have to be applied - or combination of them, to get good results.

So the big question is,
Is there any way to roughly quantify how much time it takes to process an image? given one or more scenarios - of scan parameters (enabled barcode types, etc ), image size, actual barcode type, orientation and image quality ?

Thanks

Frantz
Reply all
Reply to author
Forward
0 new messages