CN-121999045-A - Bar code positioning method based on deep learning and electronic equipment
Abstract
The application relates to the technical field of bar code recognition, and discloses a bar code positioning method based on deep learning and electronic equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining a bar code image, segmenting the bar code by adopting an image segmentation model, generating a starting symbol locating chart, a data area locating chart and a terminator locating chart, determining an upper boundary detecting starting point, a lower boundary detecting starting point, a data area left boundary detecting area and a data area right boundary detecting area according to the locating charts, performing corrosion operation in the horizontal direction on the bar code image, traversing pixel points on the corrosion image from the upper boundary detecting starting point to the lower boundary detecting starting point, determining an upper boundary and a lower boundary of the bar code, traversing pixel points on the bar code image, which are positioned in the data area left boundary detecting area and the data area right boundary detecting area, determining a left boundary and a right boundary of the data area, and determining a locating coordinate point of the data area in the bar code according to the boundaries. By the method, the efficiency and the accuracy of bar code positioning are improved, and the decoding capability of the electronic equipment in a complex scene is improved.
Inventors
- LIU HONGLIANG
- LIN MIAO
- DAI ZHIWEI
- LI QINGJIAN
- CHEN QI
- CHEN ZHILIE
Assignees
- 深圳市研祥金码科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260121
Claims (10)
- 1. A barcode locating method based on deep learning, the method comprising: acquiring a bar code image, and segmenting a bar code in the bar code image by adopting a pre-trained image segmentation model to generate a start symbol positioning map, a data area positioning map and a stop symbol positioning map; determining an upper and lower boundary detection starting point according to the initiator positioning chart, the data area positioning chart and the terminator positioning chart; performing corrosion operation in the horizontal direction on the bar code image to obtain a corrosion image; sequentially traversing pixel points of the corrosion image upwards from the upper and lower boundary detection starting points to determine the upper boundary of the bar code; Sequentially traversing pixel points of the corrosion image downwards from the upper and lower boundary detection starting points to determine the lower boundary of the bar code; Determining a left boundary detection area and a right boundary detection area of the data area according to the data area positioning map; Traversing pixel points on the bar code image, which are positioned in the left boundary detection area of the data area, and determining the left boundary of the data area in the bar code; Traversing pixel points on the bar code image, which are positioned in the right boundary detection area of the data area, and determining the right boundary of the data area in the bar code; And determining a positioning coordinate point of the data area in the bar code according to the upper boundary, the lower boundary, the left boundary of the data area and the right boundary of the data area.
- 2. The method according to claim 1, wherein before determining the upper and lower boundary detection start points according to the initiator positioning map, the data area positioning map, and the terminator positioning map, further comprising: detecting the initiator positioning map, the data area positioning map and the terminator positioning map to obtain edge points of the initiator, the data area and the terminator in the bar code; Calculating a first linear voting matrix according to the coordinates of the edge points, and determining the linear angle with the highest voting number in the first linear voting matrix as the angle of the bar code; Rotating the bar code image, the initiator positioning map, the data area positioning map and the terminator positioning map according to the angle of the bar code; Judging whether the bar code is reverse or not according to the initiator positioning chart and the terminator positioning chart; And if the bar code is in the reverse direction, rotating the rotated bar code image, the initiator positioning chart, the data area positioning chart and the terminator positioning chart by 180 degrees.
- 3. The method for positioning a barcode based on deep learning according to claim 2, wherein the determining whether the barcode is reverse according to the initiator positioning map and the terminator positioning map comprises: Calculating the average value of the abscissa of each pixel point in the initiator region in the bar code image according to the initiator positioning chart to obtain a first average value; calculating the average value of the horizontal coordinates of each pixel point in the terminator region in the bar code image according to the terminator positioning chart to obtain a second average value; If the first average value and the second average value are not equal to zero and the first average value is larger than the second average value, determining that the bar code is reverse; If the first average value or the second average value is equal to zero, acquiring the image width of the bar code image, and calculating a position threshold according to the image width; if the first average value is equal to zero, and the second average value is greater than zero and smaller than the position threshold value, determining that the bar code is reverse; And if the second average value is equal to zero and the first average value is greater than the position threshold value, determining that the bar code is reverse.
- 4. The deep learning based barcode locating method of claim 1, further comprising: determining a left boundary detection area of the initiator according to the initiator positioning chart; Traversing pixel points on the bar code image, which are positioned in the left boundary detection area of the initiator, and determining the left boundary of the initiator in the bar code; And determining a positioning coordinate point of the initiator in the bar code according to the upper boundary, the lower boundary, the left boundary of the initiator and the left boundary of the data area.
- 5. The deep learning based barcode locating method of claim 1, further comprising: determining a terminator right boundary detection area according to the terminator positioning map; Traversing pixel points on the bar code image, which are positioned in the detection area of the right boundary of the terminator, and determining the right boundary of the terminator in the bar code; and determining a positioning coordinate point of the terminator in the bar code according to the upper boundary, the lower boundary, the right boundary of the data area and the right boundary of the terminator.
- 6. The method for positioning a barcode based on deep learning according to claim 1, wherein the determining the upper and lower boundary detection start points according to the initiator positioning map, the data area positioning map and the terminator positioning map specifically comprises: Traversing the initiator region in the initiator positioning chart, the data region in the data region positioning chart and the terminator region in the terminator positioning chart, and calculating the ordinate average value of all pixel points; and determining a pixel point with the ordinate equal to the average value of the ordinate in the corrosion image as an upper and lower boundary detection starting point.
- 7. The method for positioning a barcode based on deep learning according to claim 6, wherein the sequentially traversing pixels of the corrosion image from the upper and lower boundary detection start point upward to determine an upper boundary of the barcode specifically comprises: Respectively acquiring first pixel values of the pixel points with the same coordinates on the initial symbol positioning map, the data area positioning map and the termination symbol positioning map according to the coordinates of the pixel points traversed currently; If the first pixel value is in the preset threshold range, second pixel values of two pixel points adjacent to the pixel point currently traversed in the vertical direction in the corrosion image are obtained; If the difference value between the second pixel values is larger than a first preset threshold value, determining the pixel point traversed currently as an upper boundary point; within a first preset angle range, calculating a second straight line voting matrix according to the upper boundary point; And determining the straight line with the highest voting number in the second straight line voting matrix as the upper boundary of the bar code.
- 8. The method for positioning a barcode based on deep learning according to claim 1, wherein the determining a left boundary detection area of a data area and a right boundary detection area of the data area according to the data area positioning map specifically comprises: Traversing all pixel points in the data area positioning map, calculating pixel difference values between two pixel points adjacent to the pixel point traversed currently in the horizontal direction, and determining a left edge point and a right edge point in the data area positioning map according to the pixel difference values; Calculating the abscissa average value of the left edge point, and determining a left boundary detection area of the data area according to the abscissa average value of the left edge point; And calculating the abscissa average value of the right edge point, and determining the right boundary detection area of the data area according to the abscissa average value of the right edge point.
- 9. The method for locating a barcode based on deep learning according to claim 1, wherein traversing the pixel points on the barcode image located in the left boundary detection area of the data area to determine the left boundary of the data area in the barcode specifically comprises: If the pixel difference value between two pixel points adjacent to the pixel point traversed currently in the horizontal direction in the bar code image is larger than a second preset threshold value, determining the pixel point traversed currently as a left boundary point of a data area; within a second preset angle range, calculating a third linear voting matrix according to the left boundary point of the data area; and determining the straight line with the highest voting number in the third straight line voting matrix as the left boundary of the data area in the bar code.
- 10. An electronic device comprising a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to implement the deep learning based barcode locating method of any one of claims 1-9.
Description
Bar code positioning method based on deep learning and electronic equipment Technical Field The embodiment of the application relates to the technical field of bar code recognition, in particular to a bar code positioning method based on deep learning and electronic equipment. Background Bar codes are a graphical symbology for representing data, formed by a series of bars and spaces of unequal widths arranged according to a specific coding rule. Taking PDF417 bar code as an example, PDF417 bar code is a high-density and high-capacity two-dimensional stacked bar code, which has strong information storage capacity, can encode data such as characters, images and biological characteristics, and is widely applied to multiple fields. Currently, the PDF417 barcode mainly adopts image preprocessing, edge detection, contour extraction, barcode region screening and other steps to identify, so as to locate a barcode region in a barcode image through contour information in the barcode image, and thus, information stored in the barcode is obtained by performing decoding operation on the barcode region. However, in the prior art, whether there is a connected rectangle in the barcode image is generally detected by the profile information to find the initiator and the terminator in the PDF417 barcode, and finally the barcode region in the barcode image is located based on the initiator and the terminator. When the initiator or the terminator Fu Queshi (or the defect) of the PDF417 bar code is detected, the positions of the initiator and the terminator cannot be accurately found by finding the connected rectangle, which results in that the electronic device cannot accurately identify the bar code due to the positioning failure of the bar code area. Although deep learning algorithms such as image recognition and object recognition are also used to find the initiator and terminator of the bar code, the deep learning algorithm can only determine the approximate positions of the initiator and terminator in the bar code, and cannot accurately locate the boundaries of the initiator, data area and terminator. Disclosure of Invention In view of the above problems, the embodiment of the application provides a barcode positioning method based on deep learning and an electronic device, which are used for solving the problem that the electronic device in the prior art cannot accurately identify barcodes due to positioning failure of barcode areas. According to one aspect of the embodiment of the application, a barcode positioning method based on deep learning is provided, and the method comprises the steps of obtaining a barcode image, segmenting a barcode in the barcode image by adopting a pre-trained image segmentation model, generating a starting character positioning map, a data area positioning map and a terminator positioning map, determining an upper boundary detection starting point and a lower boundary detection starting point according to the starting character positioning map, the data area positioning map and the terminator positioning map, conducting horizontal corrosion operation on the barcode image to obtain a corrosion image, traversing pixels of the corrosion image upwards from the upper boundary detection starting point and the lower boundary detection starting point, traversing pixels of the corrosion image downwards from the upper boundary detection starting point and the lower boundary detection starting point to determine the lower boundary of the barcode, determining a left boundary detection area of the data area and a right boundary detection area of the data area according to the data area positioning map, traversing pixels of the barcode image, which are positioned in the left boundary detection area of the data area, determining the right boundary of the barcode image, traversing pixels of the barcode image which are positioned in the right boundary detection area of the data area, determining the right boundary of the data area of the barcode image according to the upper boundary detection starting point and the lower boundary detection starting point and the right boundary detection area of the data area. According to another aspect of the embodiment of the application, there is provided an electronic device, including a memory, a processor and a computer program stored on the memory, where the processor executes the computer program to implement the above-mentioned barcode locating method based on deep learning. In the embodiment of the application, on one hand, the initiator, the data area and the terminator can be found out at one time through the image segmentation model, so that when the data area of the bar code is precisely positioned, only the area initially positioned by the image segmentation model is needed to be calculated, and the efficiency and the accuracy of bar code positioning are effectively improved. On the other hand, the embodiment of the application realizes accurate positioning of