Two-dimensional code positioning method and system based on grid jump degree and readable storage medium

Through the positioning method based on grid jumping, and using technologies such as pyramid downsampling and Laplace transformation, the existing QR code identification library is solved, and efficient QR code recognition in complex environments is achieved, which is suitable for industrial production.

CN120387466AActive Publication Date: 2025-07-29HANGZHOU HUICUI INTELLIGENT TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510872789.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-07-29
Estimated Expiration
2045-06-27

AI Technical Summary

Technical Problem

The existing QR code recognition library has a slow decoding speed and a low decoding success rate in complex environments, making it difficult to be compatible with various types of QR codes, especially in industrial production where dust and dirt are severely interfered with.

Method used

The positioning method based on the grid jumping degree is adopted, and through pyramid downsampling, grid scanning, Laplace transformation and closed operations, combined with jumping degree evaluation and preset discrimination rules, the QR code area is quickly positioned and corrected and adjusted to prevent repeated decoding.

Benefits of technology

It realizes efficient and stable QR code recognition in complex environments, is compatible with multiple types of QR codes, improves decoding speed and success rate, avoids repeated decoding, and adapts to industrial production needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120387466A_ABST
    Figure CN120387466A_ABST
Patent Text Reader

Abstract

The invention discloses a two-dimensional code positioning method and system based on a grid jump degree and a readable storage medium. The method comprises the steps of obtaining a to-be-recognized two-dimensional code image, and performing sampling to obtain a grid image; traversing the gridding image to calculate rank jump degree scores, and sorting the jump degree scores; mapping the coordinate of the target point corresponding to the score with the highest jump degree into the two-dimensional code binary image to perform cross retrieval of a two-dimensional code connected domain; the retrieved minimum bounding box of the connected domain is judged, and if yes, coordinates of the minimum bounding box of the connected domain are mapped to the two-dimensional code image to obtain a two-dimensional code area; after the two-dimensional code area is corrected and adjusted, decoding is conducted to complete two-dimensional code positioning, and decoding is stopped when decoding succeeds and the number of the two-dimensional codes obtained through decoding meets the preset number. Through innovative jump degree evaluation and grid priority positioning, the problems of low speed and poor universality in the prior art are solved, and efficient and stable two-dimensional code recognition is realized in a complex environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and more specifically, to a two-dimensional code positioning method, system, and readable storage medium based on grid jump degree. Background Art

[0002] Two-dimensional codes are a very popular coding method. Due to their large storage capacity, strong error tolerance, high security, etc., they have a very wide range of application scenarios.

[0003] The existing two-dimensional code recognition libraries have a slow decoding speed and a low decoding success rate in severe interference situations. In industrial production, interference such as dust and dirt will further reduce the decoding efficiency and success rate.

[0004] Currently, the two-dimensional code positioning on the market has the following disadvantages: 1. The positioning method based on deep learning requires a large amount of labeled data for training, with high maintenance costs and a slow positioning speed, making it difficult to meet the requirements of high-speed recognition scenarios. 2. The positioning method based on the two-dimensional code form, that is, different positioning logics need to be designed for different types of two-dimensional codes (such as DM codes, QR codes), lacking generality. Especially when the image is large, the positioning speed drops significantly and may even be unusable. In summary, there is currently no publicly available positioning method that can simultaneously meet the requirements of fast speed and compatibility with multiple types of two-dimensional codes. Summary of the Invention

[0005] The purpose of the present invention is to provide a two-dimensional code positioning method, system, and readable storage medium based on grid jump degree to solve the above-mentioned disadvantages of the prior art.

[0006] The first aspect of the present invention provides a two-dimensional code positioning method based on grid jump degree, including the following steps: Obtain the two-dimensional code image to be recognized and sample it to obtain a grid image; Traverse the grid image to calculate the row and column jump degree scores, and sort the jump degree scores according to a preset sorting; Obtain the binary image of the two-dimensional code image, and map the target point coordinates corresponding to the highest jump degree score to the binary image for cross retrieval of the two-dimensional code connected domain; Judge the minimum bounding box of the retrieved connected domain based on a preset discrimination rule. If satisfied, map the coordinates of the minimum bounding box of the connected domain to the two-dimensional code image to obtain the two-dimensional code area; Perform correction adjustment on the two-dimensional code area and then decode to complete two-dimensional code positioning. Among them, stop decoding when the decoding is successful and the number of decoded two-dimensional codes meets a preset number.

[0007] In this solution, obtaining the to-be-recognized QR code image and sampling it to obtain a grid image specifically includes: Performing pyramid downsampling on the obtained QR code image and then performing grid scanning, where Scanning the entire QR code image based on a set grid window to obtain the grid image.

[0008] In this solution, traversing the grid image to calculate the row and column jump degree scores and sorting the jump degree scores according to a preset sorting specifically includes: Calculating the jump degree scores of each row and each column for each block of the grid image by row and column scanning; The calculation formula for the jump degree score is as follows: ; Where is the jump degree score, M is the pixel mean, n is the total number of pixels, is the number of pixels in the first high-frequency interval greater than the pixel mean, c is the number of pixels in the second high-frequency interval greater than the pixel mean, b is the number of pixels in the low-frequency interval less than the pixel mean, is the pixel serial number, is the pixel value; Arranging the jump degree scores of the grid image in the order of the preset sorting, where the preset sorting includes from high to low.

[0009] In this solution, obtaining the binary image of the QR code image and mapping the target point coordinates corresponding to the highest jump degree score into the binary image for cross retrieval of the QR code connected domain specifically includes: Obtaining the binary image of the QR code image, which includes performing Laplace transform on the QR code image, performing closing operation on the Laplace image, and then performing threshold segmentation; Mapping the target point coordinates into the binary image and performing cross retrieval of the QR code connected domain, where during cross retrieval, expansion is performed in a preset order until the pixel value is the eigenvalue and then the retrieval stops, and the coordinates of the point corresponding to the eigenvalue are recorded as the feature coordinates; Extracting the white area connected to the feature coordinates in the binary image to obtain the QR code connected area.

[0010] In this solution, based on a preset discrimination rule, judging the minimum bounding box of the retrieved connected domain. If it is satisfied, mapping the coordinates of the minimum bounding box of the connected domain into the QR code image to obtain the QR code area, specifically includes: Extracting the minimum bounding box of the connected domain based on the QR code connected area and performing discrimination based on a preset rule. The preset rule includes: the width of the minimum bounding box is greater than , the minimum bounding box width is less than , the aspect ratio of the minimum bounding box is less than , where ; ; ; where min_w is the minimum QR code width, max_w is the maximum QR code width, min_aspect_ratio is the minimum aspect ratio of the QR code, and PyramidLayer is the number of pyramid downsampling layers; Map the coordinates of the minimum bounding box of the connected component to the QR code image to perform region extraction to obtain the QR code region.

[0011] In this solution, after correcting and adjusting the QR code region, decoding is performed to complete QR code positioning, which specifically includes: Perform perspective transformation correction and contrast enhancement adjustment on the QR code region and then perform decoding, where the minimum bounding box region that has participated in decoding will not be decoded repeatedly; Extract the preset number of decodings, and stop decoding when the decoding is successful and the number of decoded QR codes meets the number of decodings, thereby completing the positioning and recognition operation of the QR code.

[0012] The second aspect of the present invention also provides a QR code positioning system based on grid jump degree, including a memory and a processor. The memory includes a QR code positioning method program based on grid jump degree. When the QR code positioning method program based on grid jump degree is executed by the processor, the following steps are implemented: Obtain the QR code image to be recognized and sample it to obtain a grid image; Traverse the grid image to calculate the row and column jump degree scores, and sort the jump degree scores according to a preset sorting; Obtain the binary image of the QR code image, and map the coordinates of the target point corresponding to the highest jump degree score to the binary image to perform a cross search for the QR code connected component; Judge the minimum bounding box of the connected component retrieved based on a preset discrimination rule. If it is satisfied, map the coordinates of the minimum bounding box of the connected component to the QR code image to obtain the QR code region; Perform correction and adjustment on the QR code region and then perform decoding to complete QR code positioning, where decoding stops when the decoding is successful and the number of decoded QR codes meets the preset number.

[0013] In this solution, the step of obtaining the QR code image to be recognized and sampling it to obtain a grid image specifically includes: Perform pyramid downsampling on the obtained QR code image and then perform grid scanning, where, Perform full-image scanning on the QR code image based on a set grid window to obtain the grid image.

[0014] In this solution, traverse the grid image to calculate the row and column jump degree scores, and sort the jump degree scores according to a preset sorting. Specifically, it includes: For each block of the grid image, calculate the jump degree scores of each row and each column according to row and column scanning; The calculation formula for the jump degree score is as follows: ; Where, is the jump degree score, M is the pixel mean value, n is the total number of pixels, is the number of pixels in the first high-frequency interval greater than the pixel mean value, c is the number of pixels in the second high-frequency interval greater than the pixel mean value, b is the number of pixels in the low-frequency interval less than the pixel mean value, is the pixel serial number, is the pixel value; Arrange the jump degree scores of the grid image in the order of the preset sorting. Among them, the preset sorting includes from high to low.

[0015] In this solution, obtain the binary image of the QR code image, and map the target point coordinates corresponding to the highest jump degree score into the binary image for cross retrieval of the QR code connected domain. Specifically, it includes: Obtain the binary image of the QR code image, which includes performing Laplace transform on the QR code image, performing closing operation on the Laplace image, and then performing threshold segmentation; Map the target point coordinates into the binary image, and perform cross retrieval of the QR code connected domain. Among them, during cross retrieval, expand in a preset order until the pixel value is the eigenvalue and then stop the retrieval, and record the coordinates of the point corresponding to the eigenvalue as the feature coordinates; Extract the white area connected to the feature coordinates in the binary image to obtain the QR code connected area.

[0016] In this solution, based on a preset discrimination rule, judge the minimum bounding box of the retrieved connected domain. If it is satisfied, map the coordinates of the minimum bounding box of the connected domain into the QR code image to obtain the QR code area. Specifically, it includes: Extract the minimum bounding box of the connected domain based on the QR code connected area, and perform discrimination based on a preset rule. The preset rule includes: the width of the minimum bounding box is greater than , the width of the minimum bounding box is less than , and the aspect ratio of the length and width of the minimum bounding box is less than , where ; ; ; where min_w is the minimum QR code width, max_w is the maximum QR code width, min_aspect_ratio is the minimum QR code aspect ratio, and PyramidLayer is the number of pyramid downsampling layers; Map the coordinates of the minimum bounding box of the connected component to the QR code image to intercept the region to obtain the QR code region.

[0017] In this solution, after correcting and adjusting the QR code region, decoding is performed to complete QR code positioning, which specifically includes: Perform perspective transformation correction and contrast enhancement adjustment on the QR code region and then perform decoding, where the minimum bounding box region that has participated in decoding will not be decoded repeatedly; Extract the preset number of decodings, and stop decoding when the decoding is successful and the number of decoded QR codes meets the number of decodings, thereby completing the positioning and recognition operation of the QR code.

[0018] The third aspect of the present invention provides a computer-readable storage medium, which includes a program for a QR code positioning method based on grid jump degree of a machine. When the program for the QR code positioning method based on grid jump degree is executed by a processor, the steps of a QR code positioning method based on grid jump degree as described in any one of the above are implemented.

[0019] A QR code positioning method, system, and readable storage medium disclosed by the present invention solve the problems of slow speed and poor versatility in the prior art through innovative jump degree evaluation and grid priority positioning, and achieve efficient and stable QR code recognition in complex environments. The specific beneficial effects are as follows: 1. Strong compatibility, where all types of QR codes are compatible through the "jump degree evaluation method" and "grid jump degree priority positioning"; 2. Fast speed, grid scanning and priority sorting significantly reduce invalid calculations, improve the positioning speed, and further accelerate the processing using pyramid downsampling; 3. High robustness, using Laplace transform and closing operation to enhance high-frequency features, reduce noise interference, and cross retrieval and morphological discrimination ensure accurate positioning, adapting to complex environments (such as dirt and dust); 4. Avoid repeated decoding, that is, the region suppression mechanism prevents the same QR code from being processed multiple times, improving efficiency. Description of the Drawings

[0020] Figure 1Shows the step diagram of a QR code positioning method based on grid jump degree of the present invention; Figure 2 Shows the flowchart of a QR code positioning method based on grid jump degree of the present invention; Figure 3 Shows the QR code image to be recognized in a QR code positioning method based on grid jump degree of the present invention; Figure 4 Shows the schematic diagram of grid scanning in a QR code positioning method based on grid jump degree of the present invention; Figure 5 Shows the grid pixel area diagram of a QR code positioning method based on grid jump degree of the present invention; Figure 6 Shows the schematic diagram of the gray value change curve in a QR code positioning method based on grid jump degree of the present invention; Figure 7 Shows the schematic diagram of the maximum row and column jump degree in a QR code positioning method based on grid jump degree of the present invention; Figure 8 Shows the schematic diagram of the Laplace transform in a QR code positioning method based on grid jump degree of the present invention; Figure 9 Shows the Laplace diagram after the closing operation in a QR code positioning method based on grid jump degree of the present invention; Figure 10 Shows the binary diagram in a QR code positioning method based on grid jump degree of the present invention; Figure 11 Shows the schematic diagram of cross retrieval in a QR code positioning method based on grid jump degree of the present invention; Figure 12 Shows the schematic diagram of the minimum bounding box in a QR code positioning method based on grid jump degree of the present invention; Figure 13 Shows the corrected QR code image in a QR code positioning method based on grid jump degree of the present invention; Figure 14 Shows the QR code image with enhanced contrast in a QR code positioning method based on grid jump degree of the present invention; Figure 15 Shows the minimum bounding box area that has participated in decoding in a QR code positioning method based on grid jump degree of the present invention; Figure 16 Shows the schematic diagram of the decoding result in a QR code positioning method based on grid jump degree of the present invention; Figure 17 Shows the block diagram of a QR code positioning system based on grid jump degree of the present invention. Detailed implementation manner

[0021] In order to more clearly understand the above-mentioned objects, features, and advantages of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments may be combined with each other.

[0022] In the following description, many specific details are set forth in order to fully understand the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited by the specific embodiments disclosed below.

[0023] At present, there are many open-source QR code recognition libraries on the market, such as zbar, zxing, etc., but their decoding speeds are relatively slow, and in the case of severe interference, the decoding success rate is also relatively low. Especially in the field of industrial production, the decoding speed and decoding success rate directly affect production efficiency, and there may be a lot of dust and dirt interfering with the appearance of the QR code. Then these open-source libraries are relatively not so applicable.

[0024] The decoding logic of QR codes is a set of standard methods internationally. The core of all recognition methods lies in the acquisition and processing of QR code data before decoding. Therefore, it is very important to accurately and stably locate the position of the QR code. There are two main methods for locating QR codes, the positioning method based on deep learning and the positioning method based on the morphology of QR codes.

[0025] For the positioning method based on deep learning, it is necessary to pre-collect a large number of QR code pictures for corner point annotation, and for the QR code pictures with positioning failures, it is necessary to repeatedly iterate and train. Without a large number of high-quality data sets, the maintainability will be relatively low. At the same time, the positioning method based on deep learning is usually relatively slow in positioning speed, and some scenarios that require high-speed recognition are not very applicable.

[0026] At present, the vast majority of open-source libraries on the market are based on the positioning method designed according to the morphology of QR codes. Different positioning methods are designed for different types of QR code morphologies. For example, the edge of the DM (Data Matrix) code is composed of L-shaped and virtual line segments. To locate the DM code, it is usually necessary to rely on the characteristics of the L-shaped and virtual line segments; another example is that there are square-within-square features at the three corners of the QR (Quick Response) code. To locate the QR code, it usually relies on the square-within-square features. The positioning based on morphology is diverse, but it cannot be universal for all types of QR codes, and the existing open-source libraries on the market are relatively slow in positioning speed, especially in the case of particularly large images, these open-source libraries are basically unusable.

[0027] At present, there is no publicly available positioning method that is fast in positioning speed and can be compatible with various types of two-dimensional codes. However, the present application provides a general two-dimensional code positioning mechanism, which has the characteristics of strong compatibility, fast speed, and high robustness.

[0028] Specifically, Figure 1 The flowchart of a two-dimensional code positioning method based on grid jump degree in the present application is shown.

[0029] As Figure 1 shown, the present application discloses a two-dimensional code positioning method based on grid jump degree, including the following steps: S102, obtaining the two-dimensional code image to be recognized and sampling it to obtain a grid image; S104, traversing the grid image to calculate the row and column jump degree scores, and sorting the jump degree scores according to a preset sorting; S106, obtaining the binary image of the two-dimensional code image, and mapping the target point coordinates corresponding to the highest jump degree score to the binary image for cross retrieval of the two-dimensional code connected domain; S108, judging the minimum bounding box of the connected domain retrieved based on a preset discrimination rule, and if it is satisfied, mapping the coordinates of the minimum bounding box of the connected domain to the two-dimensional code image to obtain the two-dimensional code area; S110, performing correction adjustment on the two-dimensional code area and then decoding to complete two-dimensional code positioning. Among them, decoding stops when the decoding is successful and the number of two-dimensional codes decoded meets a preset number.

[0030] It should be noted that in this embodiment, as Figure 2 shown, it is a schematic flowchart of a two-dimensional code positioning method based on grid jump degree. Among them, when positioning and recognizing a two-dimensional code, it specifically includes four steps: image preprocessing, grid scanning and jump degree calculation, two-dimensional code precise positioning, and decoding optimization. Among them, in image preprocessing, first obtain the two-dimensional code image to be recognized and sample it to obtain a grid image. Specifically, the image size can be reduced by pyramid downsampling to accelerate processing; further, when performing grid scanning and jump degree calculation, calculate the row and column jump degree scores by traversing the grid image, and sort the jump degree scores according to a preset sorting. At the same time, obtain the binary image of the two-dimensional code image, so as to map the target point coordinates corresponding to the highest jump degree score to the binary image for cross retrieval of the two-dimensional code connected domain to obtain the two-dimensional code connected area.

[0031] Further, for precise QR code positioning, the minimum bounding box of the connected component is extracted, and the minimum bounding box of the retrieved connected component is judged based on a preset discrimination rule. When the preset rule is satisfied, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area. Finally, decoding optimization is performed, that is, the QR code area is corrected and adjusted and then decoded to complete QR code positioning. Among them, decoding stops when the decoding is successful and the number of decoded QR codes meets the preset number. For the decoded area, suppression optimization is performed to prevent repeated processing.

[0032] According to an embodiment of the present invention, the obtaining the to-be-recognized QR code image and sampling it to obtain a grid image specifically includes: Performing pyramid downsampling on the obtained QR code image and then performing grid scanning, where Based on a set grid window, the entire QR code image is scanned to obtain the grid image.

[0033] It should be noted that in this embodiment, as Figure 3 shown, the displayed QR code image to be recognized is specifically subjected to pyramid downsampling to reduce the size to accelerate the operation and perform grid scanning. Among them, as Figure 4 shown, the grid scanning schematic diagram is shown, where step is the window sliding step length when calculating the jump degree, and the corresponding rectangular box is the window for calculating the jump degree. The window calculates the jump degree once every time it slides one step on the image. Specifically, through the set grid window with a step length of 1 / 2 of the grid size, the entire image is scanned. And in actual application, the grid window size is preferably adapted to the QR code size without too much deviation. Among them, the QR code has been "coded" to avoid being scanned.

[0034] According to an embodiment of the present invention, the traversing the grid image to calculate the row and column jump degree scores and sorting the jump degree scores according to a preset sorting specifically includes: Calculating the jump degree scores of each row and each column for each block of the grid image by row and column scanning; The calculation formula for the jump degree score is as follows: ; Among them, is the jump degree score, M is the pixel mean value, n is the total number of pixels, is the number of pixels in the first high-frequency interval greater than the pixel mean value, c is the number of pixels in the second high-frequency interval greater than the pixel mean value, b is the number of pixels in the low-frequency interval less than the pixel mean value, is the pixel serial number, is the pixel value; Arrange the jump degree scores of the grid images in the order of a preset sorting, where the preset sorting includes from high to low.

[0035] It should be noted that in this embodiment, each grid image is evaluated, scanned row by row and column by column, the jump degree scores are calculated for each row and each column, and the sum of the scores is used as the score of the grid. The jump degree score calculation is to first calculate the pixel mean value M of the image within the grid, traverse the pixels for each row or each column, those greater than the pixel mean value M are called "high frequency", and those less than the pixel mean value M are called "low frequency". As Figure 5 shown, it is displayed as a grid pixel area map, as Figure 6 shown, it is displayed as a schematic diagram of the corresponding gray value change curve. Specifically, for Figure 5 the grid area map shown, calculate the jump degree score according to the pixel values in the high and low frequency intervals: ; where the total number of pixels n is "19", the number of pixels in the first high frequency interval greater than the pixel mean value is "6", the number of pixels in the second high frequency interval greater than the pixel mean value c is "5", and the number of pixels in the low frequency interval less than the pixel mean value b is "8". Among them, in order to suppress noise interference, the number of pixels in each interval is at least 3, otherwise it is not included in the score calculation.

[0036] Furthermore, record the row x and column y with the largest jump degree in each grid to obtain the point P(x, y) with the largest jump degree in each grid. Specifically, as Figure 7 shown, it is displayed as a schematic diagram of the largest row and column jump degrees. Among them, through a large amount of data verification, if the grid image is part of the QR code, the point with the largest jump degree must be in the internal area of the QR code. Therefore, all grids can be sorted according to the jump degree scores from high to low. The reason for using the preset sorting from high to low in this embodiment is that the position with a high score is more likely to be the QR code, and decoding will be performed preferentially, and the QR code can be found and recognized faster.

[0037] According to the embodiment of the present invention, obtaining the binary image of the QR code image and mapping the target point coordinates corresponding to the highest jump degree score into the binary image for cross-search of the QR code connected domain specifically includes: Obtain the binary image of the QR code image, which includes performing a Laplace transform on the QR code image, performing a closing operation on the Laplace image, and then performing threshold segmentation; Map the target point coordinates into the binary image, and perform cross-search of the QR code connected domain. Among them, during the cross-search, it is extended in a preset order until the search stops when the pixel value is the eigenvalue, and record the coordinates of the point corresponding to the eigenvalue as the eigen-coordinates; In the binary image, a white area connected to the feature coordinates is extracted to obtain a QR code connected area.

[0038] It should be noted that in this embodiment, as Figure 8 shown, it is a schematic diagram of Laplace transform. Among them, the QR code image is subjected to Laplace transform, and then the Laplace image is subjected to closing operation and then threshold segmentation. Among them, the kernel size of the closing operation is automatically calculated according to the grid size, and the calculation formula is: ; Among them, GridSize is the pre-set grid window size, and PyramidLayer is the number of pyramid downsampling layers. As Figure 9 shown, it is the Laplace graph after the closing operation. Furthermore, Figure 9 the image shown is subjected to threshold segmentation to obtain a binary image. Among them, the pixel value of the white area of the binary image is "255", and the pixel value of the black area is "0". The finally obtained binary image is as Figure 10 shown.

[0039] Furthermore, traverse the sorted grid set according to the jump degree score, take the point with the largest jump degree in the grid (i.e., the P point) as the target point, map the target point coordinates to the binary image, and retrieve the QR code connected domain crosswise. The retrieval range shall not exceed the size of the currently traversed grid.

[0040] Among them, as Figure 11 shown, it is a schematic diagram of crosswise retrieval. Among them, Figure 11 the "0 point" in is the P point. The overall retrieval direction expands crosswise with the P point as the center. First, retrieve the adjacent cross-region pixels, and then expand outward in order until the point with the pixel value of "255" is retrieved and the retrieval stops. Record the coordinates S(x, y) of this feature point, and extract the white area connected to the feature point S on the binary image, which is the required QR code connected domain.

[0041] According to the embodiment of the present invention, the minimum bounding box of the retrieved connected domain is judged based on the preset discrimination rule. If it is satisfied, the coordinates of the minimum bounding box of the connected domain are mapped to the QR code image to obtain the QR code area, which specifically includes: Based on the QR code connected area, the minimum bounding box of the connected domain is extracted and discriminated based on the preset rule. The preset rule includes: the width of the minimum bounding box is greater than , the width of the minimum bounding box is less than , the aspect ratio of the length and width of the minimum bounding box is less than , where ; ; ; where min_w is the minimum QR code width, max_w is the maximum QR code width, min_aspect_ratio is the minimum QR code aspect ratio, and PyramidLayer is the number of pyramid downsampling layers; Map the coordinates of the minimum bounding box of the connected region to the QR code image to intercept the region to obtain the QR code region.

[0042] It should be noted that in this embodiment, the minimum bounding box of the connected region is extracted based on the QR code connected region, as Figure 12 shown, which is shown as a schematic diagram of the minimum bounding box. Among them, discrimination is performed based on a preset rule, and the preset rule includes: the width of the minimum bounding box is greater than , the width of the minimum bounding box is less than , and the aspect ratio of the minimum bounding box is less than . Specifically: ; ; ; where min_w is the minimum QR code width, max_w is the maximum QR code width, min_aspect_ratio is the minimum QR code aspect ratio, PyramidLayer is the number of pyramid downsampling layers, and then the coordinates of the minimum bounding box of the connected region are mapped to the QR code image to intercept the region to obtain the QR code region.

[0043] According to an embodiment of the present invention, after the correction adjustment of the QR code region, decoding is performed to complete the QR code positioning, which specifically includes: Perform perspective transformation correction and contrast enhancement adjustment on the QR code region and then perform decoding, where the minimum bounding box region that has participated in decoding will not be decoded repeatedly; Extract the preset number of decodings, and stop decoding when the decoding is successful and the number of decoded QR codes meets the number of decodings, thereby completing the positioning and recognition operation of the QR code.

[0044] It should be noted that in this embodiment, perspective transformation correction is performed on the QR code region, as Figure 13 shown, which is shown as the corrected QR code image, and contrast enhancement adjustment, as Figure 14 shown, which is shown as the QR code image after contrast enhancement. After the correction adjustment of the QR code region, decoding is performed, where, as Figure 15As shown, the smallest bounding box area that has participated in decoding will be subjected to area suppression on the binary image to prevent the area from being retrieved again next time, ensuring that there is no repeated decoding. Finally, the preset number of decodings is extracted, and decoding stops when the decoding is successful and the number of two-dimensional codes obtained by decoding meets the number of decodings, thus completing the positioning and recognition operation of the two-dimensional code, as Figure 16 shown, which is displayed as a schematic diagram of the final decoding result.

[0045] Figure 17 shows a block diagram of a two-dimensional code positioning system based on grid jump degree according to the present invention.

[0046] As Figure 17 shown, the present invention discloses a two-dimensional code positioning system based on grid jump degree, including a memory and a processor. The memory includes a two-dimensional code positioning method program based on grid jump degree. When the two-dimensional code positioning method program based on grid jump degree is executed by the processor, the following steps are implemented: Obtain the two-dimensional code image to be recognized and sample it to obtain a grid image; Traverse the grid image to calculate the row and column jump degree scores, and sort the jump degree scores according to a preset sorting; Obtain the binary image of the two-dimensional code image, and map the target point coordinates corresponding to the highest jump degree score to the binary image for cross retrieval of the two-dimensional code connected domain; Judge the smallest bounding box of the retrieved connected domain based on a preset discrimination rule. If it is satisfied, map the coordinates of the smallest bounding box of the connected domain to the two-dimensional code image to obtain the two-dimensional code area; Perform correction and adjustment on the two-dimensional code area and then perform decoding to complete the two-dimensional code positioning. Among them, decoding stops when the decoding is successful and the number of two-dimensional codes obtained by decoding meets the preset number.

[0047] It should be noted that the technical solutions and detailed implementation manners in this embodiment are consistent with those of the embodiment of the two-dimensional code positioning method based on grid jump degree above, and will not be elaborated here.

[0048] The third aspect of the present invention provides a computer-readable storage medium, which includes a two-dimensional code positioning method program based on grid jump degree. When the two-dimensional code positioning method program based on grid jump degree is executed by a processor, the steps of a two-dimensional code positioning method based on grid jump degree as described in any one of the above are implemented.

[0049] A two-dimensional code positioning method, system and readable storage medium disclosed by the present invention solve the problems of slow speed and poor versatility in the prior art through innovative jump degree evaluation and grid priority positioning, and realize efficient and stable two-dimensional code recognition in complex environments.

[0050] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed with each other can be through some interfaces. The indirect coupling or communication connection of devices or units can be electrical, mechanical, or other forms.

[0051] The units described above as separate components may or may not be physically separated. The components shown as units may or may not be physical units; they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0052] In addition, each functional unit in the embodiments of the present invention can be all integrated in a processing unit, or each unit can be separately used as a unit, or two or more units can be integrated in a unit; the above integrated unit can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.

[0053] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes: removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks and other various media that can store program codes.

[0054] Alternatively, if the above integrated unit of the present invention is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present invention. And the foregoing storage medium includes: removable storage devices, ROM, RAM, magnetic disks, or optical disks and other various media that can store program codes.

Claims

1. A QR code positioning method based on grid jump degree, characterized in that It includes the following steps: Obtain the QR code image to be recognized and sample it to obtain a grid image; Traverse the grid image to calculate the row and column jump degree scores, and sort the jump degree scores according to a preset sorting; Obtain the binary image of the QR code image, and map the target point coordinates corresponding to the highest jump degree score to the binary image to perform a cross search for the QR code connected region; Judge the minimum bounding box of the connected region retrieved based on a preset discrimination rule. If it is satisfied, map the coordinates of the minimum bounding box of the connected region to the QR code image to obtain the QR code region; Perform correction adjustment on the QR code region and then decode it to complete QR code positioning. Among them, stop decoding when the decoding is successful and the number of decoded QR codes meets the preset number.

2. The method for positioning a two-dimensional code based on grid jump degree according to claim 1, characterized in that The obtaining the QR code image to be recognized and sampling it to obtain a grid image specifically includes: Perform pyramid downsampling on the obtained QR code image and then perform grid scanning, where Perform full-image scanning on the QR code image based on a set grid window to obtain the grid image.

3. The method for positioning a two-dimensional code based on grid jump degree according to claim 2, wherein The traversing the grid image to calculate the row and column jump degree scores and sorting the jump degree scores according to a preset sorting specifically includes: For each block of the grid image, calculate the jump degree scores of each row and each column according to row and column scanning; The calculation formula of the jump degree score is as follows: ; Among them, is the jump degree score, M is the pixel mean value, n is the total number of pixels, is the number of pixels in the first high-frequency interval greater than the pixel mean value, c is the number of pixels in the second high-frequency interval greater than the pixel mean value, b is the number of pixels in the low-frequency interval less than the pixel mean value, is the pixel serial number, is the pixel value; Arrange the jump degree scores of the grid image in the order of the preset sorting, where the preset sorting includes from high to low.

4. A QR code positioning method based on grid jump degree according to claim 3, characterized in that, The obtaining the binary image of the QR code image and mapping the target point coordinates corresponding to the highest jump degree score to the binary image to perform a cross search for the QR code connected region specifically includes: Obtain the binary image of the QR code image, which includes performing Laplace transform on the QR code image, performing closing operation on the Laplace image, and then performing threshold segmentation; Map the target point coordinates to the binary image to perform a cross search for the QR code connected region. Among them, during the cross search, expand in a preset order until the pixel value is the eigenvalue and then stop the search, and record the coordinates of the point corresponding to the eigenvalue as the feature coordinates; Extract the white area connected to the feature coordinates in the binary image to obtain the QR code connected region.

5. A method for positioning a two-dimensional code based on grid jump degree according to claim 4, characterized in that The judging the minimum bounding box of the connected region retrieved based on a preset discrimination rule. If it is satisfied, map the coordinates of the minimum bounding box of the connected region to the QR code image to obtain the QR code region specifically includes: Extract the minimum bounding box of the connected region based on the connected region of the QR code, and make a judgment based on a preset rule. The preset rule includes: the width of the minimum bounding box is greater than , the width of the minimum bounding box is less than , and the aspect ratio of the length to the width of the minimum bounding box is less than , where ; ; ; Among them, min_w is the minimum QR code width, max_w is the maximum QR code width, min_aspect_ratio is the minimum QR code length-width ratio, and PyramidLayer is the number of pyramid downsampling layers; Map the coordinates of the minimum bounding box of the connected region to the QR code image to perform region interception to obtain the QR code region.

6. A QR code positioning method based on grid jump degree according to claim 5, characterized in that The performing correction adjustment on the QR code region and then decoding it to complete QR code positioning specifically includes: Perform perspective transformation correction and contrast enhancement adjustment on the QR code region and then decode it. Among them, the minimum bounding box region that has participated in decoding will not be decoded repeatedly; Extract the preset number of decodings. Stop decoding when the decoding is successful and the number of two-dimensional codes obtained by decoding meets the number of decodings, thereby completing the positioning and recognition operation of the two-dimensional code.

7. A QR code positioning system based on grid jump degree, characterized in that It includes a memory and a processor. The memory includes a two-dimensional code positioning method program based on grid jump degree. When the two-dimensional code positioning method program based on grid jump degree is executed by the processor, the following steps are implemented: Obtain the two-dimensional code image to be recognized and sample it to obtain a grid image; Traverse the grid image to calculate the row and column jump degree scores, and sort the jump degree scores according to a preset sorting; Obtain the binary image of the two-dimensional code image, and map the target point coordinates corresponding to the highest jump degree score to the binary image for cross retrieval of the connected domain of the two-dimensional code; Judge the minimum bounding box of the connected domain retrieved based on a preset discrimination rule. If it is satisfied, map the coordinates of the minimum bounding box of the connected domain to the two-dimensional code image to obtain the two-dimensional code area; Perform correction and adjustment on the two-dimensional code area and then perform decoding to complete the positioning of the two-dimensional code. Among them, stop decoding when the decoding is successful and the number of two-dimensional codes obtained by decoding meets the preset number.

8. A two-dimensional code positioning system based on grid jump degree according to claim 7, characterized in that, The obtaining the two-dimensional code image to be recognized and sampling it to obtain a grid image specifically includes: Perform pyramid downsampling on the obtained two-dimensional code image and then perform grid scanning, where Perform full-image scanning on the two-dimensional code image based on a set grid window to obtain the grid image.

9. A two-dimensional code positioning system based on grid jump degree according to claim 8, characterized in that, The traversing the grid image to calculate the row and column jump degree scores and sorting the jump degree scores according to a preset sorting specifically includes: Calculate the jump degree scores of each row and each column by scanning each block of the grid image row by row and column by column; The calculation formula for the jump degree score is as follows: ; Among them, is the jump degree score, M is the pixel mean value, n is the total number of pixels, is the number of pixels in the first high-frequency interval greater than the pixel mean value, c is the number of pixels in the second high-frequency interval greater than the pixel mean value, and b is the number of pixels in the low-frequency interval less than the pixel mean value, is the pixel serial number, is the pixel value; Arrange the jump degree scores of the grid image in the order of the preset sorting, where the preset sorting includes from high to low.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a two-dimensional code positioning method program based on grid jump degree. When the two-dimensional code positioning method program based on grid jump degree is executed by a processor, it implements the steps of a two-dimensional code positioning method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Two-dimension code recognition method and device

    CN102880849A

  • Colorful three-dimensional code structure and colorful three-dimensional code reading method

    CN104657768A

  • Image acquisition, recognition and reading method and system based on CIS scanning

    CN105187686A

  • Two-dimensional code identification method and system based on connected domain analysis, device and medium

    CN109993019A

  • Low-quality two-dimensional code information extraction method and device based on run length coding

    CN112069852A