Dot code positioning method and device
The lattice code data points are determined through LBP features and binary search method, and combined with the minimum spacing step generation matrix, the problems of large calculation amount and high misjudgment rate in the prior art are solved, and efficient and accurate lattice code recognition is achieved.
Patent Information
- Application Number
- CN202210546488.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-19
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-05-19
AI Technical Summary
The existing dot matrix code reading methods have a large amount of calculation, poor user experience, and are difficult to distinguish when processing multiple dot matrix codes, resulting in failed reading.
The data points are determined by using LBP features, combined with the binary search method and the minimum spacing step, and by generating a matrix, the calculation amount is reduced and the recognition speed and accuracy are improved.
It greatly reduces the amount of calculation of determining data points, improves the reading rate and accuracy of dot matrix codes, reduces the probability of misjudgment, and can quickly identify multiple dot matrix codes.
Smart Images

Figure CN114912476B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a dot matrix code positioning method and device, and belongs to the field of dot matrix code reading. Background Art
[0002] Dot matrix codes are composed of multiple tiny dots arranged in a certain pattern and are a graphic carrier for recording information. Existing methods for reading dot matrix codes are relatively cumbersome, require a large amount of calculation, and provide a poor user experience.
[0003] For example, the patent publication number CN110276226A, "A Dot Code Detection Method and System," requires calculating the average energy density of a selected area within a sliding window to determine a candidate area; calculating the average energy density of the candidate area after etching to determine a first area; calculating the energy density between each subframe of the first area and the overall energy density of the first area to determine a target area; and finally, merging the target areas to obtain the target dot code area. Multiple energy density calculations are required to determine the code area location, which is computationally intensive.
[0004] For example, patent publication number CN 110245538A, "A Dot Code Positioning Method and System," uses multiple sets of sliding windows of varying sizes to perform trial calculations, selecting the optimal sliding window as the target window. However, multiple rounds of scanning are required to determine the target sliding window parameters, resulting in a high computational load and low efficiency in code region determination.
[0005] For example, patent publication number CN113158704A, "A Method and System for Rapidly Locating Dotcode Codes," uses an initial data point to search for data points in other directions. Based on the distance relationship between the data points, the directions of the two principal axis points are determined to locate the Dotcode code. This method is simple and computationally inefficient. However, each data point requires boundary width calculations in multiple directions, requiring further simplification. Furthermore, if the image being processed contains multiple Dotcode codes, this method cannot distinguish between them, resulting in recognition failure.
[0006] LBP (Local Binary Pattern) is an operator used to describe the local texture characteristics of an image and is widely used in target detection. Existing technologies, such as "A Long-Distance QR Code Location Method" and "A QR Code Location and Recognition System Based on Image Features," use LBP features to identify whether an object is a QR code.
[0007] In summary, a dot matrix code recognition method with less computational effort is needed. Summary of the Invention
[0008] To overcome the problems existing in the prior art, the present invention designs a dot matrix code positioning method that determines data points based on LBP features, greatly reducing the amount of calculation required to determine the data points, thereby improving the dot matrix code reading rate. To achieve the above objectives, the present invention adopts the following technical solutions:
[0009] Technical solution 1:
[0010] A dot matrix code positioning method comprises the following steps:
[0011] Get the image to be processed;
[0012] determining a first scan line;
[0013] Searching for and confirming a first data point along a first scan line in the image to be processed;
[0014] Continue searching and identifying the remaining data points;
[0015] The remaining data points are determined according to the local binary features of the first data point.
[0016] Furthermore, the method further includes: if the first data point cannot be searched and confirmed along the first scan line, determining a second scan line by a binary search method, and searching and confirming the first data point along the second scan line.
[0017] Furthermore, the searching for the first data point is specifically:
[0018] Paired boundaries with a spacing greater than a spacing threshold are searched along the first scan line, where the paired boundaries are boundary points with opposite pixel value change trends.
[0019] Furthermore, the confirmed first data point is specifically:
[0020] Other pairs of boundaries with a spacing greater than a spacing threshold are searched along multiple scan lines passing through the midpoints of the paired boundaries. If at least one other pair of boundaries with a spacing greater than the spacing threshold is found, the first data point is confirmed.
[0021] Furthermore, the determining of the remaining data points based on the local binary features of the first data point is specifically as follows:
[0022] The similarity between the local binary features of the first data point and the local binary features of the remaining data points is calculated, and if the similarity is greater than a similarity threshold, the remaining data points are confirmed.
[0023] Furthermore, the minimum distance between the data points is calculated based on the confirmed data points; the minimum distance is used as a step length, and the remaining data points are searched according to the step length.
[0024] Furthermore, a matrix is generated based on the relative positional relationship of the confirmed data points; and a positioning module is searched in the matrix, where the positioning module includes a plurality of data points with a specific positional relationship.
[0025] Furthermore, the position of the dot matrix code is determined according to the position of the positioning module.
[0026] Technical solution 2:
[0027] A dot code positioning device, characterized by comprising a memory and a processor, wherein the memory stores instructions, and the instructions are suitable for being loaded by the processor and executing the following steps:
[0028] Get the image to be processed;
[0029] determining a first scan line;
[0030] Searching for and confirming a first data point along a first scan line in the image to be processed;
[0031] Continue searching and identifying the remaining data points;
[0032] The remaining data points are determined according to the local binary features of the first data point.
[0033] Furthermore, the method further includes: if the first data point cannot be searched and confirmed along the first scan line, determining a second scan line by a binary search method, and searching and confirming the first data point along the second scan line.
[0034] Furthermore, the searching for the first data point is specifically:
[0035] Paired boundaries with a spacing greater than a spacing threshold are searched along the first scan line, where the paired boundaries are boundary points with opposite pixel value change trends.
[0036] Furthermore, the confirmed first data point is specifically:
[0037] Other pairs of boundaries with a spacing greater than a spacing threshold are searched along multiple scan lines passing through the midpoints of the paired boundaries. If at least one pair of other paired boundaries with a spacing greater than the spacing threshold is found, the first data point is confirmed.
[0038] Furthermore, the determining of the remaining data points based on the local binary features of the first data point is specifically as follows:
[0039] The similarity between the local binary features of the first data point and the local binary features of the remaining data points is calculated. If the similarity is greater than a similarity threshold, the remaining data points are confirmed.
[0040] Furthermore, the minimum distance between the data points is calculated based on the confirmed data points; the minimum distance is used as a step length, and the remaining data points are searched according to the step length.
[0041] Furthermore, a matrix is generated based on the relative positional relationship of the confirmed data points; and a positioning module is searched in the matrix, where the positioning module includes a plurality of data points with a specific positional relationship.
[0042] Furthermore, the dot matrix code is positioned according to the position of the positioning module.
[0043] Compared with the prior art, the present invention has the following characteristics and beneficial effects:
[0044] 1. The present invention determines data points based on LBP features, which greatly reduces the amount of calculation required to determine the data points, thereby improving the dot matrix code reading rate.
[0045] 2. The present invention uses a binary search method to determine the scan line position, effectively improving the speed of finding the first data point and quickly determining whether a dot matrix code exists in the image to be processed.
[0046] 3. The present invention confirms the width of the data point multiple times in different directions, thereby improving the accuracy of the judgment of the first data point and reducing the probability of misjudgment.
[0047] 4. The present invention uses the minimum spacing as the step length and calculates the LBP feature every step length, further reducing the amount of calculation required to confirm the data point. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a flow chart of the present invention;
[0049] Figure 2 It is a schematic diagram of binary search for candidate points;
[0050] Figure 3 It is a schematic diagram for confirming the first data point;
[0051] Figure 4 This is a schematic diagram of LBP feature calculation;
[0052] Figure 5 This is a schematic diagram of Hamming distance calculation;
[0053] Figure 6 is a schematic diagram of the dot matrix code to be processed;
[0054] Figure 7 It is a matrix diagram;
[0055] Figure 8 This is a schematic diagram of the positioning module;
[0056] Figure 9 This is a schematic diagram of the dot matrix code position. DETAILED DESCRIPTION
[0057] The present invention will be described in more detail below with reference to the embodiments.
[0058] Example 1
[0059] like Figure 1 As shown, a dot matrix code positioning method includes the following steps:
[0060] S1, obtaining an image to be processed containing a dot matrix code;
[0061] S2, determining the first scan line;
[0062] S3, searching and confirming a first data point along a first scan line in the image to be processed;
[0063] S4, searching and confirming the remaining data points;
[0064] The remaining data points are determined according to the LBP features of the first data point, specifically:
[0065] Calculate the LBP feature of the first data point: take the centroid of the first data point as the center and the radius of the first data point as the neighborhood radius; take multiple pixels within the neighborhood radius and compare them with the center pixel in turn. If the grayscale value of the current pixel is greater than the grayscale value of the center pixel, it is recorded as 1; otherwise, it is recorded as 0. Finally, a binary string is obtained, which is recorded as the LBP feature L1 of the first data point;
[0066] Similarly, calculate the LBP features of the remaining data points: take a certain pixel as the center and the radius of the first data point as the neighborhood radius; take multiple pixels within the neighborhood radius and compare them with the center pixel in turn. If the grayscale value of the current pixel is greater than the grayscale value of the center pixel, it is recorded as 1; otherwise, it is recorded as 0; finally, a binary string is obtained, which is recorded as the LBP feature L2 of the remaining data points;
[0067] Calculate the similarity between LBP feature L1 and LBP feature L2, expressed as:
[0068] D=count(XOR(L1,L2))
[0069] Where XOR represents the exclusive OR operation; count is the number of 1s in the result of the exclusive OR operation; and D is the Hamming distance.
[0070] If the Hamming distance value is greater than the similarity threshold, it is confirmed that there is a data point at the pixel point, and the pixel point is considered to be the centroid of the data point; otherwise, it is confirmed that there is no data point at the pixel point.
[0071] The beneficial effect of this embodiment is that the data points are determined according to the LBP features, which greatly reduces the amount of calculation required to determine the data points, thereby improving the dot matrix code reading rate.
[0072] Example 2
[0073] See also Figures 2 to 5 , a dot matrix code recognition method comprises the following steps:
[0074] S1. Obtain an image to be processed and convert it into a single-channel grayscale image G. The number of pixels of the width of the grayscale image G is W, and the number of pixels of the height is H.
[0075] S2. Determine a first scanning line, where the first scanning line is located at H / 2 of the grayscale image G (of course, it can also be located at W / 2).
[0076] S3. Search and confirm the first data point:
[0077] S31. Searching for the first data point:
[0078] Along the first scan line, search for adjacent pixels whose pixel difference exceeds the threshold. If a pixel's value is smaller than the next pixel and the absolute value of the pixel difference exceeds the threshold, record that pixel as point C1. If a pixel's value is larger than the next pixel and the absolute value of the pixel difference exceeds the threshold, record that pixel as point C2. Points C1 and C2 form a paired boundary.
[0079] The distance between the paired boundaries (point C1 and point C2) is calculated. If the distance is greater than a threshold, the search for the first data point ends; otherwise, the search for the paired boundaries with a distance greater than the threshold is continued along the first scan line.
[0080] See also Figure 2 If no paired boundaries with a spacing greater than the threshold are found on the first scan line, a binary search is performed to determine the second scan line. The search for the first data point continues along the second scan line, which is located at position H / 4 of the grayscale image G. If the first data point is still not found on the second scan line, the search continues along the third scan line (at 3H / 4), the fourth scan line (at H / 8), the fifth scan line (at 3H / 8), and so on. Using the binary search method to determine the scan line position effectively improves the speed of finding the first data point and quickly determines whether a dot matrix code exists in the image to be processed.
[0081] S32. Confirm the first data point:
[0082] See also Figure 3 Assume that the midpoint of the found pair of boundaries with a spacing greater than the threshold is (L, C). Multiple scan lines passing through (L, C) are used to search for other pairs of boundaries with a spacing greater than the threshold. If at least one other pair of boundaries exists, the first data point is confirmed to exist at (L, C), and the coordinates (L, C) are the centroid of the first data point. Multiple confirmations of data point widths in multiple directions improve the accuracy of data point judgment and reduce the probability of misjudgment.
[0083] S4. Search and confirm the remaining data points:
[0084] S41. Calculate the LBP feature of the first data point:
[0085] like Figure 4 As shown, with the coordinate (L, C) as the center and W as the neighborhood radius, the 8 pixels within the neighborhood radius W are taken, starting from the upper left corner and moving clockwise, and the grayscale values are compared with the pixel at the coordinate (L, C) to obtain the LBP feature of the first data point 11011110;
[0086] S42, scanning pixel by pixel in L rows, and calculating LBP features at each pixel;
[0087] S43, such as Figure 5 As shown, the Hamming distance between the LBP feature of the first data point and the LBP feature at each pixel point is calculated. If the distance is less than or equal to the similarity threshold (the threshold is set to 1 in this embodiment), it means that there is a data point at the pixel point, and the pixel point is the center of the data point.
[0088] Example 3
[0089] Furthermore, after a certain number of data points are confirmed, the minimum spacing between the data points is calculated based on the confirmed data points. Instead of calculating the LBP features at each pixel, the minimum spacing is used as the step size and the LBP features are calculated every step, thus further reducing the amount of calculation required to confirm the data points.
[0090] Example 4
[0091] For Figure 6 The image shown contains multiple dot matrix codes. The dot matrix codes in the image are difficult to distinguish, which may lead to dot matrix code reading failure.
[0092] This embodiment sets up a matrix, and fills the confirmed data points into the matrix according to the relative position relationship, such as Figure 7 As shown. In the dot matrix code, there is a positioning module with a specific position relationship, such as Figure 8 The five data points with consistent spacing and in the same straight line direction constitute a positioning module.
[0093] Accordingly, if Figure 9 As shown, find 5 consecutive characters 1 in the straight line direction in the matrix to obtain two positioning modules. According to the position of the positioning module, the position of the dot matrix code is determined, that is, Figure 9 Select a rectangular area in the middle box.
[0094] Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
Claims
1. A dot code positioning method, characterized in that: The following steps are involved: Get the image to be processed; determining a first scan line; Searching for and confirming a first data point along a first scan line in the image to be processed; Continue searching and identifying the remaining data points; The remaining data points are determined based on the local binary features of the first data point, specifically: The similarity between the local binary features of the first data point and the local binary features of the remaining data points is calculated, and if the similarity is greater than a similarity threshold, the remaining data points are confirmed.
2. A dot matrix code positioning method according to claim 1, characterized in that: Also includes: If the first data point cannot be confirmed along the first scan line, a second scan line is determined by a binary search method, and the first data point is searched and confirmed along the second scan line.
3. A dot matrix code positioning method according to claim 1, characterized in that: The step of searching for the first data point is specifically as follows: Paired boundaries with a spacing greater than a spacing threshold are searched along the first scan line, where the paired boundaries are boundary points with opposite pixel value change trends.
4. A dot matrix code positioning method according to claim 3, characterized in that: The step of confirming the first data point is specifically as follows: Other pairs of boundaries with a spacing greater than a spacing threshold are searched along multiple scan lines passing through the midpoints of the paired boundaries. If at least one other pair of boundaries with a spacing greater than the spacing threshold is found, the first data point is confirmed.
5. A dot matrix code positioning method according to claim 1, characterized in that: Also includes: Based on the confirmed data points, calculate the minimum distance between data points; Use the minimum spacing as the step size and search for the remaining data points according to the step size.
6. A dot matrix code positioning method according to claim 1, characterized in that: Also includes: Generate a matrix based on the relative position relationship of the confirmed data points; A positioning module is searched in the matrix, where the positioning module includes a plurality of data points having a specific positional relationship.
7. A dot matrix code positioning method according to claim 6, characterized in that: Also includes: The position of the dot matrix code is determined according to the position of the positioning module.
8. A dot matrix code positioning device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores instructions, and the instructions are suitable for being loaded by the processor and executing the following steps: Get the image to be processed; determining a first scan line; Searching for and confirming a first data point along a first scan line in the image to be processed; Continue searching and identifying the remaining data points; The remaining data points are determined based on the local binary features of the first data point, specifically: Calculate the similarity between the local binary features of the first data point and the local binary features of the remaining data points. If the similarity is greater than a similarity threshold, confirm the remaining data.
Citation Information
Patent Citations
Lattice code positioning method and system
CN110245538A
Lattice code detection method and system
CN110276226A
Method and system for quickly positioning Dotcode
CN113158704A