Scanning barcode on a curved surfaces

3,822 views
Skip to first unread message

Max

unread,
Sep 19, 2011, 6:56:03 AM9/19/11
to zxing
Hello!
I've installed ZXING BarCodeScanner on my Android phone and tried to
scan/recognize barcodes on a rounded surfaces (bottles) and it fails

It looks bar code recognition works fine on a codes printed on a flat
surfaces and it doesn't work (eternal autofocusing ) on a rounded
surfaces ...

Is there any know issues on that? Does BarCode scanner cannot
recognize codes on a curved surfaces?
Or this can be an issue of demo app provided (BarCodeScanner) ?
or this can be a problem of apparent light gradient which takes place
if surface is not flat (I saw some comment regarding gradients in a
code ...)?

Finally, the question is: has anyone successfully used ZXING BarCode
scanner to read barcodes printed on a curved surface?
If so, would you please share any knowledge on what is required to
make this possible

Sean Owen

unread,
Sep 19, 2011, 7:11:13 AM9/19/11
to zx...@googlegroups.com
A little curve is fine -- a lot won't work. It is definitely optimized for flat surfaces. I can scan cans and bottles just fine, so I'd imagine you're having some other problem.

Muhammad Umar

unread,
Aug 16, 2014, 6:51:39 PM8/16/14
to zx...@googlegroups.com
I tried it on various products in a super market, there were two main problems;

1. It wont read any curved surface, unless its ALMOST FLAT,i.e. a radius of 1 feat at least...
2. It wont read very long barcodes...
3. it takes a lot of time in focusing, and trying to read the barcode.

Alternatively, I have used Symbol hand held scanner... and it reads any barcode like a charm...

how can we optimize the current library to reea the barcodes very swiftly?

Sean Owen

unread,
Aug 17, 2014, 2:46:48 PM8/17/14
to zx...@googlegroups.com
The curvature of something like a soda can is fine; I find smaller things like pill bottles hard. It's certainly not true that you need a 1 foot radius, or that it won't read "long" barcodes. I have no idea what you're scanning but you're doing something wrong.

Shachar Shemesh

unread,
Aug 17, 2014, 3:55:17 PM8/17/14
to zx...@googlegroups.com
A while back I tried to suggest a simple fix that would, I believe, solve this problem completely (as well as a few other problems):
Allow zoom.

Zoom would allow you to hold the phone further away from the barcode, reducing the distance difference between the near and far parts of it. In effect, zoom would lessen the curvature of the surface the bar code is printed on.

At the time, this suggestion was rejected. Maybe its time has come...

Shachar

Wayman, Jack A Jr COL USARMY HQDA DCS G-8 (US)

unread,
Aug 17, 2014, 4:25:03 PM8/17/14
to Shachar Shemesh, zx...@googlegroups.com
Avoid induced curvature by holding camera at greater distance and zooming in.

One idea is to set the default zoom setting at a distance that incentivizes the use to hold the camera far enough away that they naturally avoid inducing curvature.
From: Shachar Shemesh
Sent: Sunday, August 17, 2014 3:55 PM
Subject: Re: [zxing] Re: Scanning barcode on a curved surfaces

--
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/d/optout.

Sean Owen

unread,
Aug 17, 2014, 5:24:59 PM8/17/14
to zx...@googlegroups.com
Shachar, I looked back at that thread, and since, I took out zoom from the app entirely, because it is not consistently supported. Its role is to induce the user to hold back further, and that's what the scanning reticle already accomplishes. No, I don't see another reason to add zoom? It's digital, not optical, so does not improve resolution.

Being very close adds perspective distortion at the edges for a camera phone lens, but barcodes aren't close enough for that to be a factor. Why would it have anything to do with correcting perspective distortion on a curved surface? the surface is still curved and is convex, not concave.

Sean Owen

unread,
Aug 17, 2014, 5:26:08 PM8/17/14
to zx...@googlegroups.com, sha...@shemesh.biz
I don't understand this. The curvature is real, not an artifact of the lens.

Wayman, Jack A Jr COL USARMY HQDA DCS G-8 (US)

unread,
Aug 17, 2014, 6:22:24 PM8/17/14
to Sean Owen, zx...@googlegroups.com, sha...@shemesh.biz
Right.   I'm only suggesting the minor lens distortion might make minor physical curvature more challenging to read. 


From: Sean Owen
Sent: Sunday, August 17, 2014 5:26 PM
Subject: Re: [zxing] Re: Scanning barcode on a curved surfaces

--

Shachar Shemesh

unread,
Aug 18, 2014, 1:48:15 AM8/18/14
to zx...@googlegroups.com
On 18/08/14 00:24, Sean Owen wrote:

Being very close adds perspective distortion at the edges for a camera phone lens, but barcodes aren't close enough for that to be a factor. Why would it have anything to do with correcting perspective distortion on a curved surface? the surface is still curved and is convex, not concave.

At the time, I asked for a digital zoom because I was trying to get zxing to work on a very low end camera that had a low screen resolution. This resulted in a conflict between the distance you need to hold the phone in order for the bar code to be big enough to be accepted, and the distance in which the phone could focus. I also offered, as an alternative, to allow capturing a picture and processing that.

You said no. My need went away. I let the matter drop. I still think processing a static picture is a good one (it will also allow zxing to read pdf417 bar codes, which it currently is practically unable to do), but so long as no one else brought it up, I let it go.

This is different. The curvature does not change as a result of how far away you hold the phone, but its effects are. This has nothing to do with lens distortion (which I doubt are severe enough to interfere anyways), and everything to do with linear optics. Let's take an extreme example to demonstrate.

Let's take a curvature that makes the edges of the bar code 5cm further away than the middle. No one expects any bar code reader to read such a thing, but for the sake of our example, let's analyze it. If you hold your phone 5cm away from the nearest point of the bar code, the bars on the sides will have a time code twice as high as the bars in the middle. If you hold the phone 10cm away, the bars on the side will only be 50% higher. If you put a telephoto lens on your phone, and try to read the bar code from a kilometer away, the bars will have a time code that will be, for all intents and purposes, uniform.

So, the further away you hold the phone, the easier it is for the application to read curved bar codes. In order to encourage, or even allow, people to hold the phone further away, you need zoom. Yes, even a default digital zoom factor of 2 or 4 would do the trick.

There is one caveat. The bigger the zoom, the more shaky the picture. Since zxing is analyzing the live picture, that will probably interfere somewhat. I don't know how much.

As before, I think taking a snapshot, even as an option, might be a solution. Personally, I think we can have an "auto" mode, where, if zxing thinks there might be a bar code in the picture, it takes a snapshot and analyzes the full resolution result. I actually think there are many use cases where this will decrease the time it takes to recognize a bar code.

Hope this helps,
Shachar

Sean Owen

unread,
Aug 18, 2014, 3:29:48 AM8/18/14
to zx...@googlegroups.com
The bars at the center are normal-width, and they become thinner down to 0 as you move around the surface and the line from bar to lens becomes perpendicular to the surface. The width is proportional to the angle between this line and the plane of the lens. It is not at all proportional to the distances between the near and far point. By this logic, when really close to the barcode, the side bars are wider. Also by this logic, I would see bars and nearly the side of the can as the same width if I were far enough away, which isn't so. 

But more than all this -- digital zoom is exactly that, just zoom, doesn't make you farther away. The app already does that a different way, the reticle.

Shachar Shemesh

unread,
Aug 18, 2014, 3:04:52 PM8/18/14
to zx...@googlegroups.com
On 18/08/14 10:29, Sean Owen wrote:
The bars at the center are normal-width, and they become thinner down to 0 as you move around the surface and the line from bar to lens becomes perpendicular to the surface.
I need to think about it.

My first impulse is to say you are conflating two factors - one is the angle between the surface and the camera and the other is the curvature of just the bar code. The two are related, but not the same. Don't get me wrong - distancing the camera will reduce that effect as well (place the camera really close to a soda can, and you only cover 30 degrees of the can. Distance it to infinity, and you can capture 180 degrees), but I concede that no distance will cause the bars width to be the same.

Like I said, I need to think about it.

The width is proportional to the angle between this line and the plane of the lens. It is not at all proportional to the distances between the near and far point. By this logic, when really close to the barcode, the side bars are wider. Also by this logic, I would see bars and nearly the side of the can as the same width if I were far enough away, which isn't so.
True. Then again, if the bars don't cover too much of the angle of the curvature, the first effect is still important.


But more than all this -- digital zoom is exactly that, just zoom, doesn't make you farther away. The app already does that a different way, the reticle.
Here I disagree. Had the app taken the image at raw resolution, I might agree more. As things stand, for many bar code styles, if you do not get the camera close enough that the bar code fills almost the entire reticle, you won't get a detection (unless your screen resolution is super high). This means that putting in a x2 zoom will, effectively, make people take the picture from twice as far.

Shachar

Joe Falconer

unread,
Aug 18, 2014, 3:12:16 PM8/18/14
to zx...@googlegroups.com

Not sure I understand the logic of the optics discussion but a smaller framing rectangle or digital zoom may help since both can force an increase in lens to target distance. I'm not sure of the amount of improvement that can be achieved (maybe lens and stability related). Maybe you have a "curved barcode" option that either increases zoom or changes the frame size if the selected previewSize is going to provide sufficient resolution. This makes more sense now that larger preview sizes are prioritized.

I'd do an experiment that doesn't need any code mods. Take a digital image of a curved barcode that won't scan taken at twice the distance than the standard barcode frame would suggest (without image stabilisation). Try to scan the image. If Shachar's view is correct, the barcode is more likely to scan.

In fact I'd take two images: one at the normal distance and one at the increased distance so that the distance effect can be compared and examined visually

Joe

Reply all
Reply to author
Forward
0 new messages