improving accuracy on zxing

4,344 views
Skip to first unread message

Pat_Cork

unread,
Aug 2, 2012, 12:08:41 PM8/2/12
to zx...@googlegroups.com
Hi all
I'm using the java command line runner of zxing (latest build from the SVN server) to sacn in images of files, and process them the acruacy that I'm getting is vairing from 53% - 85%, but it vairies alot,at the moment I'm using 21 images, but this will go up to 100+ images every week, I've attaced the image, I was hoping to get 100% but it looks like that I not going to get near that number, is there any tips that people out there can give me to improve the accuracy.

I'm currently using imagemagik, to crop out the image where the qrcode is in on the page for the more difficult images, to improve accuracy, which is helping, but I'm still only getting up to 80%, Does the magic silver bullet exist!! :) or did I miss that lession? :)

RawQRCodeDecodelog-2012-08-01.log:Decoded 6 files out of 11 successfully (54%)
RawQRCodeDecodelog-2012-08-02-12:51:56.log:Decoded 21 files out of 25 successfully (84%)
RawQRCodeDecodelog-2012-08-02-12:56:57.log:Decoded 8 files out of 15 successfully (53%)
RawQRCodeDecodelog-2012-08-02-14:02:37.log:Decoded 8 files out of 15 successfully (53%)
RawQRCodeDecodelog-2012-08-02-14:03:51.log:Decoded 8 files out of 15 successfully (53%)
RawQRCodeDecodelog-2012-08-02.log:Decoded 8 files out of 15 successfully (53%)

Thanks for all yer help so far.
Pat
1343208516_23017_TutoialAttendance001.XSM_00000001Copy2.jpg

Steven Parkes

unread,
Aug 2, 2012, 12:16:19 PM8/2/12
to Pat_Cork, zx...@googlegroups.com
Is this supposed to be an example of an image that doesn't decode? I had no trouble decoding it, both with Java and C++.

Pat Rice

unread,
Aug 3, 2012, 8:01:19 AM8/3/12
to Steven Parkes, zx...@googlegroups.com
Hi Steven
Thanks for the reply, the one attached was and example of what I'm trying to do, I'm trying to up the accuracy, and I'm looking for tips on how to do it, as it fails randomly is there any way I can make the "--tryharder" option even longer?, I've noticed that when I use the QRreader in the Android phone, that the QR code is eventually decoded once I give it a bit of time, so it does work, but with the command line runner, I don't have the option of increasing the time to "look" at the Image thus the code fails, or maybe I'm not using the right options
 
I hope you understand what I trying to get across and  again thanks for coming back to me.
 
Thanks
Pat

Lachezar Dobrev

unread,
Aug 3, 2012, 8:37:30 AM8/3/12
to Pat Rice, Steven Parkes, zx...@googlegroups.com
The ZXing project is designed around the
if-you-fail-try-and-try-again principle. This principle works very
well for constant streaming images, such as those coming from a
Camera. The downside is that even seriously low success rates are
considered acceptable, since the success rate is stackable.

The common talk in this project is that:
'A failure to scan a particular image is not a bug'.

This principal works extremely well for mobile devices (where camera
is the principal source):
- it requires limited CPU, thus saving on battery.
- it works blazing fast, thus enabling low-end devices.
- 1 in 10 rate means a bar-code scanned in 1-2 seconds, which is acceptable

However for One-Shot-One-Kill ZXing does not cut it (as of yet).
I myself have dropped the idea to use ZXing to read codes from
scanned documents.

However! If you have more processing power you can apply distortions
to the images and weirdly enough enhance the success rate.
Common nudges include:
- Blur the image (various blur sizes)
- Sharpen the image (especially after a blur)
- Resize the image (scale down works very well)
- Rotate the image (±45°, ±90°, etc.)

If you have the CPU power to do that those are all automation-supported tasks.

2012/8/3 Pat Rice <patrick...@gmail.com>:
> --
>
>
>

Pat

unread,
Aug 3, 2012, 9:32:00 AM8/3/12
to Lachezar Dobrev, Steven Parkes, zx...@googlegroups.com
Thanks Lachezar
What are you using to read QRcodes from scanned images?

I was thinking that al-right, that It wasn't a bug, I'm using imagemagik
to crop out the image, and this is improving the image, I'm running this
on a ubuntu server, so It will eventually run as a cron, when the
contents of a directory changes, so I should be ok on processing power.

I've scaled down the image to 400px square, but I haven't done that on
the problem images... Which I might try on the Crop'ed images.

I haven't tried doing any blurs (below) on the image or sharpening the
image, but I presume I could try below, I wondering though am I "pushing
water up hill" :) as in this might just be too hard for zxing when using
it with scanned images

http://www.imagemagick.org/Usage/blur/

http://www.imagemagick.org/Usage/blur/#sharpen

Thanks again Lachezar, I great to know other people are using this stuff
out there and that I'm not crazy :)

Pat

Steven Parkes

unread,
Aug 3, 2012, 10:58:29 AM8/3/12
to Pat, Lachezar Dobrev, Steven Parkes, zx...@googlegroups.com
The example you posted is pretty low resolution. There are less than two samples per QR module.

A few things that might improve the recognition rate:

If you are producing the codes, instead of putting in a very long URL, use a URL shortener that redirects. The codes will be much less dense and have a higher recognition rate.

Scan the image at higher resolution.

You can try some of the techniques mentioned before with imagemagick. You can try just magnifying the image with various interpolations and see if it helps. The open source version of ZXing doesn't try to do any subpixel detection and I suspect that your sampling rate is close enough to the minimum that that would improve detection. Magnifying the image should be sort of an equivalent. Maybe.

Lachezar Dobrev

unread,
Aug 3, 2012, 11:51:44 AM8/3/12
to Pat, Steven Parkes, zx...@googlegroups.com
Well... We're not reading QR codes from scanned pages.
After reconsidering the pros and cons, we decided, that it would be
too much hassle, and we'll still need people to make sense of the
documents with unreadable codes. So we just dropped it as infeasible:
too much work, too many problems, not a full solution, and not a very
hard requirement.

Just to mention: we were trying to scan codes off Faxed documents.
We have a Fax machine, that sends the Fax as a PDF via e-mail.

2012/8/3 Pat <patrick...@gmail.com>:
>> - Rotate the image (ą45°, ą90°, etc.)

Sean Owen

unread,
Aug 3, 2012, 6:11:42 PM8/3/12
to zx...@googlegroups.com
This scans easily for me. It says:
http://143.239.143.90/welcomeV2.php?fname=AftabLeah&StudentNo=111410238&ModuleNo=lw1054&TicketNo=1&CurrentTime=1343208310&RandomNumber=292720408

One of the most useful things you can do is restrict the scan to the region of the image you know has the barcode. Is it always in the top-left quarter? crop to that region and scan that.

Michael McGrath

unread,
Mar 16, 2017, 6:12:00 PM3/16/17
to zxing, l.do...@gmail.com, smpa...@smparkes.net, patrick...@gmail.com
On Friday, August 3, 2012 at 7:32:00 AM UTC-6, Pat wrote:
> What are you using to read QRcodes from scanned images?

Pat
we're using zbarimg to detect barcodes from scanned docs -- did you end up using something different? Would be interested to know of any successes/failures you have with linux command line barcode detectors.

Thanks,
Michael

Reply all
Reply to author
Forward
0 new messages