Click to See Complete Forum and Search --> : Barcode readeing using C++


MuffDiver99019
August 8th, 2008, 09:50 AM
The purpose is the read barcode using web cameras.

what's given is the algorithm to read from the web cam and canny edge detector.

I have managed to get my algorithm to work on ideal and near ideal situations on images after canny edge detector processed.

but when I tried to use real web cam captured images my algorithm does not work unless I spend a long time position the barcode to near ideal situation.

here's are 3 samples of barcode I obtained using my webcam, and I can only read the last 5 digits of the top left barcode.
http://i38.tinypic.com/122bsyh.jpg


Now I know my algorithm is too simplistic, but here it is:

Find where barcode begins and ends, and calculate the bar width= barcode image width/95 bars.

using only the horizontal strip from the barcode.height/2, starting from the leftmost line, stepping with step size, take the mid point of each bar width and determine if it's 0 or 1, put the result in the array size of 95.

By taking the average width using barcode begin and barcode ends I manage to solve the problem of varying barcode width.

But if you look at the image I captured, immediately you will notice my algorithm will not work when there is noise in the horizontal strip from the barcode.height/2, or if the lines are discontinuous at that strip.

I tried a quick way to solve the problem by doing this:
when I encounter a white pixel at the horizonetal strip, I look up and look down 10 pixels and see if white pixels are there as well, etc. but from the top left barcode in the image, you can see that the 1st line is not straight, it's rotated and curved, looking up and down 10 pixels will not work.

My friend suggested me to use hough transform which can correct the rotated and curved lines and find the most vertical lines and my simple algorithm will work.

but I don't think hough transform can recognize all the lines within 30 seconds.

So my question is this: is there any way to test if the pixel I found on the horizontal strip belong to a line or noise without a lot of calculations?