Two-dimensional code positioning method and device, terminal equipment and storage medium
By identifying and filtering potential locators in QR codes under multiple scanning directions, and using the positional relationships of known locators to deduce the location of damaged locators, the problem of accurately locating some damaged locators in QR code images is solved, improving the recognition success rate and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUNLUX IOT TECHNOLOGY (GUANGDONG) INC
- Filing Date
- 2025-12-10
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies struggle to accurately locate locators within QR code images, especially when one locator is completely damaged, another is partially damaged, or only one locator remains intact, making accurate QR code recognition impossible.
By identifying potential locators in multiple preset scanning directions, the first locator that meets the locator composition elements in all directions is selected. The position of the damaged locator is calculated by using the relative positional relationship between this locator and other locators, and the three-point configuration of the QR code is restored.
It significantly improves the recognition success rate and robustness of QR codes under complex conditions, and can achieve accurate positioning even when one locator is completely damaged or another locator is partially damaged.
Smart Images

Figure CN121920391A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of QR code recognition, and in particular to a QR code positioning method, apparatus, terminal device and storage medium. Background Technology
[0002] QR code recognition typically involves steps such as image acquisition, localization, sampling, and decoding, with localization being the prerequisite and foundation of the entire recognition process. QR codes use three fixed-structure finder patterns to determine their position, orientation, and scale information within an image. Only when these three finder patterns are accurately located can subsequent grid sampling, error correction, and decoding processes be completed within the correct area. Therefore, the accuracy of localization directly determines whether a QR code can be successfully recognized.
[0003] Most existing QR code location methods determine the size of the QR code image by identifying at least two complete locators, and then infer the location of the other damaged locator based on the two complete locators. Alternatively, they can achieve location based on a complete locator combined with several correction symbols. However, when faced with a QR code image lacking correction symbols, and one locator being completely damaged, another partially damaged, and only one complete locator, it becomes difficult to identify the partially damaged locator using the same methods as identifying the complete locator. Therefore, it is impossible to deduce the locations of the other two damaged locators from a single complete locator.
[0004] Therefore, when faced with a QR code image that lacks a calibration symbol, has one locator completely damaged, one locator partially damaged, and only has one complete locator, accurately locating the QR code becomes a technical problem that needs to be solved. Summary of the Invention
[0005] This application provides a QR code positioning method, apparatus, terminal device, and storage medium, which can solve the problem in the prior art of how to accurately locate a QR code when there is no correction symbol in the QR code image, and one locator is completely damaged, one locator is partially damaged, or there is only one complete locator.
[0006] Some embodiments of this application provide a QR code positioning method, including: Scan the QR code image to be recognized from multiple preset first scanning directions to identify all potential locators in the QR code image; wherein, the potential locator is a local area in which preset locator components can be identified in at least one of the first scanning directions; When the number of potential locators is at least two, a first locator is selected from all the potential locators; wherein the first locator can identify the locator components in each of the first scanning directions; When the number of the first locator is one, multiple second scanning directions are determined based on the first locator. The potential locator located in the second scanning direction of the first locator is used as the second locator, and the QR code is located based on the first locator and the second locator.
[0007] Compared to existing technologies, the above embodiments have the following advantages: By identifying potential locators in multiple first scanning directions and selecting the first locator that satisfies the locator components in all scanning directions, the system can reliably obtain a unique and complete locator (i.e., the first locator) as a positioning reference even when a portion of the QR code is damaged or contains noise. Furthermore, after determining the complete locator, the relative positional relationship between the complete locator and the second locator allows us to know that the other two locators must be located in multiple second scanning directions of the complete locator. Further, by combining the locator components possessed by the second locator, the partially damaged second locator can be accurately calculated. Finally, based on the fixed geometric structure of the QR code locator and the two locators in known positions, the theoretical position of the completely damaged locator can be calculated, thereby restoring the correct three-point configuration of the QR code. Therefore, this application can still achieve accurate positioning of the QR code even in extreme scenarios where one locator is completely damaged, one locator is partially damaged, and only one locator is complete, significantly improving the recognition success rate and robustness of QR codes under complex conditions such as occlusion, damage, and folding.
[0008] Furthermore, the first scanning direction is the scanning direction in which the constituent elements of the locator can be identified when scanning the complete locator.
[0009] Compared with the prior art, the above embodiments have the following beneficial effects: Since the first locator needs to satisfy the above features in all first scanning directions, by limiting the first scanning direction to the direction in which the components of the locator can be identified when scanning the complete locator, the accuracy of the complete locator screening is further improved, laying a reliable foundation for subsequent derivation of the scanning direction based on the unique complete locator and searching for damaged locators.
[0010] Furthermore, the locator components include: a stripe combination that conforms to a preset width ratio and the presence of at least two corner points.
[0011] Compared with the prior art, the above embodiments have the following beneficial effects: First, the locator needs to ensure that at least two corner points are not damaged in order to ensure that the geometry of the current locator has stripe combinations that meet the preset width ratio in at least one first scanning direction. Furthermore, by identifying whether there are stripe combinations that meet the preset width ratio, the partially damaged locator can be accurately located.
[0012] Furthermore, the step of scanning the QR code image to be recognized from multiple preset first scanning directions and recognizing all potential locators in the QR code image includes: The QR code image is scanned by sliding a window the size of the locator in different first scanning directions; If the vertices of the local area corresponding to the current sliding window overlap with the corner points of the local area, and a stripe combination that conforms to the preset width ratio appears in the first scanning direction, then the local area is used as the potential locator.
[0013] Compared to existing technologies, the above embodiments have the following advantages: By using a sliding window mechanism combined with multi-directional scanning to detect latent locators, the system can repeatedly verify whether local regions simultaneously satisfy the stripe ratio and corner features in different directions, significantly improving the robustness of latent locator recognition. The sliding window size is consistent with the locator structure, ensuring scale consistency in the recognition process and avoiding recognition failures due to scaling, tilting, or local noise. Simultaneously, by judging the overlap between window vertices and corners, regions lacking the geometric structure of a locator can be quickly eliminated, thereby reducing unnecessary computation and improving detection efficiency, creating a high-quality candidate set for subsequent recognition of complete locators.
[0014] When the number of the first locator is one, determining multiple second scanning directions based on the first locator includes: Starting from the first locator, the QR code image is scanned sequentially according to multiple preset third scanning directions; The third scanning direction that can scan out the components of the QR code is taken as the second scanning direction; the components of the QR code include: a number of black and white alternating rectangles.
[0015] Compared to existing technologies, the above embodiments have the following advantages: Knowing the position of the complete locator allows us to determine multiple possible third scanning directions for the QR code based on its orientation. If a locator exists along this third scanning direction, the QR code composed of alternating black and white rectangles in the center of the locator can be identified along that direction. Therefore, based on these characteristics, the positions of the other two locators can be further narrowed down from all possible third scanning directions, providing sufficient information for subsequent positioning and configuration recovery.
[0016] The third scanning direction includes: horizontal left side, horizontal right side, vertical top side, vertical bottom side, oblique top side, and oblique bottom side.
[0017] Compared with the prior art, the above embodiments have the following beneficial effects: Furthermore, by defining the third scanning direction based on the relative orientation between the three locators, it is ensured that all second scanning directions can be completely identified, thereby improving the robustness of positioning.
[0018] The step of locating the QR code based on the first locator and the second locator includes: If there is only one second locator, a third locator is determined in other second scanning directions based on the distance between the first and second locators, and the QR code is located based on the first, second, and third locators; wherein the third locator cannot identify the locator components in any of the first scanning directions. If the number of second locators is greater than one, the QR code is located based on the first locator and all the second locators.
[0019] Compared with the prior art, the above embodiments have the following beneficial effects: when there is only one second locator, the position of the completely damaged third locator can be calculated by combining another known complete locator, as well as the geometric structure and locator spacing, thereby realizing the positioning estimation of the completely damaged locator; when there are multiple second locators, the QR code positioning can be directly realized by combining another known complete locator.
[0020] Another embodiment of this application also provides a QR code positioning device, including: a first identification module, a second identification module, a scanning direction determination module, and a positioning module; The first recognition module is used to scan the QR code image to be recognized from multiple preset first scanning directions and recognize all potential locators in the QR code image; wherein, the potential locator is a local area in which preset locator components can be recognized in at least one of the first scanning directions. The second identification module is used to filter a first locator from all the potential locators when the number of potential locators is at least two; wherein the first locator can identify the locator components in each of the first scanning directions; The scanning direction determination module is used to determine multiple second scanning directions based on the first locator when the number of the first locator is one. The positioning module is used to use the potential locator located in the second scanning direction of the first locator as the second locator, and to locate the QR code based on the first locator and the second locator.
[0021] Another embodiment of this application also provides a terminal device, including: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the steps of the QR code positioning method of this application.
[0022] Another embodiment of this application also provides a computer-readable storage medium item, including: a stored computer program, which, when the computer program is running, controls the device where the computer-readable storage medium is located to perform the steps of the QR code positioning method of this application. Attached Figure Description
[0023] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0024] Figure 1 This is a flowchart illustrating a QR code positioning method provided in some embodiments of this application; Figure 2 This is a schematic diagram of a complete locator provided in some embodiments of this application; Figure 3 This is a schematic diagram of a partially damaged locator provided in some embodiments of this application; Figure 4 This is a schematic diagram of the structure of a QR code positioning device provided in some embodiments of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0027] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0028] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0029] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0030] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).
[0031] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.
[0032] Most existing QR code location methods determine the size of the QR code image by identifying at least two complete locators, and then infer the location of the other damaged locator based on the two complete locators. However, when faced with one locator completely damaged, one locator partially damaged, and only one complete locator, the partially damaged locator has missing areas. Since identifying the complete locator depends on its complete structure, it is difficult to identify the partially damaged locator using the same method as identifying the complete locator. Therefore, it is impossible to deduce the locations of the other two damaged locators from a single complete locator.
[0033] Please refer to Figure 1 To address the QR code positioning problem in existing technologies where there is no correction symbol in the QR code image, one locator is completely damaged, one locator is partially damaged, and only one complete locator exists, this application provides a QR code positioning method, including steps S101 to S104, specifically: S101: Scan the QR code image to be identified from multiple preset first scanning directions to identify all potential locators in the QR code image; wherein, the potential locator is a local area in which preset locator components can be identified in at least one of the first scanning directions.
[0034] It is understandable that, due to the damage to the QR code image, some non-locator local areas in the middle of the QR code may also contain local areas where the components of the locator can be identified. In this case, the potential locators include complete locators, partially damaged locators, and non-locators but local areas where the components of the locator can be identified. Therefore, further screening of potential locators is required.
[0035] Furthermore, in some embodiments of this application, the first scanning direction is the scanning direction in which the constituent elements of the locator can be identified when scanning the complete locator.
[0036] Preferably, in some embodiments of this application, reference is made to Figure 2 In this embodiment, the complete locator is square, and the black and white striped frame is also square. Therefore, when scanning the QR code image from both sides in the horizontal direction, both sides in the vertical direction, and both sides in the two diagonal directions, a combination of stripes with a fixed width ratio can be identified in a local area of the complete locator. Furthermore, since the complete locator includes four corner points, at least two corner points can be identified in each first scanning direction.
[0037] Since the first locator needs to satisfy inherent characteristics in all first scanning directions, by limiting the first scanning direction to the direction that can identify the components of the locator when scanning a complete locator, the accuracy of the complete locator screening is further improved, laying a reliable foundation for subsequent derivation of the scanning direction based on the unique complete locator and searching for damaged locators.
[0038] Furthermore, in some embodiments of this application, the locator components include: a stripe combination conforming to a preset width ratio and the presence of at least two corner points.
[0039] Preferably, in some embodiments of this application, the locator may be a combination of black and white stripes in a 1:1:3:1:1 ratio or a combination of stripes of other colors in other preset proportions. The embodiments of this application do not limit the stripe combination or the width ratio.
[0040] refer to Figure 3 As can be seen, even if the locator is damaged, the locator still needs to ensure that at least two corners are not damaged in order to ensure that the geometry of the current locator has stripe combinations that meet the preset width ratio in at least one first scanning direction. Furthermore, by identifying whether there are stripe combinations that meet the preset width ratio, the partially damaged locator can be accurately located.
[0041] Furthermore, in some embodiments of this application, the step of scanning the QR code image to be identified from multiple preset first scanning directions and identifying all potential locators in the QR code image includes: The QR code image is scanned by sliding a window the size of the locator in different first scanning directions; If the vertices of the local area corresponding to the current sliding window overlap with the corner points of the local area, and a stripe combination that conforms to the preset width ratio appears in the first scanning direction, then the local area is used as the potential locator.
[0042] refer to Figure 2 and Figure 3 The sliding window uses a window the same size as the locator and sequentially slides to scan the QR code image according to each of the first scanning directions. If a QR code is scanned... Figure 2 The complete locator shown can now identify the corresponding stripe combination with a preset width ratio, as well as the four corner points. If scanned... Figure 3 The partially damaged locator shown can still be identified vertically with a stripe combination of preset width ratio, as well as two corner points. However, when scanning the QR code image horizontally, due to... Figure 3The right side of the image lacks some vertical stripes, making it impossible to identify the stripe combination arranged according to the preset width ratio. Meanwhile, the four corner points of the locator can serve as key features for locating its position. Since the sliding window is already set according to the size of the locator, theoretically, if one corner point overlaps with a vertex of the sliding window, and there is a stripe combination with the preset width ratio within that area, it can be preliminarily determined that the local area likely contains a locator.
[0043] By employing a sliding window mechanism combined with multi-directional scanning to detect latent locators, the system can repeatedly verify whether local regions simultaneously satisfy both stripe proportions and corner features in different directions, significantly improving the robustness of latent locator recognition. The sliding window size is consistent with the locator structure, ensuring scale consistency in the recognition process and preventing recognition failures due to scaling, tilting, or local noise. Simultaneously, by determining the overlap between window vertices and corners, regions lacking the geometric structure of a locator can be quickly eliminated, thereby reducing unnecessary computation and improving detection efficiency, creating a high-quality candidate set for subsequent recognition of complete locators.
[0044] S102: When the number of potential locators is at least two, a first locator is selected from all the potential locators; wherein the first locator can identify the locator components in each of the first scanning directions.
[0045] Understandably, if there is only one potential locator, even if it is a complete locator, it is still impossible to deduce the other two completely damaged locators from just one complete locator, meaning that QR code location cannot be completed. Therefore, it is necessary to ensure that at least two potential locators are identified.
[0046] refer to Figure 2 As shown in the complete locator diagram, it can be understood that only when the local area is a complete locator can the locator components be identified in any first scanning direction.
[0047] S103: When the number of the first locator is one, determine multiple second scanning directions based on the first locator.
[0048] Furthermore, in some embodiments of this application, when the number of the first locator is one, determining multiple second scanning directions based on the first locator includes: Starting from the first locator, the QR code image is scanned sequentially according to multiple preset third scanning directions; The third scanning direction that can scan out the components of the QR code is taken as the second scanning direction; the components of the QR code include: a number of black and white alternating rectangles.
[0049] Furthermore, in some embodiments of this application, the third scanning direction includes: horizontal left side, horizontal right side, vertical top side, vertical bottom side, oblique top side, and oblique bottom side.
[0050] The upper oblique side includes a left upper oblique side and a right upper oblique side; the lower oblique side includes a left lower oblique side and a right lower oblique side. This application defines the third scanning direction based on the relative orientation between the three locators, ensuring that all second scanning directions can be completely identified, thus improving the robustness of positioning.
[0051] It's understandable that the placement of the three locators in the QR code image forms an isosceles right triangle. Assuming we currently know... Figure 2 The image shows the position and orientation of the complete locator in the QR code image. Scanning the QR code image along its horizontal, vertical, and two diagonal sides will inevitably identify the other partially damaged locator (the second locator). However, scanning all third scanning directions every time is inefficient. Therefore, considering the QR code characteristic between the two locators, if no QR code components are identified while scanning along a certain third scanning direction, it means there is no locator in that direction, and scanning along that direction is unnecessary, thus improving the recognition efficiency of the second locator. It is understandable that since the complete locator is located at one vertex of the QR code image, three second scanning directions can be selected from all the third scanning directions: one vertical, one horizontal, and one diagonal.
[0052] Once the location of the complete locator is known, its orientation can determine multiple possible third scanning directions for the QR code. If a locator exists along this third scanning direction, the QR code composed of alternating black and white rectangles in the center of the locator can be identified along that scanning direction. Therefore, based on the above characteristics, the locations of the other two locators can be further narrowed down from all possible third scanning directions, providing sufficient information for subsequent positioning and configuration reconstruction.
[0053] S104: The potential locator located in the second scanning direction of the first locator is used as the second locator, and the QR code is located according to the first locator and the second locator.
[0054] Furthermore, in some embodiments of this application, locating the QR code based on the first locator and the second locator includes: If there is only one second locator, a third locator is determined in other second scanning directions based on the distance between the first and second locators, and the QR code is located based on the first, second, and third locators; wherein the third locator cannot identify the locator components in any of the first scanning directions. If the number of second locators is greater than one, the QR code is located based on the first locator and all the second locators.
[0055] Since the placement of the three locators forms an isosceles right triangle, after identifying one first locator and one second locator, the location of the other completely damaged locator can be determined based on the first distance between two locators and the QR code image in the middle. At this point, only two scanning directions remain in the second scanning direction. By checking whether there is a blank local area of the same size as the locator at the first distance in the other two directions, if it exists, the location of the third locator can be determined.
[0056] When there is only one second locator, the location of the completely damaged third locator can be estimated by combining another known complete locator, the geometric structure, and the locator spacing, thus achieving the location estimation of the completely damaged locator; when there are multiple second locators, the location of the QR code can be directly achieved by combining another known complete locator.
[0057] In summary, the QR code positioning method provided in this application has the following advantages compared to existing technologies: By identifying potential locators in multiple first scanning directions and selecting the first locator that satisfies the locator composition elements in all scanning directions, the system can stably obtain a unique and complete locator (i.e., the first locator) as a positioning reference even when a portion of the QR code is damaged or contains noise. Furthermore, after determining the complete locator, the relative positional relationship between the complete locator and the second locator allows us to know that the other two locators must be located in multiple second scanning directions of the complete locator. Further, by combining the locator composition elements possessed by the second locator, the partially damaged second locator can be accurately calculated. Finally, based on the fixed geometric structure of the QR code locator and the two locators in known positions, the theoretical position of the completely damaged locator can be calculated, thereby restoring the correct three-point configuration of the QR code. Therefore, this application can still achieve accurate positioning of QR codes even in extreme scenarios where one locator is completely damaged, one locator is partially damaged, and only one locator is complete, significantly improving the recognition success rate and robustness of QR codes under complex conditions such as occlusion, dirt, and folding.
[0058] like Figure 4As shown, based on the above-described method embodiments, this application provides a QR code positioning device, including: a first identification module 201, a second identification module 202, a scanning direction determination module 203, and a positioning module 204; the first identification module 201 is used to scan a QR code image to be identified from multiple preset first scanning directions, and identify all potential locators in the QR code image; wherein, the potential locator is a local area in which preset locator components can be identified in at least one first scanning direction; the second identification module 202 is used to filter a first locator from all the potential locators when the number of potential locators is at least two; wherein, the first locator can identify the locator components in each first scanning direction; the scanning direction determination module 203 is used to determine multiple second scanning directions based on the first locator when the number of the first locator is one; the positioning module 204 is used to use the potential locator in the second scanning direction of the first locator as the second locator, and to position the QR code based on the first locator and the second locator.
[0059] Furthermore, in some embodiments of this application, the first scanning direction is the scanning direction in which the constituent elements of the locator can be identified when scanning the complete locator.
[0060] Furthermore, in some embodiments of this application, the locator components include: a stripe combination conforming to a preset width ratio and the presence of at least two corner points.
[0061] Further, in some embodiments of this application, the first identification module 201 includes: a sliding scanning unit and a first judgment unit; the first identification module 201 is used to scan the QR code image to be identified from multiple preset first scanning directions, and identify all potential locators in the QR code image, including: the sliding scanning unit is used to slide and scan the QR code image in different first scanning directions through a sliding window of size equal to the locator size; the first judgment unit is used to identify the local area as the potential locator if the vertex of the local area corresponding to the current sliding window overlaps with each corner point in the local area and a stripe combination that conforms to the preset width ratio appears in the first scanning direction.
[0062] Further, in some embodiments of this application, the scanning direction determination module 203 includes: a scanning unit and a scanning direction filtering unit; the scanning direction determination module 203 is used to determine multiple second scanning directions based on the first locator when the number of the first locator is one, including: the scanning unit is used to scan the QR code image sequentially according to multiple preset third scanning directions, starting from the first locator; the scanning direction filtering unit is used to select the third scanning direction that can scan out the QR code components as the second scanning direction; the QR code components include: a plurality of black and white alternating rectangles.
[0063] Furthermore, in some embodiments of this application, the third scanning direction includes: horizontal left side, horizontal right side, vertical top side, vertical bottom side, oblique top side, and oblique bottom side.
[0064] Further, in some embodiments of this application, the positioning module 204 includes: a first positioning unit and a second positioning unit; the positioning module 204 is used to locate the QR code according to the first positioning symbol and the second positioning symbol, including: the first positioning unit is used to determine a third positioning symbol in other second scanning directions according to the distance between the first positioning symbol and the second positioning symbol if the number of the second positioning symbol is one, and to locate the QR code according to the first positioning symbol, the second positioning symbol and the third positioning symbol; wherein, the third positioning symbol cannot identify the positioning symbol components in any of the first scanning directions; the second positioning unit is used to locate the QR code according to the first positioning symbol and all the second positioning symbols if the number of the second positioning symbols is greater than one.
[0065] In summary, the QR code positioning device provided in this application has the following advantages compared to the prior art: By identifying potential locators in multiple first scanning directions and selecting the first locator that satisfies the locator composition elements in all scanning directions, the system can stably obtain a unique and complete locator (i.e., the first locator) as a positioning reference even when a portion of the QR code is damaged or contains noise. Furthermore, after determining the complete locator, the relative positional relationship between the complete locator and the second locator allows us to know that the other two locators must be located in multiple second scanning directions of the complete locator. Further, by combining the locator composition elements possessed by the second locator, the partially damaged second locator can be accurately calculated. Finally, based on the fixed geometric structure of the QR code locator and the two locators in known positions, the theoretical position of the completely damaged locator can be calculated, thereby restoring the correct three-point configuration of the QR code. Therefore, this application can still achieve accurate positioning of QR codes even in extreme scenarios where one locator is completely damaged, one locator is partially damaged, and only one locator is complete, significantly improving the recognition success rate and robustness of QR codes under complex conditions such as occlusion, dirt, and folding.
[0066] It is understood that the above-described device embodiments correspond to the method embodiments of this application, and can implement the QR code positioning method provided by any of the above-described method embodiments of this application.
[0067] It should be noted that the device embodiments described above are merely illustrative, and some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided in this application, the connection relationships between modules indicate that they have communication connections, which can specifically be implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0068] Based on the above embodiments of the QR code positioning method, another embodiment of this application provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the QR code positioning method of any embodiment of this application.
[0069] For example, in this embodiment, the computer program can be divided into one or more modules, which are stored in the memory and executed by the processor to complete this application. The one or more module units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal device.
[0070] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0071] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device via various interfaces and lines.
[0072] Based on the above-described method embodiments, another embodiment of this application provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute the QR code positioning method described in any of the above-described method embodiments of this application.
[0073] The modules / units integrated in the device / terminal equipment, if implemented as software functional units and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
Claims
1. A QR code positioning method, characterized in that, include: Scan the QR code image to be recognized from multiple preset first scanning directions to identify all potential locators in the QR code image; wherein, the potential locator is a local area in which preset locator components can be identified in at least one of the first scanning directions; When the number of potential locators is at least two, a first locator is selected from all the potential locators; wherein the first locator can identify the locator components in each of the first scanning directions; When the number of the first locator is one, multiple second scanning directions are determined based on the first locator. The potential locator located in the second scanning direction of the first locator is used as the second locator, and the QR code is located based on the first locator and the second locator.
2. The QR code positioning method as described in claim 1, characterized in that, The first scanning direction is the scanning direction in which the constituent elements of the locator can be identified when scanning the complete locator.
3. The QR code positioning method as described in any one of claims 1 to 2, characterized in that, The locator consists of: a stripe combination that conforms to a preset width ratio and the presence of at least two corner points.
4. The QR code positioning method as described in claim 3, characterized in that, The process of scanning the QR code image to be recognized from multiple preset first scanning directions, and recognizing all potential locators in the QR code image, includes: The QR code image is scanned by sliding a window the size of the locator in different first scanning directions; If the vertices of the local area corresponding to the current sliding window overlap with the corner points of the local area, and a stripe combination that conforms to the preset width ratio appears in the first scanning direction, then the local area is used as the potential locator.
5. The QR code positioning method as described in claim 1, characterized in that, When the number of the first locator is one, determining multiple second scanning directions based on the first locator includes: Starting from the first locator, the QR code image is scanned sequentially according to multiple preset third scanning directions; The third scanning direction that can scan out the components of the QR code is taken as the second scanning direction; the components of the QR code include: a number of black and white alternating rectangles.
6. The QR code positioning method as described in claim 5, characterized in that, The third scanning direction includes: horizontal left side, horizontal right side, vertical top side, vertical bottom side, oblique top side, and oblique bottom side.
7. The QR code positioning method as described in claim 1, characterized in that, The step of locating the QR code based on the first locator and the second locator includes: If there is only one second locator, a third locator is determined in other second scanning directions based on the distance between the first and second locators, and the QR code is located based on the first, second, and third locators; wherein the third locator cannot identify the locator components in any of the first scanning directions. If the number of second locators is greater than one, the QR code is located based on the first locator and all the second locators.
8. A QR code positioning device, characterized in that, include: The system comprises a first identification module, a second identification module, a scanning direction determination module, and a positioning module; The first recognition module is used to scan the QR code image to be recognized from multiple preset first scanning directions and recognize all potential locators in the QR code image; wherein, the potential locator is a local area in which preset locator components can be recognized in at least one of the first scanning directions. The second identification module is used to filter a first locator from all the potential locators when the number of potential locators is at least two; wherein the first locator can identify the locator components in each of the first scanning directions; The scanning direction determination module is used to determine multiple second scanning directions based on the first locator when the number of the first locator is one. The positioning module is used to use the potential locator located in the second scanning direction of the first locator as the second locator, and to locate the QR code based on the first locator and the second locator.
9. A terminal device, characterized in that, The device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements a QR code positioning method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform a QR code positioning method as described in any one of claims 1 to 7.