Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recognizing barcodes with AI

As a pet project/learning experience (no this is not homework) I'm working on software to recognize barcodes from a photograph. I'm not looking for software or a library that does it - instead I'm using this as a learning exercise that I'm blogging about and will post up on Codeplex.

I have code that successfully recognizes EAN13 barcodes (which I published on CodePlex) and UPC version A/E should follow shortly. I have two areas that I'm concerned about, though. First is in decoding barcodes that are in a picture that is bit blurry or with poor contrast, etc. Second is in simply finding the actual barcode in a larger picture (right now you have to give me a photo of just the barcode).

I have the gut feeling that some form of AI is going to help me out here. I played a bit in the past with genetic algorithms and I took a course ages ago on AI so it's not totally foreign to me, but I'm not quite sure where to start.

What type of algorithm is best suited to this type of problem? Any recommended reading or code for the AI grunt work? Yes, I want to understand what's happening, but I don't necessarily want to go down to the level of coding the sorts, etc myself.

like image 667
ctacke Avatar asked Aug 17 '10 21:08

ctacke


1 Answers

I would suggest to search for properties that a barcode has. Some that I have in mind are:

  1. Histogram of colors shows two distinct colors in about even distribution
  2. Doing a hough transformation finds many parallel lines
  3. The thickness of the lines have two distinct dimensions.

Some other?

Having this I would split the image into pieces and do a classification with these features then cobine the results to calculate a liklyhood if the piece contains an barcode or not.

For your second problem (blurry image) I would suggest to calculate the 1st order derivative of the grayvalues and then detect the edges of the lines in this space. The maximum of the derivative is lower if the image is blurred but it should be detectable to a certain blurring factor.

Does this help you?

like image 130
schoetbi Avatar answered Oct 05 '22 10:10

schoetbi