Barcode decoding

From JasonAntmanWiki
Jump to: navigation, search

I've often had some ideas where I thought it would be nice to track things by barcodes. Especially with all of the computer and network hardware that I have, it could prove useful. Especially since I have a Brother label printer that will do barcodes. Unfortunately, barcode scanners are somewhat expensive. So I searched for some alternatives.

After doing a quick search on SourceForge, I found a few projects that could extract barcodes from images. I selected the Zebra project, which claimed to provide ready-to-run command line tools.

I downloaded the source, and set about compiling it. After searching out dependencies (it turns out that while Zebra asks for ImageMagick and the -devel packages, I also needed ImageMagick-Magic++ and -devel) I successfully installed it. A quick run of ldconfig fixed some module issues. I then downloaded some random images containing barcodes by doing a Google image search for "barcode". Running the software (zebraimg) on them yielded the correct result.

Webcam Integration

The next step was to integrate a webcam into the system. Once I got the webcam working, it was time for a test. I grabbed the first thing that was handy on my desk with a barcode - a package of Sharpie markers.

My minimalist webcam setup - only capturing single JPEGs with a command-line tool - wasn't exactly adequate for adjusting the camera for a good image. The first one that I got, which I thought was acceptable, wasn't read by Zebra. Unfortunately, Zebra doesn't have any option for debugging output, so there's no help in figuring out why it doesn't work.

It seems to me, that there were two main problems with the webcam images - 1) the quality was poor around the edges and 2) the amount of color and/or low contrast was a problem.

So, I decided to find a barcode encoding system and do some tests with my label printer. I chose EAN-13. I first tried an online generator that gave me a GIF file. Zebra recognized it perfectly. I printed off an identical barcode with my printer on 1" wide white label tape. I slapped it on the bottom of an old hard drive hot-swap tray and set about working some magic with the el-cheapo webcam.

It seems that even a larger issue than the low resolution on the webcam is the quality of lighting. Zebra seems to need as close to a B&W high-contrast image as possible. Moving around my desk lamp, I was able to get Zebra to recognize 2 of 12 images, and even then the barcode recognition was slightly inaccurate. My sample, 2 500001 000002 was being recognized every time as 2 500001 00000. I don't know the intricacies of barcodes or EAN-13, but I can't understand why the last digit was being dropped off. Interestingly, though, my GIF sample generated from the above site, identical to the printed label, was being recognized identically.

More to come...

Views
Notice - this is a static HTML mirror of a previous MediaWiki installation. Pages are for historical reference only, and are greatly outdated (circa 2009).