A QR code positioning method, system, and readable storage medium based on grid jump degree.
By employing a positioning method based on grid jump degree, utilizing pyramid downsampling and gridded scanning, combined with Laplace transform and closing operation, the problems of slow speed and poor compatibility of existing QR code recognition libraries are solved, achieving efficient and stable QR code recognition.
Patent Information
- Application Number
- CN202510872789.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-06-27
AI Technical Summary
Existing QR code recognition libraries have slow decoding speeds and low decoding success rates, especially under severe interference conditions, making it difficult to meet the needs of high-speed recognition and compatibility with multiple types of QR codes.
A grid-based hopping degree-based positioning method is adopted, which uses pyramid downsampling, gridded scanning, hopping degree calculation, Laplace transform and closing operation, combined with preset discrimination rules to locate and decode QR codes, avoiding repeated decoding.
It achieves efficient and stable QR code recognition, is compatible with all types of QR codes, improves positioning speed and robustness, reduces noise interference, and avoids repeated decoding.
Smart Images

Figure CN120387466B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically, to a QR code positioning method, system, and readable storage medium based on grid jump degree. Background Technology
[0002] QR codes are a very popular encoding method, and are widely used due to their large information storage capacity, strong fault tolerance, and high security.
[0003] Existing QR code recognition libraries have slow decoding speeds and low decoding success rates under severe interference. In industrial production, interference such as dust and dirt will further reduce decoding efficiency and success rates.
[0004] Currently, QR code positioning on the market has the following drawbacks:
[0005] 1. Deep learning-based localization methods require a large amount of labeled data for training, resulting in high maintenance costs and slow localization speed, making them difficult to meet the needs of high-speed recognition scenarios.
[0006] 2. Positioning methods based on QR code format require different positioning logic designs for different types of QR codes (such as DM codes and QR codes), lacking universality. Especially when the image is large, the positioning speed drops significantly, or even becomes unusable.
[0007] In summary, there is currently no publicly available positioning method that can simultaneously meet the requirements of high speed and compatibility with multiple types of QR codes. Summary of the Invention
[0008] The purpose of this invention is to provide a QR code positioning method, system, and readable storage medium based on grid jump degree, in order to overcome the shortcomings of the prior art.
[0009] The first aspect of this invention provides a QR code positioning method based on grid hop degree, comprising the following steps:
[0010] The image of the QR code to be recognized is sampled to obtain a gridded image;
[0011] The gridded image is traversed to calculate the row and column jump scores, and the jump scores are sorted according to a preset sorting.
[0012] Obtain the binary image of the QR code image, and perform cross-shaped retrieval of the connected components of the QR code based on the target point coordinates corresponding to the highest jump degree score mapped to the binary image;
[0013] Based on the preset discrimination rules, the minimum bounding box of the connected component is judged. If the condition is met, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area.
[0014] After correcting and adjusting the QR code area, decoding is performed to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets a preset number.
[0015] In this solution, the step of obtaining a gridded image by sampling the QR code image to be recognized specifically includes:
[0016] The acquired QR code image is then subjected to pyramid downsampling followed by gridded scanning, wherein...
[0017] The gridded image is obtained by scanning the entire QR code image based on the set grid window.
[0018] In this scheme, the step of traversing the gridded image to calculate the row and column jump scores, and sorting the jump scores according to a preset sorting, specifically includes:
[0019] For each gridded image, the jump score for each row and each column is calculated by scanning rows and columns;
[0020] The formula for calculating the jump score is as follows:
[0021] ;
[0022] in, The score represents the jumpiness, where M is the average pixel value and n is the total number of pixels. Let be the number of pixels in the first high-frequency range greater than the pixel mean, c be the number of pixels in the second high-frequency range greater than the pixel mean, and b be the number of pixels in the low-frequency range less than the pixel mean. Pixel number Pixel value;
[0023] The jump scores of the gridded image are arranged in a preset sorting order, wherein the preset sorting includes from high to low.
[0024] In this solution, obtaining the binary image of the QR code image and mapping the coordinates of the target point corresponding to the highest jump score onto the binary image to perform a cross-shaped search of the connected components of the QR code specifically includes:
[0025] Obtaining a binary image of the QR code image includes performing a Laplacian transform on the QR code image, and then performing threshold segmentation on the Laplacian image after performing a closing operation.
[0026] The target point coordinates are mapped onto the binary image, and a cross search of the connected components of the QR code is performed. During the cross search, the search is expanded in a preset order until a pixel value is found as a feature value, at which point the search stops and the coordinates of the point corresponding to the feature value are recorded as feature coordinates.
[0027] The white region connected to the feature coordinates is extracted from the binary image to obtain the QR code connected region.
[0028] In this scheme, the step of judging the minimum bounding box of the retrieved connected component based on a preset discrimination rule, and if the condition is met, mapping the coordinates of the minimum bounding box of the connected component to the QR code image to obtain the QR code region, specifically includes:
[0029] Based on the connected regions of the QR code, the minimum bounding box of the connected components is extracted, and the results are judged according to preset rules, including: the minimum bounding box width is greater than... The minimum bounding box width is less than The aspect ratio of the minimum bounding box is less than ,in,
[0030] ;
[0031] ;
[0032] ;
[0033] 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;
[0034] The QR code region is obtained by mapping the coordinates of the minimum bounding box of the connected component onto the QR code image and performing region cropping.
[0035] In this solution, the step of correcting and adjusting the QR code area before decoding to complete QR code positioning specifically includes:
[0036] After perspective transformation correction and contrast enhancement adjustment are performed on the QR code area, it is decoded. The minimum bounding box area that has participated in the decoding will not be decoded again.
[0037] Extract the preset number of decodes. When decoding is successful and the number of decoded QR codes meets the preset number of decodes, the decoding stops, thereby completing the QR code positioning and recognition operation.
[0038] A second aspect of the present invention also provides a QR code positioning system based on grid hopping degree, comprising a memory and a processor, wherein the memory includes a QR code positioning method program based on grid hopping degree, and the QR code positioning method program based on grid hopping degree, when executed by the processor, performs the following steps:
[0039] The image of the QR code to be recognized is sampled to obtain a gridded image;
[0040] The gridded image is traversed to calculate the row and column jump scores, and the jump scores are sorted according to a preset sorting.
[0041] Obtain the binary image of the QR code image, and perform cross-shaped retrieval of the connected components of the QR code based on the target point coordinates corresponding to the highest jump degree score mapped to the binary image;
[0042] Based on the preset discrimination rules, the minimum bounding box of the connected component is judged. If the condition is met, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area.
[0043] After correcting and adjusting the QR code area, decoding is performed to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets a preset number.
[0044] In this solution, the step of obtaining a gridded image by sampling the QR code image to be recognized specifically includes:
[0045] The acquired QR code image is then subjected to pyramid downsampling followed by gridded scanning, wherein...
[0046] The gridded image is obtained by scanning the entire QR code image based on the set grid window.
[0047] In this scheme, the step of traversing the gridded image to calculate the row and column jump scores, and sorting the jump scores according to a preset sorting, specifically includes:
[0048] For each gridded image, the jump score for each row and each column is calculated by scanning rows and columns;
[0049] The formula for calculating the jump score is as follows:
[0050] ;
[0051] in, The score represents the jumpiness, where M is the average pixel value and n is the total number of pixels. Let be the number of pixels in the first high-frequency range greater than the pixel mean, c be the number of pixels in the second high-frequency range greater than the pixel mean, and b be the number of pixels in the low-frequency range less than the pixel mean. Pixel number Pixel value;
[0052] The jump scores of the gridded image are arranged in a preset sorting order, wherein the preset sorting includes from high to low.
[0053] In this solution, obtaining the binary image of the QR code image and mapping the coordinates of the target point corresponding to the highest jump score onto the binary image to perform a cross-shaped search of the connected components of the QR code specifically includes:
[0054] Obtaining a binary image of the QR code image includes performing a Laplacian transform on the QR code image, and then performing threshold segmentation on the Laplacian image after performing a closing operation.
[0055] The target point coordinates are mapped onto the binary image, and a cross search of the connected components of the QR code is performed. During the cross search, the search is expanded in a preset order until a pixel value is found as a feature value, at which point the search stops and the coordinates of the point corresponding to the feature value are recorded as feature coordinates.
[0056] The white region connected to the feature coordinates is extracted from the binary image to obtain the QR code connected region.
[0057] In this scheme, the step of judging the minimum bounding box of the retrieved connected component based on a preset discrimination rule, and if the condition is met, mapping the coordinates of the minimum bounding box of the connected component to the QR code image to obtain the QR code region, specifically includes:
[0058] Based on the connected regions of the QR code, the minimum bounding box of the connected components is extracted, and the results are judged according to preset rules, including: the minimum bounding box width is greater than... The minimum bounding box width is less than The aspect ratio of the minimum bounding box is less than ,in,
[0059] ;
[0060] ;
[0061] ;
[0062] 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;
[0063] The QR code region is obtained by mapping the coordinates of the minimum bounding box of the connected component onto the QR code image and performing region cropping.
[0064] In this solution, the step of correcting and adjusting the QR code area before decoding to complete QR code positioning specifically includes:
[0065] After perspective transformation correction and contrast enhancement adjustment are performed on the QR code area, it is decoded. The minimum bounding box area that has participated in the decoding will not be decoded again.
[0066] Extract the preset number of decodes. When decoding is successful and the number of decoded QR codes meets the preset number of decodes, the decoding stops, thereby completing the QR code positioning and recognition operation.
[0067] A third aspect of the present invention provides a computer-readable storage medium including a machine program for a QR code positioning method based on grid hopping degree, wherein when the QR code positioning method program based on grid hopping degree is executed by a processor, it implements the steps of the QR code positioning method based on grid hopping degree as described in any of the preceding claims.
[0068] This invention discloses a QR code positioning method, system, and readable storage medium based on grid jump degree. Through innovative jump degree evaluation and grid priority positioning, it solves the problems of slow speed and poor versatility in existing technologies, achieving efficient and stable QR code recognition in complex environments. The specific beneficial effects are as follows:
[0069] 1. Strong compatibility, including compatibility with all types of QR codes through the "jump degree evaluation method" and "grid jump degree priority positioning";
[0070] 2. High speed: Mesh scanning and priority sorting significantly reduce invalid calculations, improve positioning speed, and pyramid downsampling further accelerates processing;
[0071] 3. High robustness: It utilizes Laplace transform and closing operation to enhance high-frequency features and reduce noise interference. Furthermore, cross-shaped search and morphological discrimination ensure accurate positioning and adapt to complex environments (such as dirt and dust).
[0072] 4. Avoid repeated decoding, i.e., the region suppression mechanism prevents the same QR code from being processed multiple times, thus improving efficiency. Attached Figure Description
[0073] Figure 1 The diagram illustrates the steps of a QR code positioning method based on grid jump degree according to the present invention.
[0074] Figure 2 A flowchart of a QR code positioning method based on grid jump degree according to the present invention is shown;
[0075] Figure 3 The image shown is a QR code image to be identified according to the QR code positioning method based on grid jump degree of the present invention;
[0076] Figure 4 A schematic diagram of grid scanning is shown for a QR code positioning method based on grid jump degree according to the present invention;
[0077] Figure 5 The diagram shows a grid pixel region of a QR code positioning method based on grid jump degree according to the present invention;
[0078] Figure 6 A schematic diagram of the grayscale value change curve of a QR code positioning method based on grid jump degree according to the present invention is shown;
[0079] Figure 7 A schematic diagram illustrating the maximum row and column jump degree of a QR code positioning method based on grid jump degree according to the present invention is shown.
[0080] Figure 8 A schematic diagram of the Laplace transform of a QR code positioning method based on grid jump degree according to the present invention is shown;
[0081] Figure 9 The Laplace plot of the QR code positioning method based on grid jump degree of the present invention after the closing operation is shown;
[0082] Figure 10 A binary image of a QR code positioning method based on grid jump degree according to the present invention is shown;
[0083] Figure 11 A schematic diagram of a cross-shaped retrieval method for QR code positioning based on grid jump degree according to the present invention is shown;
[0084] Figure 12 A schematic diagram of the minimum bounding box of a QR code positioning method based on grid jump degree according to the present invention is shown;
[0085] Figure 13 The image shown is a corrected QR code image based on a grid jump degree QR code positioning method according to the present invention;
[0086] Figure 14 The image shows a contrast-enhanced QR code image based on a grid jump degree QR code positioning method according to the present invention;
[0087] Figure 15 The minimum bounding box region involved in decoding is shown in the QR code positioning method based on grid jump degree of the present invention;
[0088] Figure 16 A schematic diagram of the decoding result of a QR code positioning method based on grid jump degree according to the present invention is shown;
[0089] Figure 17The block diagram of a two-dimensional code positioning system based on the grid jump degree of the present invention is shown. Detailed implementation mode
[0090] In order to be able 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 with reference to the accompanying drawings and specific implementation modes. 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.
[0091] 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.
[0092] At present, there are many open-source two-dimensional 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 industrial production field, the decoding speed and decoding success rate directly affect the production efficiency, and there may be more dust and dirt interfering with the appearance of the two-dimensional code. Then these open-source libraries are relatively not so applicable.
[0093] The decoding logic of two-dimensional codes is a set of standard methods internationally, and the core of all recognition methods lies in the acquisition and processing of two-dimensional code data before decoding. Therefore, it is very important to accurately and stably locate the position of two-dimensional codes. There are two mainstream methods for positioning two-dimensional codes, the positioning method based on deep learning and the positioning method based on the morphology of two-dimensional codes.
[0094] For the positioning method based on deep learning, it is necessary to pre-collect a large number of two-dimensional code pictures for corner point annotation, and for the two-dimensional code pictures with positioning failures, it is necessary to iterate and train repeatedly. Without a large number of high-quality data sets, the maintainability will be relatively low. At the same time, for the positioning method based on deep learning, the positioning speed is usually relatively slow, and it is not very suitable for some scenarios that require high-speed recognition.
[0095] At present, the vast majority of open-source libraries on the market are positioning methods designed based on the morphology of two-dimensional codes. Different positioning methods are designed for different types of two-dimensional code morphologies. For example, the edge of the DM (Data Matrix) code is composed of L-shaped and virtual line segments, and the positioning of the DM code usually needs to rely on the characteristics of the L-shaped and virtual line segments; another example is that there are double-square features at the three corners of the QR (Quick Response) code, and the positioning of the QR code usually relies on the double-square features. The positioning based on morphology is diverse, but it cannot be universal for all types of two-dimensional 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.
[0096] Currently, there is no publicly available positioning method that is fast and compatible with various types of QR codes. This application provides a universal QR code positioning mechanism with strong compatibility, high speed, and high robustness.
[0097] Specifically, Figure 1 A flowchart of a QR code positioning method based on grid jump degree according to this application is shown.
[0098] like Figure 1 As shown, this application discloses a QR code positioning method based on grid hopping degree, including the following steps:
[0099] S102, Obtain the QR code image to be recognized and sample it to obtain a gridded image;
[0100] S104, traverse the gridded image to calculate the row and column jump scores, and sort the jump scores according to a preset sorting.
[0101] S106, Obtain the binary image of the QR code image, and perform a cross search of the connected components of the QR code based on the target point coordinates corresponding to the highest jump score mapped to the binary image.
[0102] S108, Based on the preset discrimination rules, the minimum bounding box of the connected component is judged. If the condition is met, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area.
[0103] S110, after correcting and adjusting the QR code area, decoding is performed to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets the preset number.
[0104] It should be noted that, in this embodiment, as Figure 2 The diagram shows a flowchart of a QR code localization method based on grid jump degree. The method involves four steps: image preprocessing, gridded scanning and jump degree calculation, precise QR code localization, and decoding optimization. In image preprocessing, the QR code image to be recognized is first sampled to obtain a gridded image. Pyramid downsampling can reduce the image size and accelerate processing. Further, in gridded scanning and jump degree calculation, row and column jump degree scores are calculated by traversing the gridded image and sorted according to a preset order. Simultaneously, a binary image of the QR code image is obtained. Based on the coordinates of the target point corresponding to the highest jump degree score, a cross-shaped search of the QR code's connected regions is performed in the binary image to obtain the connected regions of the QR code.
[0105] Further, precise QR code positioning involves extracting the minimum bounding box of the connected components and judging the retrieved minimum bounding boxes based on preset discrimination rules. When the preset rules are met, the coordinates of the minimum bounding box are mapped onto the QR code image to obtain the QR code region. Finally, decoding optimization is performed, that is, the QR code region is corrected and adjusted before decoding to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets a preset number. Suppression optimization is performed on the decoded region to prevent duplicate processing.
[0106] According to an embodiment of the present invention, the step of obtaining a gridded image by sampling the QR code image to be recognized specifically includes:
[0107] The acquired QR code image is then subjected to pyramid downsampling followed by gridded scanning, wherein...
[0108] The gridded image is obtained by scanning the entire QR code image based on the set grid window.
[0109] It should be noted that, in this embodiment, as Figure 3 As shown, the QR code image to be recognized is subjected to pyramid downsampling to reduce its size and speed up the process, and then gridded scanning is performed. For example... Figure 4 As shown, this is a schematic diagram of grid scanning. Here, "step" is the window sliding step size when calculating the jump degree, and the corresponding rectangle is the window for calculating the jump degree. The jump degree is calculated once every time the window slides on the image by one step. Specifically, the entire image is scanned through a set grid window with a step size of 1 / 2 grid size. In practical applications, the grid window size should preferably be adapted to the QR code size, without too much deviation. The QR code has been "masked" to prevent it from being scanned.
[0110] According to an embodiment of the present invention, the step of traversing the gridded image to calculate the row and column jump scores, and sorting the jump scores according to a preset sorting, specifically includes:
[0111] For each gridded image, the jump score for each row and each column is calculated by scanning rows and columns;
[0112] The formula for calculating the jump score is as follows:
[0113] ;
[0114] in, The score represents the jumpiness, where M is the average pixel value and n is the total number of pixels. Let be the number of pixels in the first high-frequency range greater than the pixel mean, c be the number of pixels in the second high-frequency range greater than the pixel mean, and b be the number of pixels in the low-frequency range less than the pixel mean. Pixel number Pixel value;
[0115] The jump scores of the gridded image are arranged in a preset sorting order, wherein the preset sorting includes from high to low.
[0116] It should be noted that, in this embodiment, each grid image is evaluated by scanning rows and columns, and a jump score is calculated for each row and column. The scores are then summed as the score for that grid. The jump score is calculated by first calculating the pixel mean M of the image within the grid, then traversing the pixels of each row or column. Pixels greater than the pixel mean M are called "high frequency," and those less than the pixel mean M are called "low frequency." Figure 5 As shown, it is displayed as a grid pixel area map, such as Figure 6 As shown, the corresponding grayscale value change curve is displayed. Specifically, for Figure 5 The grid area map shown is used to calculate the jump score based on the pixel values in the high and low frequency ranges:
[0117] ;
[0118] Among them, the total number of pixels n is "19", which is greater than the number of pixels in the first high-frequency interval of the pixel mean. The number of pixels in the second high-frequency interval (greater than the pixel mean) is "6", the number of pixels c in the low-frequency interval (greater than the pixel mean) is "5", and the number of pixels b in the low-frequency interval (less than the pixel mean) is "8". In order to suppress noise interference, the number of pixels in each interval must be at least 3; otherwise, they will not be included in the score calculation.
[0119] Furthermore, record the row x and column y with the largest jump degree within each grid, to obtain the point P(x,y) with the largest jump degree within each grid, as follows: Figure 7 As shown, this is a schematic diagram of the maximum row and column jump degree. After extensive data verification, if the grid image is a QR code part, the point with the maximum jump degree must be in the internal area of the QR code. Therefore, all grids can be sorted from high to low according to the jump degree score. The reason for using the preset sorting from high to low in this embodiment is that the position with the high score is more likely to be a QR code, and will be decoded first, so that the QR code can be found and identified more quickly.
[0120] According to an embodiment of the present invention, the step of obtaining the binary image of the QR code image and performing a cross-shaped search of the connected components of the QR code based on mapping the coordinates of the target point corresponding to the highest jump degree score onto the binary image specifically includes:
[0121] Obtaining a binary image of the QR code image includes performing a Laplacian transform on the QR code image, and then performing threshold segmentation on the Laplacian image after performing a closing operation.
[0122] The target point coordinates are mapped onto the binary image, and a cross search of the connected components of the QR code is performed. During the cross search, the search is expanded in a preset order until a pixel value is found as a feature value, at which point the search stops and the coordinates of the point corresponding to the feature value are recorded as feature coordinates.
[0123] The white region connected to the feature coordinates is extracted from the binary image to obtain the QR code connected region.
[0124] It should be noted that, in this embodiment, as Figure 8 The diagram shows a Laplacian transformation, where the QR code image undergoes a Laplacian transform, followed by a closing operation and threshold segmentation. The kernel size for the closing operation is automatically calculated based on the grid size, using the following formula:
[0125] ;
[0126] Where GridSize is the preset grid window size, and PyramidLayer is the number of pyramid downsampling layers, such as... Figure 9 As shown, the Laplace graph is displayed after the closing operation, and then... Figure 9 The image shown is subjected to thresholding to obtain a binary image, where the pixel value of the white area is "255" and the pixel value of the black area is "0". The final binary image is shown below. Figure 10 As shown.
[0127] Furthermore, the set of grids sorted according to the jump degree score is traversed, and the point with the largest jump degree in the grid (i.e., point P) is taken as the target point. The coordinates of the target point are mapped to the binary graph, and the connected components of the QR code are searched in a cross shape. The search range shall not exceed the size of the grid being traversed.
[0128] Among them, such as Figure 11 As shown, this is a schematic diagram of a cross-shaped search, in which... Figure 11 The "0 point" in the image is point P. The overall search direction is to expand outward in a cross shape with point P as the center. First, search the adjacent cross region pixels, and then expand outward in sequence until a point with a pixel value of "255" is found, at which point the search stops. Record the coordinates S(x,y) of the feature point. Extract the white area connected to feature point S on the binary image, which is the required connected component of the QR code.
[0129] According to an embodiment of the present invention, the step of judging the minimum bounding box of the retrieved connected components based on a preset discrimination rule, and mapping the coordinates of the minimum bounding box of the connected components to the QR code image to obtain the QR code region, specifically includes:
[0130] Based on the connected regions of the QR code, the minimum bounding box of the connected components is extracted, and the results are judged according to preset rules, including: the minimum bounding box width is greater than... The minimum bounding box width is less than The aspect ratio of the minimum bounding box is less than ,in,
[0131] ;
[0132] ;
[0133] ;
[0134] 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;
[0135] The QR code region is obtained by mapping the coordinates of the minimum bounding box of the connected component onto the QR code image and performing region cropping.
[0136] It should be noted that, in this embodiment, the minimum bounding box of the connected region is extracted based on the connected region of the QR code, such as... Figure 12 The diagram shows a minimum bounding box, where the determination is based on preset rules, including: the minimum bounding box width is greater than... The minimum bounding box width is less than The aspect ratio of the minimum bounding box is less than Specifically:
[0137] ;
[0138] ;
[0139] ;
[0140] Wherein, 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. Then, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code region.
[0141] According to an embodiment of the present invention, the step of correcting and adjusting the QR code area and then decoding to complete the QR code positioning specifically includes:
[0142] After perspective transformation correction and contrast enhancement adjustment are performed on the QR code area, it is decoded. The minimum bounding box area that has participated in the decoding will not be decoded again.
[0143] Extract the preset number of decodes. When decoding is successful and the number of decoded QR codes meets the preset number of decodes, the decoding stops, thereby completing the QR code positioning and recognition operation.
[0144] It should be noted that, in this embodiment, perspective transformation correction is performed on the QR code area, such as... Figure 13 As shown, the image displayed is the corrected QR code image, along with contrast enhancement adjustments, as follows: Figure 14 As shown, the QR code image is displayed after contrast enhancement. The QR code area is corrected and adjusted before decoding. For example... Figure 15 As shown, the smallest bounding box region that has participated in decoding will undergo region suppression on the binary image to prevent that region from being searched again in the next iteration, ensuring that there is no duplicate decoding. Finally, a preset number of decoding operations is extracted. Decoding stops when the decoding is successful and the number of decoded QR codes meets the preset number of decoding operations, thereby completing the QR code positioning and recognition operation. Figure 16 The image shown is a schematic diagram of the final decoding result.
[0145] Figure 17 A block diagram of a QR code positioning system based on grid jump degree according to the present invention is shown.
[0146] like Figure 17 As shown, this invention discloses a QR code positioning system based on grid hopping degree, including a memory and a processor. The memory includes a QR code positioning method program based on grid hopping degree. When the processor executes the QR code positioning method program based on grid hopping degree, it performs the following steps:
[0147] The image of the QR code to be recognized is sampled to obtain a gridded image;
[0148] The gridded image is traversed to calculate the row and column jump scores, and the jump scores are sorted according to a preset sorting.
[0149] Obtain the binary image of the QR code image, and perform cross-shaped retrieval of the connected components of the QR code based on the target point coordinates corresponding to the highest jump degree score mapped to the binary image;
[0150] Based on the preset discrimination rules, the minimum bounding box of the connected component is judged. If the condition is met, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area.
[0151] After correcting and adjusting the QR code area, decoding is performed to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets a preset number.
[0152] It should be noted that the technical solution and detailed implementation of this embodiment are consistent with the above-described embodiment of the QR code positioning method based on grid jump degree, and will not be repeated here.
[0153] A third aspect of the present invention provides a computer-readable storage medium including a QR code positioning method program based on grid hopping degree. When the QR code positioning method program based on grid hopping degree is executed by a processor, it implements the steps of the QR code positioning method based on grid hopping degree as described in any of the preceding claims.
[0154] This invention discloses a QR code positioning method, system, and readable storage medium based on grid jump degree. Through innovative jump degree evaluation and grid priority positioning, it solves the problems of slow speed and poor versatility of existing technologies, and achieves efficient and stable QR code recognition in complex environments.
[0155] In the several embodiments provided in this 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 units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0156] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0157] In addition, in the various embodiments of the present invention, each functional unit can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0158] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0159] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
Claims
1. A QR code positioning method based on grid jump degree, characterized in that, Includes the following steps: The image of the QR code to be recognized is sampled to obtain a gridded image; The gridded image is traversed to calculate the row and column jump scores, and the jump scores are sorted according to a preset sorting. Obtain the binary image of the QR code image, and perform cross-shaped retrieval of the connected components of the QR code based on the target point coordinates corresponding to the highest jump degree score mapped to the binary image; Based on the preset discrimination rules, the minimum bounding box of the connected component is judged. If the condition is met, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area. After the QR code area is corrected and adjusted, decoding is performed to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets the preset number. The step of traversing the gridded image to calculate row and column jump scores, and sorting the jump scores according to a preset sorting, specifically includes: For each gridded image, the jump score for each row and each column is calculated by scanning rows and columns; The formula for calculating the jump score is as follows: ; in, The score represents the jumpiness, where M is the average pixel value and n is the total number of pixels. Let be the number of pixels in the first high-frequency range greater than the pixel mean, c be the number of pixels in the second high-frequency range greater than the pixel mean, and b be the number of pixels in the low-frequency range less than the pixel mean. Pixel number Pixel value; The jump scores of the gridded image are arranged in a preset sorting order, wherein the preset sorting includes from high to low; In this context, the average pixel value M of the image within the grid is used to iterate through each row or column. Pixels greater than the average pixel value M are called high-frequency intervals, and those less than the average pixel value M are called low-frequency intervals.
2. The QR code positioning method based on grid jump degree according to claim 1, characterized in that, The process of obtaining a gridded image by sampling the QR code image to be recognized specifically includes: The acquired QR code image is then subjected to pyramid downsampling followed by gridded scanning, wherein... The gridded image is obtained by scanning the entire QR code image based on the set grid window.
3. The QR code positioning method based on grid jump degree according to claim 1, characterized in that, The process of obtaining the binary image of the QR code and mapping the coordinates of the target point corresponding to the highest jump score onto the binary image to perform a cross-shaped search of the connected components of the QR code specifically includes: Obtaining a binary image of the QR code image includes performing a Laplacian transform on the QR code image, and then performing threshold segmentation on the Laplacian image after performing a closing operation. The target point coordinates are mapped onto the binary image, and a cross search of the connected components of the QR code is performed. During the cross search, the search is expanded in a preset order until a pixel value is found as a feature value, at which point the search stops and the coordinates of the point corresponding to the feature value are recorded as feature coordinates. The white region connected to the feature coordinates is extracted from the binary image to obtain the QR code connected region.
4. The QR code positioning method based on grid jump degree according to claim 3, characterized in that, The step of judging the minimum bounding box of the retrieved connected component based on a preset discrimination rule, and if the condition is met, mapping the coordinates of the minimum bounding box of the connected component to the QR code image to obtain the QR code region, specifically includes: Based on the connected regions of the QR code, the minimum bounding box of the connected components is extracted, and the results are judged according to preset rules, including: the minimum bounding box width is greater than... The minimum bounding box width is less than The aspect ratio of the minimum bounding box is less than ,in, ; ; ; in, Minimum QR code width, Maximum QR code width The minimum aspect ratio of the QR code, This represents the number of downsampling layers in the pyramid. The QR code region is obtained by mapping the coordinates of the minimum bounding box of the connected component onto the QR code image and performing region cropping.
5. The QR code positioning method based on grid jump degree according to claim 4, characterized in that, The process of correcting and adjusting the QR code area before decoding to complete QR code positioning specifically includes: After perspective transformation correction and contrast enhancement adjustment are performed on the QR code area, it is decoded. The minimum bounding box area that has participated in the decoding will not be decoded again. Extract the preset number of decodes. When decoding is successful and the number of decoded QR codes meets the preset number of decodes, the decoding stops, thereby completing the QR code positioning and recognition operation.
6. A QR code positioning system based on grid jump degree, characterized in that, The system includes a memory and a processor. The memory contains a QR code positioning method program based on grid hop count. When executed by the processor, the QR code positioning method program based on grid hop count performs the following steps: The image of the QR code to be recognized is sampled to obtain a gridded image; The gridded image is traversed to calculate the row and column jump scores, and the jump scores are sorted according to a preset sorting. Obtain the binary image of the QR code image, and perform cross-shaped retrieval of the connected components of the QR code based on the target point coordinates corresponding to the highest jump degree score mapped to the binary image; Based on the preset discrimination rules, the minimum bounding box of the connected component is judged. If the condition is met, the coordinates of the minimum bounding box of the connected component are mapped to the QR code image to obtain the QR code area. After the QR code area is corrected and adjusted, decoding is performed to complete the QR code positioning. Decoding stops when the decoding is successful and the number of decoded QR codes meets the preset number. The step of traversing the gridded image to calculate row and column jump scores, and sorting the jump scores according to a preset sorting, specifically includes: For each gridded image, the jump score for each row and each column is calculated by scanning rows and columns; The formula for calculating the jump score is as follows: ; in, The score represents the jumpiness, where M is the average pixel value and n is the total number of pixels. Let be the number of pixels in the first high-frequency range greater than the pixel mean, c be the number of pixels in the second high-frequency range greater than the pixel mean, and b be the number of pixels in the low-frequency range less than the pixel mean. Pixel number Pixel value; The jump scores of the gridded image are arranged in a preset sorting order, wherein the preset sorting includes from high to low; In this context, the average pixel value M of the image within the grid is used to iterate through each row or column. Pixels greater than the average pixel value M are called high-frequency intervals, and those less than the average pixel value M are called low-frequency intervals.
7. A QR code positioning system based on grid jump degree according to claim 6, characterized in that, The process of obtaining a gridded image by sampling the QR code image to be recognized specifically includes: The acquired QR code image is then subjected to pyramid downsampling followed by gridded scanning, wherein... The gridded image is obtained by scanning the entire QR code image based on the set grid window.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a QR code positioning method program based on grid hopping degree. When the QR code positioning method program based on grid hopping degree is executed by a processor, it implements the steps of the QR code positioning method based on grid hopping degree as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Two-dimension code recognition method and device
CN102880849A
Image acquisition, recognition and reading method and system based on CIS scanning
CN105187686A