QR code detection method and device, storage medium and computer program

Through the preliminary detection, fine positioning and reconstruction decoding steps of the QR code detection method, the problem of low QR code scanning success rate in industrial production is solved, and efficient decoding in complex environments is achieved.

CN120671696APending Publication Date: 2025-09-19SHENZHEN HANS GREEN POWER LIGHTING TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510356243.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

In industrial production scenarios, due to differences in the reflective properties of the material matrix and the manufacturing process, the quality and pixel size of QR codes vary greatly, resulting in a low scanning success rate and the inability to achieve rapid detection and decoding.

Method used

A QR code detection method is adopted, including preliminary detection, fine positioning and reconstruction decoding steps. By detecting whether there is a QR code in the image, its position, orientation and version are determined, and the grayscale image is divided into a grid, each module in the image is converted into a black or white point, and then decoding is performed.

Benefits of technology

The success rate of QR code scanning is improved, and through the combination of multiple decoding strategies, successful decoding is ensured even in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120671696A_ABST
    Figure CN120671696A_ABST
Patent Text Reader

Abstract

The invention discloses a QR code detection method and device, a storage medium and a computer program.The QR code detection method comprises the steps that a preliminary detection step is executed firstly, whether QR codes exist in an image or not is determined, if yes, a preliminary detection area containing the QR codes is given, then a fine positioning step is executed, the positions, directions and versions of the QR codes are determined in the preliminary detection area, and then the QR codes are detected. According to the method, a QR code is used as a template, a gray level image is obtained, finally, a reconstruction decoding step is executed, grid equal division is performed on the gray level image according to the version of the QR code, each module in the image is converted into a black or white point, then decoding is performed, the QR code detection method starts from several links of preliminary detection, fine positioning, reconstruction and decoding, and the detection success rate can be improved step by step.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of two-dimensional code, and particularly relates to a QR code detection method, device, storage medium and computer program. Background Art

[0002] As a two-dimensional code identification scheme with large information capacity, strong integrity and low cost in the perception layer of the Internet of Things, the QR code (Quick Response Code) has become an important carrier for information interaction and data transmission, and has been widely deployed in various fields such as e-commerce, warehousing logistics and equipment management.

[0003] In industrial production scenarios, due to the different reflective properties of the material matrix and manufacturing processes (silk screen / laser), and the addition of the "dot matrix" structure (some discrete dot blocks are used to replace the original continuous shape, which needs to be restored in the image preprocessing stage, and due to the comprehensive influence of the physical size of these discrete dot blocks and the photographing accuracy, the pixel number of the unit module will vary), the quality and pixel size of QR codes vary greatly, reducing the scanning success rate of QR codes and resulting in the inability to achieve rapid detection and decoding of QR codes. Summary of the Invention

[0004] In view of the deficiencies of the above-mentioned prior art, the present application provides a QR code detection method, device, storage medium and computer program, which can improve the scanning success rate of QR codes.

[0005] The following technical solutions are adopted in this embodiment:

[0006] A QR code detection method includes the steps of:

[0007] Preliminary detection: Detect whether there is a QR code in the image. If there is, give a preliminary detection area containing the QR code;

[0008] Fine positioning: In the preliminary detection area, determine the position, direction and version of the QR code, and obtain a grayscale image;

[0009] Reconstruction and decoding: According to the version of the QR code, divide the grayscale image into grids equally, convert each module in the image into a black or white point, and then perform decoding.

[0010] Further, in the QR code detection method, the step of determining the position, direction and version of the QR code includes:

[0011] Obtain an edge image, perform contour extraction on the edge image, screen and combine according to the principle that three "square frame" identification patterns form an isosceles triangle, take the combination of the three "square frame" identification patterns with the largest area as the target item, and determine the position, direction and version of the QR code according to the target item.

[0012] Further, in the QR code detection method, the step of determining the position, orientation, and version of the QR code according to the target item includes:

[0013] Obtain the size of the innermost block of the three "hui" - shaped identification patterns, take the median value and calculate the size of the unit module based on this, and infer the version of the QR code according to the length of the right - angled side;

[0014] Determine the position and orientation of the QR code according to the fact that the three "hui" - shaped identification patterns form an isosceles triangle.

[0015] Further, in the QR code detection method, the step of converting each module in the image into a black or white point and then performing decoding includes:

[0016] Taking the grayscale value of the center point of each module as a representative, and comprehensively determining its black - and - white attribution in combination with the global mean and local strength and weakness to obtain a reconstructed image.

[0017] Further, in the QR code detection method, the step of converting each module in the image into a black or white point and then performing decoding further includes:

[0018] Set multiple decoding strategies and execute the multiple decoding strategies in sequence until decoding is successful.

[0019] Further, in the QR code detection method, the step of executing multiple decoding strategies in sequence until decoding is successful includes:

[0020] First - time decoding: Set the three "hui" - shaped identification patterns as fixed styles in an 8 * 8 area respectively, and then perform decoding using the standard process;

[0021] If the first - time decoding is successful, end the decoding;

[0022] If the first - time decoding fails, continue with the new decoding steps.

[0023] Further, in the QR code detection method, the new decoding steps include one or more of the following steps:

[0024] In the reconstructed image, for the center points that satisfy "the 3 * 3 four - neighborhood is white and the number of points with a grayscale value higher than the center point is greater than two", change from white to black, and then perform decoding using the first - time decoding steps;

[0025] Or, in the reconstructed image, for the center points that satisfy "the 3 * 3 four - neighborhood is black and the number of points with a grayscale value lower than the center point is greater than two", change from black to white, and then perform decoding using the first - time decoding steps;

[0026] Alternatively, in the reconstructed image, the center point that satisfies the requirement of "a certain amplitude lower than the median of the 3*3 eight-neighborhood" is turned from white to black, and then decoded using the first decoding step;

[0027] Alternatively, in the reconstructed image, the center point that meets the requirement of "being higher than the median of the 3*3 eight-neighborhood by a certain amplitude" is turned from black to white, and then decoded using the first decoding step.

[0028] Compared with the prior art, the present application provides a QR code detection method, device, storage medium and computer program. In the QR code detection method, a preliminary detection step is first performed to confirm whether there is a QR code in the image. If a QR code is present, a preliminary detection area containing the QR code is given, and then a fine positioning step is performed to determine the position, direction and version of the QR code in the preliminary detection area, and obtain a grayscale image. Finally, a reconstruction and decoding step is performed. According to the version of the QR code, the grayscale image is divided into a grid, so that each module in the image is converted into a black or white point, and then decoding is performed. The QR code detection method starts from the preliminary detection, fine positioning, reconstruction and decoding, and can improve the detection success rate step by step. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 The process of the QR code detection method provided in this application Figure 1 .

[0030] Figure 2 The process of the QR code detection method provided in this application Figure 2 .

[0031] Figure 3 This is a schematic diagram of an image containing a QR code provided for this application.

[0032] Figure 4 This is a structural block diagram of the QR code detection device provided in this application. DETAILED DESCRIPTION

[0033] In order to make the technical problems, technical solutions and beneficial effects to be solved by this application more clearly understood, the following further describes this application in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0034] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.

[0035] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.

[0036] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0037] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0038] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0039] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0040] QR codes are composed of black and white blocks and use specific encoding rules to store information. They can store a variety of data types, including numbers, letters, and Chinese characters. In industrial production scenarios, QR codes can be placed on materials and recognized by cameras to obtain information about the materials.

[0041] See also Figure 1 and Figure 2 The QR code detection method provided in this application includes the following steps:

[0042] S10, preliminary detection: detect whether there is a QR code in the image, and if so, provide a preliminary detection area containing the QR code;

[0043] S20, fine positioning: within the preliminary detection area, determine the position, orientation, and version of the QR code and obtain a grayscale image;

[0044] S30, reconstruction decoding: According to the version of the QR code, the grayscale image is divided into a grid, so that each module in the image is converted into a black or white point, and then decoding is performed.

[0045] The QR code detection method starts with preliminary detection, fine positioning, reconstruction and decoding, and gradually improves the detection success rate.

[0046] The basic structure of a QR code includes a position detection pattern, separators, an identification pattern, a time pattern, format information, a mask pattern, and an error correction code. These elements work together to ensure efficient QR code reading and data recovery. QR codes have versions ranging from 1 to 40, each with varying size and storage capacity. The larger the version, the greater the amount of data that can be stored. QR codes have four levels of error correction: L, M, Q, and H, ensuring data recovery in the event of loss or damage.

[0047] As an important branch of vision tasks, object detection has seen the emergence of many excellent deep learning open-source detection frameworks in recent years, with the YOLO series being the most renowned. QR codes have relatively stable graphical structures that can be trained and extracted as common features for detection.

[0048] In a specific embodiment, the following steps can be used to implement preliminary detection:

[0049] S11. Dataset organization: Collect as many QR code physical illuminated images of different versions and styles as possible, annotate them, and then perform operations such as rotation, mirroring, slicing, and polarity flipping to enrich the sample.

[0050] S12. Model training: Train the model in Python and export it as a model file. Train once, use anywhere.

[0051] S13. Deploy the application: load the model file in the C++ environment, call the inference interface, perform detection on the memory image, and obtain the results.

[0052] It is worth mentioning that there are many options for each link of the preliminary detection step, and the above implementation method is only described through a specific example.

[0053] When the QR code was invented, an error correction mechanism was designed so that it can be recognized and scanned even if a part of it is missing. When scanning the code, it relies on the identification patterns on the QR code for positioning. These patterns usually form a "hui" character shape. By using three positioning patterns, the position and orientation of a QR code rectangle can be identified and determined. The error correction function of the QR code further ensures that even if the code becomes dirty or damaged, the data can be automatically restored, thereby increasing the success rate of code scanning.

[0054] After obtaining the preliminary detection area containing the QR code through the preliminary detection step, the preliminary detection area is usually larger than the actual area of the QR code, and the actual area of the QR code needs to be further determined through the fine positioning step.

[0055] For example, Figure 3 As shown, the box B1 is the preliminary detection area containing the QR code. It can be seen that the preliminary detection area does not tightly enclose the QR code and does not indicate the position of the missing "hui" character identification pattern, which is not convenient for subsequent reconstruction. Therefore, further fine positioning is required.

[0056] In some embodiments, the following steps can be adopted for fine positioning:

[0057] Obtain an edge image, perform contour extraction on the edge image, screen and combine according to the principle that the three "hui" character identification patterns form an isosceles triangle, take the combination of the three "hui" character identification patterns with the largest area as the target item, and determine the position, orientation and version of the QR code according to the target item.

[0058] The edge image is an image obtained by performing edge extraction on the original image. An edge is the junction of an image area and another attribute area, the place where the area attributes change suddenly, the place with the greatest uncertainty in the image, and also the place where the image information is most concentrated.

[0059] The three corner angles with unique designs of the QR code are the key to the fine positioning step. Based on the contour relationship, find the centers of the corner angles, screen and combine according to the isosceles triangle principle, take the group with the largest area as the target item, and at the same time infer the version based on this and determine the "gap" orientation of the QR code.

[0060] The isosceles triangle principle means that the sequential connection of the centers of the three "hui" character identification patterns of the QR code will form an isosceles triangle. However, due to the influence of some interference factors, multiple combinations may be mis-extracted when extracting the "hui" character identification patterns, and the combination of the three "hui" character identification patterns with the largest area is confirmed as the required combination of the three "hui" character identification patterns.

[0061] For example, Figure 3 As shown, the box B2 is the fine positioning area of the QR code, which can tightly enclose the QR code more compactly.

[0062] In some embodiments, the steps of determining the position, orientation, and version of the QR code include:

[0063] Obtain the sizes of the innermost blocks of the three "回"-shaped identification patterns, take the median value, and calculate the size of the unit module based on this. Infer the version of the QR code based on the length of the right-angled side.

[0064] Determine the position and orientation of the QR code according to the three "回"-shaped identification patterns forming an isosceles triangle.

[0065] Since there are three "回"-shaped identification patterns for the QR code, there may be three different sizes. Taking the median value can play a role in anti-interference. By determining the size of the innermost block of the "回"-shaped identification pattern, the size of the entire QR code can be further determined, and thus the version of the QR code can be known.

[0066] In a specific embodiment, the following steps can be adopted to achieve fine detection:

[0067] S21. Smoothing filtering: Median filtering can be performed using several sizes of 3 / 5 / 7 / 9 according to the pixel size of the candidate region to remove some noise interference.

[0068] S22. Gradient estimation: Calculate the gray difference of adjacent positions to facilitate subsequent edge extraction. A quick and simple calculation method is as follows: Make differences column by column horizontally at the middle part of the candidate region, include those with absolute values higher than the threshold in the statistical summation, and finally take the average value.

[0069]

[0070] Among them, G represents the gray value of the image, its subscript refers to the row and column coordinates, th refers to the threshold value, generally taking 10, and Tsum is the cumulative sum of the absolute values of the gradient differences.

[0071] The core idea of the formula is that flat regions with small differences do not participate in gradient calculation to avoid lowering the threshold.

[0072] S23. Edge extraction: The Canny operator can be used, with the average gradient as the low threshold of its input parameter and twice the gradient as the high threshold to obtain the edge image; then bond the fracture situations within the 3*3 region to facilitate subsequent contour extraction.

[0073] S24. Screening of corner points: Perform contour extraction on the edge image. First, screen out the contour with a slightly larger and more square size, then use the non-maximum suppression method to remove the overlapping ones, and finally see if they can form an "isosceles triangle" in groups of three, and only keep the group with the largest area. If not, try several times after expanding the edge image in an accumulative progressive manner and then extracting the contour again.

[0074] S25. Speculative boundary: Take the contour of the middle size among the three rounded corners as the innermost block of the inner rounded corner, and thus obtain the size of the unit module; then infer the version based on the length of the right-angled side. Considering the existence of errors, add one version to each of the upper and lower sides.

[0075] L = MID(L1, L2, L3)

[0076] D = MAX(D1, D2)

[0077]

[0078] Among them, L refers to the size of the innermost loop of the "return" - shaped identification pattern, and the middle value is taken to resist interference; S is the size of the unit module. According to the QR standard, the size of the loop is three times the size of the unit module, so the size of the unit module is L / 3; D refers to the distance between the centers of the "return" - shaped identification patterns. Here, the two sides located on the right - angled side are used; V ′ is the preliminary calculation result, and there may be errors. Take three values in V nearby to improve the decoding rate.

[0079] S26. Presumptive notch: Based on the structure that three "return" - shaped identification patterns form an "isosceles triangle",推定缺口所在方位。

[0080] S27. Take the image and摆正: Transform and take out the grayscale image so that the notch is located at the lower right corner.

[0081] It is worth mentioning that there are many optional solutions for each link in the fine - detection steps. The above implementation manners are only illustrated by a specific embodiment.

[0082] Reconstruction decoding includes two steps: reconstruction and decoding. The purpose of reconstruction is to binarize the grayscale image obtained in the fine - detection step, so that each module becomes a black or white point for subsequent decoding.

[0083] In some embodiments, the steps of reconstruction decoding include:

[0084] Taking the grayscale value of the center point of each module as a representative, and comprehensively determining its black - and - white attribution in combination with the global mean value and local strength and weakness to obtain the reconstructed image.

[0085] The principle of reconstruction is that, based on the version deduced previously, the grayscale image is evenly divided into grids to obtain the module size. Then, taking the grayscale value of the central area of the module as a representative, comprehensively determining its black - and - white attribution in combination with the global mean value and local strength and weakness. Finally, directly identify the three rounded corners, and thus complete the reconstruction of the QR code.

[0086] In some embodiments, the steps of reconstruction decoding further include:

[0087] Setting multiple decoding strategies and sequentially executing multiple decoding strategies until the decoding is successful. It should be noted that in the translation of "推定缺口所在方位", there may be some inaccuracies in the original Chinese expression. It is recommended to check the original text for a more accurate meaning. If it is "推测缺口所在方位", the translation above is correct.

[0088] By adopting multiple different decoding strategies for decoding in sequence, the success rate of decoding can be improved.

[0089] In some embodiments, the steps of performing multiple decoding strategies until successful decoding include:

[0090] First decoding: Set the three "square within a square" identification patterns as fixed styles in 8*8 regions respectively, and then perform decoding using the standard process;

[0091] If the first decoding is successful, end the decoding;

[0092] If the first decoding fails, continue with new decoding steps.

[0093] The standard process is the decoding process provided in the QR code standard and can be implemented using an open-source solution.

[0094] In some embodiments, the new decoding steps include one or more of the following steps:

[0095] In the reconstructed image, for the center points that satisfy "the 3*3 four-neighborhood is white and the number of pixels with a gray value higher than the center point is greater than two", change the color from white to black, and then perform decoding using the steps of the first decoding;

[0096] In the reconstructed image, for the center points that satisfy "the 3*3 four-neighborhood is black and the number of pixels with a gray value lower than the center point is greater than two", change the color from black to white, and then perform decoding using the steps of the first decoding;

[0097] In the reconstructed image, for the center points that satisfy "lower than the value of the 3*3 eight-neighborhood by a certain amplitude", change the color from white to black, and then perform decoding using the steps of the first decoding;

[0098] In the reconstructed image, for the center points that satisfy "higher than the value of the 3*3 eight-neighborhood by a certain amplitude", change the color from black to white, and then perform decoding using the steps of the first decoding.

[0099] It can be understood that, according to actual needs, one of the above decoding steps can be selected for execution, or several of the decoding steps can be executed in sequence, or all of the decoding steps can be executed in sequence, and the order of the above decoding steps can also be re-set.

[0100] The eight-neighborhood and four-neighborhood are common concepts in image processing and computer vision, used to describe the relationship between neighboring pixels around a pixel. In image processing, pixel points are saved and displayed row by row. 3*3 means that the field of view for local processing is 3 pixel points for both rows and columns. The meaning of the neighborhood is the points in a circle around the point under investigation.

[0101] In a two-dimensional plane, the eight-neighborhood of a pixel refers to the eight adjacent pixels around it, located above, below, left, right, and in the four diagonal directions. The four-neighborhood refers to the four adjacent pixels around the pixel, located above, below, left, and right.

[0102] Through the above steps, the grayscale value of the central area of ​​the module can be used as a representative, and its black and white attribution can be re-determined by combining the global mean and local strength, so as to re-decode until the decoding is successful.

[0103] In a specific embodiment, the following steps may be used to implement reconstruction decoding:

[0104] S31. Downsampling of the center area: Divide the grayscale image evenly according to the current version grid, and take the mean value of the center area of ​​each grid as the representative, so that it can be compatible with the "dot matrix" method.

[0105] S32, binarization operation: In the obtained grayscale image, the maximum and minimum grayscale values ​​are extracted. For embodiments with uniform illumination, the average of the two maximum values ​​can be used as the global threshold for binarization; for embodiments with uneven illumination, a sliding window dynamic threshold is used for binarization to obtain initial reconstructed data.

[0106] S33, first decoding: Set the three 8*8 areas of the return corner to fixed patterns, and then use the standard process to decode. If successful, end here, otherwise continue.

[0107] S34. Secondary decoding: In the reconstructed image, the center point that satisfies the following conditions: "the four 3*3 neighborhoods are white and the number of grayscale values ​​higher than the center point is greater than two" is changed from white to black, and then decoding is attempted using the measures of step S33.

[0108] S35, three-step decoding: In the reconstructed image, the center point that satisfies "the number of 3*3 neighborhoods that are black and whose grayscale values ​​are lower than the center point is greater than two" is changed from black to white, and then the measures of step S33 are adopted to attempt decoding.

[0109] S36, four-step decoding: In the reconstructed image, the center point that meets the requirement of "lower than the median of the 3*3 eight-neighborhood by a certain amplitude" is turned from white to black, and then the measures of step S33 are adopted to try decoding.

[0110] S37, five-time decoding: In the reconstructed image, the center point that meets the requirement of "higher than the median of the 3*3 eight-neighborhood by a certain amplitude" is changed from black to white, and then the measures of step S33 are adopted to attempt decoding.

[0111] It is worth mentioning that the above-mentioned initial binarization operation can be implemented by other existing means, and the order of subsequent steps S34 to S37 can be adjusted according to actual needs. For example, the second decoding adopts step S35, the third decoding adopts step S34, etc., but the principle of successful decoding as soon as possible should be followed.

[0112] In summary, the QR code detection method, based on the target detection module of deep learning, can perform a good preliminary detection of the area where the QR code is located, eliminating the structured empirical tuning in traditional algorithms, has good universality, and can support "one image, multiple codes" from the source; then, automatic threshold edge extraction is performed on each area separately, followed by precise positioning based on the contour relationship and layout estimation; finally, the "rectified" grayscale QR image is progressively and multi-levelly reconstructed and decoded alternately, greatly improving the success rate.

[0113] This application also provides a QR code detection device. Figure 4 , the QR code detection device includes at least one processor A1, a communication bus A2, a memory A3 and at least one communication interface A4.

[0114] Processor A1 can be a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, or one or more integrated circuits for implementing the solution of the present application, such as an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0115] The communication bus A2 is used to transmit information between the above components. The communication bus A2 can be divided into address bus, data bus, control bus, etc. For the convenience of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0116] Memory A3 can be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compact disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these. Memory A3 can exist independently and be connected to processor A1 via communication bus A2. Memory A3 can also be integrated with processor A1.

[0117] Communication interface A4 uses any transceiver-like device for communicating with other devices or communication networks. Communication interface A4 includes a wired communication interface and may also include a wireless communication interface. The wired communication interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless communication interface may be a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof.

[0118] In a specific implementation, processor A1 may include one or more CPUs.

[0119] In a specific implementation, the QR code detection device may include multiple processors. Each of these processors may be a single-core processor or a multi-core processor. The processor here may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0120] In a specific implementation, as an embodiment, the QR code detection device may further include an output device A5 and an input device A6. The output device A5 communicates with the processor A1 and displays various calculation result data or information in the form of numbers, characters, images, sounds, etc. For example, the output device A5 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device A6 communicates with the processor A1 and may receive user input in a variety of ways. For example, the input device A6 may be a CCD camera for acquiring an image of the QR code, or may be a mouse, keyboard, touch screen device, or other sensing device.

[0121] In some embodiments, memory A3 is used to store program code A7 for executing the solution of the present application, and processor A1 can execute program code A7 stored in memory A3. Program code A7 can include one or more software modules, and the QR code detection device can implement the QR code detection method provided in the above embodiments through processor A1 and program code A7 in memory A3.

[0122] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.

[0123] The present application also provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a computer, the computer executes the steps of the above-mentioned QR code detection method.

[0124] The present application also provides a computer program product comprising instructions that, when executed on a computer, cause the computer to perform the steps of the aforementioned QR code detection method. Alternatively, a computer program is provided that, when executed on a computer, causes the computer to perform the steps of the aforementioned QR code detection method.

[0125] It is understandable that those skilled in the art can make equivalent substitutions or changes based on the technical solution and application concept of this application, and all these changes or substitutions should fall within the scope of protection of the claims attached to this application.

Claims

1. A QR code detection method, characterized in that: Including the steps: Preliminary detection: Detect whether there is a QR code in the image. If there is, give the preliminary detection area containing the QR code; Fine positioning: Within the preliminary detection area, determine the position, orientation, and version of the QR code, and obtain the grayscale image; Reconstruction and decoding: According to the version of the QR code, evenly divide the grayscale image into grids, convert each module in the image into a black or white point, and then perform decoding.

2. The QR code detection method according to claim 1, wherein: The step of determining the position, orientation, and version of the QR code includes: Obtain the edge image, perform contour extraction on the edge image, screen and combine according to the principle that three "hui"-shaped identification patterns form an isosceles triangle, and take the combination of the three "hui"-shaped identification patterns with the largest area as the target item. Determine the position, orientation, and version of the QR code according to the target item.

3. The QR code detection method according to claim 2, characterized in that: The step of determining the position, orientation, and version of the QR code according to the target item includes: Obtain the size of the innermost block among the three "hui"-shaped identification patterns, take the median value and calculate the size of the unit module based on this, and infer the version of the QR code according to the right-angled side length; Determine the position and orientation of the QR code according to the fact that the three "hui"-shaped identification patterns form an isosceles triangle.

4. The QR code detection method according to claim 1, wherein: The step of converting each module in the image into a black or white point and then performing decoding includes: Taking the grayscale value of the center point of each module as a representative, comprehensively determine its black and white attribution in combination with the global mean and local strength and weakness to obtain the reconstructed image.

5. The QR code detection method according to claim 4, characterized in that: The step of converting each module in the image into a black or white point and then performing decoding further includes: Set multiple decoding strategies and execute the multiple decoding strategies in sequence until the decoding is successful.

6. The QR code detection method according to claim 5, characterized in that: The step of executing the multiple decoding strategies in sequence until the decoding is successful includes: First decoding: Set the three "hui"-shaped identification patterns as fixed styles in an 8*8 area respectively, and then perform decoding using the standard process; If the first decoding is successful, end the decoding; If the first decoding fails, continue with the new decoding steps.

7. The QR code detection method according to claim 6, characterized in that: The new decoding steps include one or more of the following steps: In the reconstructed image, for the center points that satisfy "the 3*3 four-neighborhood is white and the number of points with a grayscale value higher than the center point is greater than two", change from white to black, and then perform decoding using the steps of the first decoding; In the reconstructed image, for the center points that satisfy "the 3*3 four-neighborhood is black and the number of points with a grayscale value lower than the center point is greater than two", change from black to white, and then perform decoding using the steps of the first decoding; In the reconstructed image, for the center points that satisfy "lower than the value of the 3*3 eight-neighborhood by a certain amplitude", change from white to black, and then perform decoding using the steps of the first decoding; In the reconstructed image, for the center points that satisfy "higher than the value of the 3*3 eight-neighborhood by a certain amplitude", change from black to white, and then perform decoding using the steps of the first decoding.

8. A QR code detection method, characterized in that: Including a processor and a memory; the memory is used to store a computer program, and the computer program includes program instructions; the processor is used to call the computer program to implement the QR code detection method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that The computer program is stored in the storage medium, and when the computer program is executed by the processor, it implements the steps of the QR code detection method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The computer program product stores computer instructions, and when the computer instructions are executed by a processor, the steps of the QR code detection method according to any one of claims 1 to 7 are implemented.