I. Pretreatment steps

Obtain the image data transmitted by the main program, and then preprocess the image, including gray processing and geometric correction, of which the gray processing process is: 1.1 gray

1.2 Median filtering

1.3 binarization

1.4 Geometric correctionTreatment results: You can find that the image after binarization is not “positive”, so we need to make geometric correction.

Geometric correction process:

1.5 Setting sampling points

1.6 Collect the black bar code coordinates of the bar code

1.7 The Angle of geometric correction is determined by the coordinate difference of sampling points. (If it is recognized in real time, in order to save the computing power of the computer, it can be considered that the position of the image can be interfered with by manually adjusting the number)

Geometric correction function:imrotate

When the image preprocessing is completed, the image barcode recognition stage is carried out. The processing process mainly uses the data collected from five sampling points. All five sampling points should be collected once, and collected in line. After the collection, the program will extract the spline data. In each extraction, the program will remove the minimum and maximum data of the five collection points, and then carry out post-processing for the remaining three data. First, determine whether 59 splines are collected at the collection point (one-dimensional bar code has 95 modules excluding the blank areas on the left and right, 59 splines referred to in this paper refer to the number of black and white splines, while 95 modules in one-dimensional bar code refer to the sum of the number of standard modules occupied by each black and white bar), if 59, continue to read data processing. If not, the calling function falls back and waits for the main program to pass the image again. When it is 59 splines, the extracted data is averaged and stored in a matrix. Example:A value of 1 in the figure above is the number of pixels contained in the black spline of the bar code, and a value of 0 is the number of pixels contained in the white spline of the bar code. The figure below is a one-dimensional image showing the number of black and white spline pixels read from the figure above.

Finally, a decoding algorithm is developed according to the coding rules of one-dimensional bar codes. The obtained matrix is put into the decoding algorithm, and finally the Arabic digit code that can be recognized by human is obtained through comparison and calibration