From: Daniel Seow on
hey guys, im doing a project on barcode reader now. my system is able to decode barcodes now, but now im facing a problem of locating the barcode in the image. well anyone knows what method is good to locate a barcode instead of using imcrop?
in addition, im trying to fix the barcode alignment problem. i ve been asked what if my barcode is not aligned perfectly in horizontal direction, is there any function that is able to rotate the out of alignment vertical lines in the barcode?
i just need theories and explanation :) is better if u can put in the command =P
From: Walter Roberson on
Daniel Seow wrote:
> hey guys, im doing a project on barcode reader now. my system is able to
> decode barcodes now, but now im facing a problem of locating the barcode
> in the image. well anyone knows what method is good to locate a barcode
> instead of using imcrop?
> in addition, im trying to fix the barcode alignment problem. i ve been
> asked what if my barcode is not aligned perfectly in horizontal
> direction, is there any function that is able to rotate the out of
> alignment vertical lines in the barcode?
> i just need theories and explanation :) is better if u can put in the
> command =P

Convert the image to black and white, label it using bwlabel, use
regionprops() to find the centroids of the lines, The angle from the
centroid of the first barcode stripe to the centroid of the last barcode
stripe will tell you how much you would have to rotate the image around
the first centroid in order to align the stripes horizontally.

Next trick: figuring out whether your barcode is rotated upside-down...