以USB摄像头为输入设备,提出一种改进的EAN-13条形码定位和识别算法.首先,视频连续两帧图像进行差分运算,当其绝对值小于一定阈值,捕获当前图像帧,进而用形态学的膨胀和腐蚀算法对捕获到的图像进行条形码区域的定位;然后,用大律法求定位后图像的全局阈值并对其进行二值化;再然后,用所提出的矩形平移的校正方法对倾斜的条形码进行倾斜校正;最后,用平均宽度法计算出条形码条和空的宽度,接着识别条形码并判断是否识别正确.实验结果表明,该算法识别速度快,识别率高.
Taking USB Camera as the input device, an improved EAN-13 barcode loaction and recogniton algorithm was proposed. First, the differences of the two successive frames was calculated. The current image frame was captured when the absolute value of the differences was less than a certain threshold. Morphological dilation and erosion algorithm was used to locate the barcode of the image caught by camera. Then, global threshold calculated by Otsu was used to segment the image located. Then, geometric correction of the tilted bareode was realized by the method of rectangular panning that was proposed in this paper. Finally, the barcode was recognised after calculating the barcode and empty width and judged whether was right. Experiments shows that the algorithm has a high recognition speed and high rate of recognition.