A method and device for detecting a positioning pattern of a quick response code
By detecting the position detection pattern in the QR code, determining the starting reference point and module center coordinates, the problem of positioning graph detection errors in QR code decoding is solved, and the decoding efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202211606012.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-12-14
AI Technical Summary
In the prior art, the positioning graph detection error during the decoding process of the fast response code (QR code) results in the inability to accurately determine the coordinates of the data part module, affecting the decoding accuracy.
By detecting the grayscale image of the QR code, the edge position of the position detection pattern is obtained, the starting reference point is determined based on the position relationship indicated by the version, and the condition that the overlap area of the reference module and the position detection pattern is empty is used to accurately determine the edge point of the position diagram, and calculate the module center coordinate.
Accurate detection of QR code positioning graphics is achieved, improving decoding efficiency and accuracy.
Smart Images

Figure CN115908373B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular, to a method and device for detecting a positioning pattern of a quick response code. Background Art
[0002] A quick response (QR) code is a matrix two-dimensional code symbol. The QR code can represent various information such as Chinese characters and images, and has the characteristics of large information capacity, high reliability, low cost, and strong confidentiality and anti-counterfeiting properties.
[0003] As Figure 1 shown, the QR code includes position detection patterns, positioning patterns, and a data part, etc. Among them, the position detection pattern is composed of three nested squares with black and white alternating and different sizes. There are usually three position detection patterns, which are located at the upper left corner, upper right corner, and lower left corner of the QR code respectively, and are used to define the size and position of the QR code; the positioning pattern is composed of multiple black and white alternating modules, and the module is the smallest square area included in the QR code. There is a positioning pattern between the position detection patterns at the upper left corner and the lower left corner, and between the position detection patterns at the upper left corner and the upper right corner; the part of the QR code other than the positioning pattern and the position detection pattern is the data part, and the data part is composed of multiple modules and is used to carry information such as the text or image represented by the QR code.
[0004] In the process of decoding the QR code, first, the positioning pattern in the QR code is detected to determine the coordinates of each module in the positioning pattern, then, according to the coordinates of each module in the positioning pattern, the coordinates of each module included in the data part of the QR code are determined, and then, according to the coordinates of each module included in the data part of the QR code, the information represented by the QR code is determined, so as to realize the decoding of the QR code. Therefore, determining the coordinates of the positioning pattern plays a crucial role in the decoding process of the QR code. However, currently, when decoding the QR code, there are often problems that due to incorrect detection of the positioning pattern, the coordinates of each module included in the data part of the QR code cannot be accurately determined, thus resulting in inaccurate decoding of the QR code.
[0005] Therefore, there is an urgent need for a solution that can accurately detect the positioning pattern in the QR code. Summary of the Invention
[0006] This application provides a method and device for detecting a positioning pattern of a quick response code, which can accurately detect the positioning pattern in the quick response code and improve the subsequent decoding efficiency of the quick response code.
[0007] In a first aspect, a method for detecting a positioning pattern of a quick response code is provided, including:
[0008] Detect a first position detection pattern included in the quick response code according to the grayscale image of the quick response code to be detected;
[0009] Obtain the positions of the edges of the first position detection pattern by performing edge detection on the first position detection pattern;
[0010] Based on the positional relationship between the first position detection pattern indicated by the version of the quick response code and the first module included in the first positioning pattern, and the positions of the edges of the first position detection pattern, determine a starting reference point. The first module is the module closest to the first position detection pattern among the respective modules of the first positioning pattern. The reference module with the starting reference point as the vertex conforms to the positional relationship with the first position detection pattern. The size of the reference module is the same as that of the module, and the overlapping area between the reference module and the reference position of the first position detection pattern is empty. There is a boundary of the reference module that coincides with the edge where the reference position is located. The module is the smallest square area that constitutes the first positioning pattern;
[0011] Determine the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point;
[0012] Determine the center coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern.
[0013] In one example, determining the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point includes:
[0014] Determine a target feature region of a rectangle with the starting reference point as the vertex according to the position of the reference module. The overlapping area between the target feature region and the reference position is empty. The length of the target feature region is the sum of the lengths of two modules, and the width of the target feature region is equal to the width of the module;
[0015] If the target feature region does not contain an edge that coincides with the second position detection pattern, determine the next feature region according to the number of edge points in the target feature region. The second position detection pattern and the first position detection pattern are located at both ends of the first positioning pattern. The next feature region is located between the target feature region and the second position detection pattern. The pixel gray-scale gradient of the edge point is greater than the first threshold, and the coordinates of the edge point are the same as the coordinates of the starting reference point. The coordinates are any one of the vertical coordinate and the horizontal coordinate;
[0016] Redetermine the next feature region as the target feature region, continue to detect the edge points in the target feature region, and determine the next feature region of the target feature region again according to the number of edge points in the target feature region until the next feature region contains an edge that coincides with the second position detection pattern. In one example, determining the next feature region according to the number of edge points in the target feature region includes:
[0017] If the number of edge points in the target feature region is 1, determine the next feature region of the rectangle with the edge point as the vertex according to the position of the edge point. The relative position relationship between the edge point and the next feature region is the same as the relative position relationship between the target feature region of the rectangle with the starting reference point as the vertex and the starting reference point.
[0018] In one example, determining the next feature region according to the number of edge points in the target feature region includes:
[0019] If the number of edge points in the target feature region is greater than 1 or equal to 0, determine the next feature region according to the positions of the edge points that have already been the vertices of the feature region.
[0020] In one example, determining the central coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern includes:
[0021] Based on the edge points corresponding to each target feature region, determine the target edge point corresponding to each target feature region;
[0022] According to the target edge point corresponding to each target feature region, determine the central coordinates of the corresponding module in the first positioning pattern.
[0023] In one example, based on the edge points corresponding to each target feature region, determining the target edge point corresponding to each target feature region includes:
[0024] Traverse each target feature region. During each traversal:
[0025] If the target feature region includes one edge point, determine the edge point as the target edge point;
[0026] If the target feature region includes multiple edge points, determine the target edge point corresponding to the target feature region according to the position of each edge point among the multiple edge points and the position of the previous target edge point;
[0027] If the number of edge points included in the target feature region is zero, determine the target edge point corresponding to the target feature region according to the position of the previous target edge point.
[0028] In one example, determining the target edge point corresponding to the target feature region according to the position of each edge point among the multiple edge points and the position of the previous target edge point includes:
[0029] Traverse each edge point among the multiple edge points. During each traversal:
[0030] Determine the distance between the position of the edge point and the position of the previous target edge point;
[0031] Determine whether the difference between the determined distance and the module length is less than a first threshold;
[0032] If so, determine the edge point as a candidate edge point;
[0033] After traversing each edge point among multiple edge points, determine the target edge point corresponding to the target feature region according to the number of candidate edge points among the multiple edge points.
[0034] In one example, determining the target edge point corresponding to the target feature region according to the number of candidate edge points among the multiple edge points includes:
[0035] If the number of candidate edge points among the multiple edge points is 1, determine the candidate edge point as the target edge point corresponding to the target feature region;
[0036] If the number of candidate edge points among the multiple edge points is greater than 1, determine the edge point with the largest gray-level gradient among the candidate edge points as the target edge point corresponding to the target feature region.
[0037] In one example, determining the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point includes:
[0038] Determine the region of the first positioning pattern according to the position of the reference module and the position of the starting reference point, and detect the edge points in the region of the first positioning pattern by means of gray-level projection.
[0039] In a second aspect, there is provided a positioning pattern detection device for a quick response code, including:
[0040] A position detection pattern acquisition module, configured to detect a first position detection pattern included in the quick response code according to the gray-scale image of the quick response code to be detected;
[0041] An edge detection module, configured to obtain the positions of the edges of the first position detection pattern by performing edge detection on the first position detection pattern;
[0042] The starting reference point determination module is configured to determine a starting reference point based on the positional relationship between the first position detection pattern indicated by the version of the quick response code and the first module included in the first positioning pattern, and the position of the edge of the first position detection pattern. The first module is the module closest to the first position detection pattern among the respective modules of the first positioning pattern. A reference module with the starting reference point as the vertex conforms to the positional relationship with the first position detection pattern. The size of the reference module is the same as that of the module, and the overlapping area between the reference module and the reference position of the first position detection pattern is empty. There is an edge of the reference module that coincides with the edge where the reference position is located. The module is the smallest square area that constitutes the first positioning pattern. The edge point determination module is configured to determine the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point. The positioning pattern determination module is configured to determine the central coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern.
[0043] As can be seen from the above embodiments, after obtaining the quick response code to be detected, the present application determines the starting reference point based on the positional relationship between the first position detection pattern indicated by the version of the quick response code and the first module included in the first positioning pattern, and the position of the edge of the first position detection pattern. Then, by stipulating that the overlapping area between the reference module with the starting reference point as the vertex and the reference position of the first position detection pattern is empty, the position of the starting reference point is uniquely and accurately determined. Further, according to the position of the reference module and the position of the starting reference point, the edge points included in the first positioning pattern can be accurately determined, so as to accurately and effectively determine the central coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern, so as to complete the accurate detection of the first positioning pattern. Brief Description of the Drawings
[0044] In order to more clearly illustrate the technical solutions of the present application, the drawings required for the embodiments will be briefly introduced below. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
[0045] Figure 1 is a quick response code provided by an exemplary embodiment of the present application;
[0046] Figure 2 is a schematic flowchart of a method for detecting a positioning pattern of a quick response code provided by an exemplary embodiment of the present application;
[0047] Figure 3 is a schematic diagram of the positional relationship between a position detection pattern and a positioning pattern provided by an exemplary embodiment of the present application;
[0048] Figure 4It is a schematic flowchart of another method for detecting the positioning pattern of a quick response code provided by an exemplary embodiment of the present application;
[0049] Figure 5 It is a schematic diagram of a device for detecting the positioning pattern of a quick response code provided by an exemplary embodiment of the present application. Detailed implementation manners
[0050] The embodiments of the present application will be described in detail below. The examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary only for explaining the present application and should not be construed as limiting the present application. It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other.
[0051] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application means the presence of the described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any unit and all combinations of one or more related listed items.
[0052] Figure 2 It is a schematic flowchart of a method for detecting the positioning pattern of a quick response code provided by an exemplary embodiment of the present application. This embodiment can be applied to an electronic device, such as Figure 2 As shown, a method for detecting the positioning pattern of a quick response code includes the following steps:
[0053] S110, detecting a first position detection pattern included in the quick response code according to the grayscale image of the quick response code to be detected.
[0054] It should be understood that the first position detection pattern may be any one of the position detection patterns included in the quick response code.
[0055] S120, obtaining the positions of the edges of the first position detection pattern by performing edge detection on the first position detection pattern.
[0056] The position of the edge of the first position detection pattern can be represented by the horizontal and vertical coordinates of any point on the edge of the first position detection pattern. For example, as Figure 3 shown, the position of the edge of the first position detection pattern includes the positions of the edges where each dot is located. For example, the horizontal coordinate x1 of point A in the horizontal direction is the horizontal coordinate of the edge where point A is located, and the vertical coordinate y1 of point B in the vertical direction is the vertical coordinate of the edge where point B is located.
[0057] It should be noted that the edge in this application refers to the edge composed of edge points whose gray level gradient exceeds a preset threshold. For example Figure 3 the edge where point E is located in that separates the black area and the white area. The gray level gradients of the pixel points on both sides of the edge are greater than the preset threshold. The edge points in this application can be pixel points located at the edge in the black area or pixel points located at the edge in the white area.
[0058] S130. Determine the positions of the starting reference point and the reference module.
[0059] Specifically, based on the positional relationship between the first position detection pattern indicated by the version indication of the QR code and the first module included in the first positioning pattern, and the positions of the respective edges of the first position detection pattern, determine the starting reference point. The first module is the module closest to the first position detection pattern among the respective modules of the first positioning pattern. The reference module with the starting reference point as the vertex conforms to the positional relationship with the first position detection pattern. The size of the reference module is the same as that of the module, and the overlapping area between the reference module and the reference position of the first position detection pattern is empty. There is a boundary of the reference module that coincides with the edge where the reference position is located. The module is the smallest square area that constitutes the first positioning pattern.
[0060] The QR code may include multiple versions, and different version information may respectively specify the positional relationship between the first position detection pattern and the first module included in the first positioning pattern. Exemplarily, as Figure 1 and Figure 3 shown, the positional relationship between the first position detection pattern indicated by the version of the QR code and the first module included in the first positioning pattern is: if the first positioning pattern is a horizontal positioning pattern, the upper edge of the first module is located on the extension line of the edge where point B is located, and the lower edge of the first module is located on the extension line of the edge where point D is located; if the first positioning pattern is a vertical positioning pattern, the left edge of the first module is located on the extension line of the edge where point C is located, and the right edge of the first module is located on the extension line of the edge where point A is located.
[0061] Further, if the first positioning pattern is a horizontal positioning pattern, the reference position is the position of the edge where point A is located; if the first positioning pattern is a vertical positioning pattern, the reference position is the position of the edge where point E is located.
[0062] The reference module with the starting reference point as the vertex conforms to the above position relationship with the first position detection pattern. Considering that the reference module based on the above position relationship may have an overlapping area with the reference position, the application can uniquely determine the position of the starting reference point by defining the overlapping area between the reference module and the reference position of the first position detection pattern as empty.
[0063] It should be understood that the reference module is the area used to uniquely define the starting reference point. Although the position of the reference module is the same as that of the first module, the reference module should not be understood as the first module.
[0064] Among them, based on the position relationship between the first position detection pattern based on the version indication of the quick response code and the first module included in the first positioning pattern, and the positions of the edges of the first position detection pattern, the specific method for determining the starting reference point is as follows: If the first positioning pattern is a horizontally positioned pattern, the horizontal coordinate of the starting reference point is the horizontal coordinate x1 of point A, and the vertical coordinate of the starting reference point is the vertical coordinate of point B. If the first positioning pattern is a vertically positioned pattern, the horizontal coordinate of the starting reference point is the horizontal coordinate x2 of point C, and the vertical coordinate of the starting reference point is the vertical coordinate y2 of point E.
[0065] S140. Determine the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point.
[0066] In one example, S140 includes the following steps:
[0067] S141. Determine the target feature area of the rectangle with the starting reference point as the vertex according to the position of the reference module. The overlapping area between the target feature area and the reference position is empty. The length of the target feature area is the sum of the lengths of the two modules, and the width of the target feature area is equal to the width of the module.
[0068] S142. If the target feature area does not contain the edge overlapping with the second position detection pattern, determine the next feature area according to the number of edge points in the target feature area. The second position detection pattern and the first position detection pattern are located at both ends of the first positioning pattern. The next feature area is located between the target feature area and the second position detection pattern. The pixel gray gradient corresponding to the edge point is greater than the first threshold, and the coordinates of the edge point are the same as the coordinates of the starting reference point, and the coordinates are either the vertical coordinate or the horizontal coordinate.
[0069] It should be understood that if the first positioning pattern is a horizontally positioned pattern, the vertical coordinate of the edge point is the same as the vertical coordinate of the starting reference point. If the first positioning pattern is a vertically positioned pattern, the horizontal coordinate of the edge point is the same as the horizontal coordinate of the starting reference point.
[0070] It should be understood that the edge points of the feature region detected in this application do not include the pixel points on the edge of the region itself.
[0071] It should be noted that for the convenience of calculation, if the first positioning pattern is a horizontally positioned pattern, the edge points with the same horizontal coordinates are counted as one edge point; if the first positioning pattern is a vertically positioned pattern, the edge points with the same vertical coordinates are counted as one edge point.
[0072] S143. Re - determine the next feature region as the target feature region, continue to detect the edge points in the target feature region, and re - determine the next feature region of the target feature region according to the number of edge points in the target feature region until the next feature region contains the edge that coincides with the second position detection pattern.
[0073] In one example, determining the next feature region according to the number of edge points in the target feature region includes:
[0074] If the number of edge points in the target feature region is 1, according to the position of the edge point, determine the next feature region of the rectangle with the edge point as the vertex, and the relative position relationship between the edge point and the next feature region is the same as the relative position relationship between the target feature region of the rectangle with the starting reference point as the vertex and the starting reference point.
[0075] In the above - mentioned method, the number of edge points in the target feature region being 1 indicates that the module boundary included in this target feature region is relatively clear, and the next feature region can be accurately determined with this edge point as the vertex.
[0076] If the number of edge points in the target feature region is greater than 1 or equal to 0, determine the next feature region according to the positions of the edge points that have already been used as the vertices of the feature region.
[0077] For example, first determine the index of the module of the positioning pattern where the edge points that have already been used as the vertices of the feature region are located, then determine the index of the module of the positioning pattern corresponding to the next feature region, and then calculate the difference c between these two indices. According to this difference, the length length of the module, and the edge point (x1, y1) that has already been used as the vertex, determine the vertex (x2, y2) corresponding to the next feature region, as shown in the following formula:
[0078] x2 = x1 + c * length Formula (1)
[0079] y2 = y1 Formula (2)
[0080] It should be understood that the edge point is located on the edge between two modules, and the index of the module corresponding to the edge point can be defined as the index value of the module with the smallest index among the two modules.
[0081] When actually recognizing a QR code, due to noise, module defects, or other factors, there may be multiple edge points detected in the feature region. Or, due to factors such as a dirty QR code, overprinting, or blurred imaging, no edge points may be detected in the feature region. However, the edge points that have been used as the vertices of the feature region are accurate. Therefore, based on the edge points that have been used as the vertices of the feature region, the next feature region can be accurately determined.
[0082] Exemplarily, as Figure 4 shown, S142 and S143 further include:
[0083] S1421, determine whether the target feature region contains an edge that coincides with the second position detection pattern. If so, execute S1422; if not, execute S1423.
[0084] In one example, determining whether the target feature region contains an edge that coincides with the second position detection pattern includes:
[0085] Determine the index of the current target feature region, which is used to represent the number of target feature regions that have been detected in the first positioning pattern;
[0086] Based on the index of the current target feature region and the number of modules in the first positioning pattern, determine whether all the target feature regions in the first positioning pattern have been traversed.
[0087] S1422, detect the edge points in the target feature region, and the program ends.
[0088] S1423, determine the next feature region based on the number of edge points in the target feature region, detect the edge points of the next feature region, use the next feature region as the target feature region, and execute S1421.
[0089] In the above method, setting the length of the target feature region to the sum of the lengths of two modules and setting the width of the target feature region to the width of the module can make the target feature region include the positions where the edges between adjacent modules are located. By iteratively determining each target feature region in the positioning pattern and detecting the edge points of each target feature region, the noise interference in the regions other than the target feature regions for detecting edge points can be excluded, and the edge points between the modules can be accurately determined.
[0090] In one example, S140 further includes:
[0091] S144, based on the position of the reference module and the position of the starting reference point, determine the regional position of the first positioning pattern, and detect the edge points of the region of the first positioning pattern by means of gray projection.
[0092] In this solution, by means of gray projection, the edge points between all modules of the first positioning pattern are detected simultaneously. Compared with the above method of iteratively determining the edge points of the target feature region, the efficiency of detecting edge points can be improved.
[0093] S150. Determine the center coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern.
[0094] In one example, according to the embodiments in S141 to S143, determining the center coordinates of each module in the first positioning pattern includes:
[0095] Based on the edge points corresponding to each target feature region, determine the target edge points corresponding to each target feature region;
[0096] According to the target edge points corresponding to each target feature region, determine the center coordinates of the corresponding module in the first positioning pattern.
[0097] Exemplarily, according to the position coordinates of adjacent target edge points, determine the center point coordinates of the module of the positioning pattern between each adjacent pair of target edge points.
[0098] In the positioning pattern in the horizontal direction, the center between the horizontal coordinates of two adjacent target edge points is the horizontal coordinate of the center point coordinates of the module between them. The vertical coordinate of the center point coordinates of the module between two adjacent target edge points can be determined according to the position of the edge of the corresponding position detection pattern. For example, the vertical coordinate of the midpoint between the line segment formed by points B and D shown in FIG. 3 is the vertical coordinate of the center point coordinates of the module of this horizontal direction positioning pattern.
[0099] In the positioning pattern in the vertical direction, the center between the vertical coordinates of two adjacent target edge points is the vertical coordinate of the center point coordinates of the module between them. The horizontal coordinate of the center point coordinates of the module between two adjacent target edge points can be determined according to the position of the edge of the corresponding position detection pattern. For example, the horizontal coordinate of the midpoint between the line segment formed by points A and C shown in FIG. 3 is the horizontal coordinate of the center point coordinates of the module of this vertical direction positioning pattern.
[0100] Through the position coordinates of two adjacent target edge points, the center point coordinates of the module between them can be accurately and quickly determined, thereby realizing the recognition of the entire positioning pattern.
[0101] In one example, according to the embodiment in S144, determining the center coordinates of each module in the first positioning pattern includes:
[0102] Determine each target feature region according to the position of the reference module and the position of the starting reference point. Based on the edge points corresponding to each target feature region, determine the target edge points corresponding to each target feature region. According to the target edge points corresponding to each target feature region, determine the center coordinates of the corresponding module in the first positioning pattern. Among them, for the method of determining each target feature region according to the position of the reference module and the position of the starting reference point, refer to the embodiments in S141 to S143, which will not be elaborated herein.
[0103] In one example, based on the edge points corresponding to each target feature region, determining the target edge points corresponding to each target feature region includes:
[0104] Traverse each target feature region. In each traversal process:
[0105] If the target feature region includes one edge point, determine the edge point as the target edge point;
[0106] If the target feature region includes multiple edge points, determine the target edge point corresponding to the target feature region according to the position of each edge point among the multiple edge points and the position of the previous target edge point;
[0107] If the number of edge points included in the target feature region is zero, determine the target edge point corresponding to the target feature region according to the position of the previous target edge point.
[0108] In the above method, if the target feature region includes one edge point, it means that the edge of the module included in the target feature region is relatively clear, and this one edge point can be determined as the target edge point. If the target feature region includes multiple edge points or no edge points are detected, it means that the edge of the module included in the target feature region is severely interfered. Since the previous target edge point is accurate, the target edge point of the target feature region can be accurately detected by combining the previous edge point.
[0109] In one example, according to the position of each edge point among the multiple edge points and the position of the previous target edge point, determining the target edge point corresponding to the target feature region includes:
[0110] Traverse each edge point among the multiple edge points. In each traversal process:
[0111] Determine the distance between the position of the edge point and the position of the previous target edge point;
[0112] Determine whether the difference between the distance and the module length is less than the first threshold;
[0113] If so, determine the edge point as a candidate edge point;
[0114] After traversing each edge point among multiple edge points, the target edge point corresponding to the target feature region is determined according to the number of candidate edge points among the multiple edge points.
[0115] Among them, the first threshold can be set as needed, and the present application does not limit this.
[0116] In the above method, according to whether the difference between the distance between the edge point and the previous target edge point and the module length is less than the first threshold, the edge points that meet the above conditions are screened out from the multiple edge points and used as candidate edge points. According to the number of candidate edge points among the multiple edge points, the target edge point corresponding to the target feature region can be further accurately determined.
[0117] In one example, determining the target edge point corresponding to the target feature region according to the number of candidate edge points among the multiple edge points includes:
[0118] If the number of candidate edge points among the multiple edge points is 1, determine the candidate edge point as the target edge point corresponding to the target feature region;
[0119] If the number of candidate edge points among the multiple edge points is greater than 1, determine the edge point with the largest gray-level gradient among the candidate edge points as the target edge point corresponding to the target feature region.
[0120] The largest gray-level gradient of the edge point indicates that the gray-level change on both sides of this edge point is the most intense (this edge point can be a pixel point where the black area is located at the edge, or a pixel point where the white area is located at the edge). In the above method, if there are multiple candidate edge points that meet the conditions, the edge point with the largest gray-level gradient is screened out as the target edge point, further improving the accuracy of determining the target edge point.
[0121] In one example, if the number of edge points included in the target feature region is zero, the method for determining the target edge point corresponding to the target feature region according to the position of the previous target edge point includes:
[0122] If the number of edge points included in the target feature region is zero, the sum of the horizontal coordinate of the previous target edge point and the length of the module is determined as the horizontal coordinate of the target edge point, and the vertical coordinate of the previous target edge point is determined as the vertical coordinate of the target edge point.
[0123] By adopting the above method, for the case where no edge point is detected in a certain feature region, edge point supplementation needs to be performed according to the above method, so as to determine the target edge point of this feature region as accurately as possible, facilitating the subsequent positioning of the module related to this target edge point.
[0124] As can be seen from the above embodiments, the present application determines a starting reference point based on the positional relationship between the first position detection pattern of the version indication of the quick response code and the first module included in the first positioning pattern, and the position of the edge of the first position detection pattern. The present application uniquely and accurately determines the position of the starting reference point by stipulating that the overlapping area between the reference module with the starting reference point as the vertex and the reference position of the first position detection pattern is empty. Further, based on the position of the reference module and the position of the starting reference point, the edge points included in the first positioning pattern can be accurately determined, so as to accurately determine the center coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern, so as to complete the accurate detection of the first positioning pattern.
[0125] Combined with the above method for detecting the positioning pattern of the quick response code, as Figure 5 shown, the present application also provides a device for detecting the positioning pattern of the quick response code, including:
[0126] A position detection pattern acquisition module 210, configured to detect a first position detection pattern included in the quick response code according to the grayscale image of the quick response code to be detected;
[0127] An edge detection module 220, configured to obtain the position of the edge of the first position detection pattern by performing edge detection on the first position detection pattern;
[0128] A starting reference point determination module 230, configured to determine a starting reference point based on the positional relationship between the first position detection pattern of the version indication of the quick response code and the first module included in the first positioning pattern, and the position of the edge of the first position detection pattern. The first module is the module closest to the first position detection pattern among the various modules of the first positioning pattern. The reference module with the starting reference point as the vertex conforms to the positional relationship with the first position detection pattern. The size of the reference module is the same as that of the module, and the overlapping area between the reference module and the reference position of the first position detection pattern is empty. There is an edge of the reference module that coincides with the edge where the reference position is located. The module is the smallest square area constituting the first positioning pattern;
[0129] An edge point determination module 240, configured to determine the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point;
[0130] A positioning pattern determination module 250, configured to determine the center coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern.
[0131] For other implementation manners and corresponding effects, refer to the embodiments of the method for detecting the positioning pattern of the quick response code above, and details are not described herein again.
[0132] The basic principles of the present application have been described in conjunction with specific embodiments. However, it should be noted that the advantages, benefits, effects, etc. mentioned in the present application are only examples and not limitations. It cannot be considered that these advantages, benefits, effects, etc. are essential for each embodiment of the present application. Additionally, the specific details disclosed above are only for illustrative and facilitating understanding purposes, rather than limitations. These details do not limit the present application to necessarily adopt the above specific details for implementation.
[0133] It should be understood that although the steps in the flowchart of the accompanying drawings are shown sequentially in the direction of the arrows, these steps are not necessarily executed sequentially in the direction of the arrows. Unless there is a clear indication in this document, the execution of these steps is not strictly limited in order, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.
[0134] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present application are only illustrative examples and do not intend to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open-ended terms, meaning "including but not limited to", and can be used interchangeably with each other. The word "or" and "and" used herein refer to the word "and / or", and can be used interchangeably with each other, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to", and can be used interchangeably with each other.
[0135] It also should be noted that in the devices, equipment, and methods of the present application, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present application.
[0136] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present application. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
[0137] The foregoing description has been presented for purposes of illustration and description. In addition, this description is not intended to limit embodiments of the present application to the forms disclosed herein. Although several example aspects and embodiments have been discussed above, those skilled in the art will recognize some of their variations, modifications, alterations, additions, and subcombinations.
Claims
1. A method for detecting a positioning pattern of a quick response code, characterized in that, Including: Detecting a first position detection pattern included in the quick response code according to a grayscale image of the quick response code to be detected; Obtaining positions of edges of the first position detection pattern by performing edge detection on the first position detection pattern; Determining a starting reference point based on a positional relationship between the first position detection pattern indicated by a version of the quick response code and a first module included in a first positioning pattern, and positions of edges of the first position detection pattern, where the first module is the module closest to the first position detection pattern among each module of the first positioning pattern, a reference module with the starting reference point as a vertex conforms to the positional relationship with the first position detection pattern, a size of the reference module is the same as that of the module, and a coincidence area between the reference module and a reference position of the first position detection pattern is empty, and there is a boundary of the reference module that coincides with an edge where the reference position is located, and the module is the smallest square area constituting the first positioning pattern; Determining edge points included in the first positioning pattern according to positions of the reference module and the starting reference point, where determining the edge points included in the first positioning pattern according to positions of the reference module and the starting reference point includes: Determining a target feature area of a rectangle with the starting reference point as a vertex according to the position of the reference module, where the coincidence area between the target feature area and the reference position is empty, a length of the target feature area is a sum of lengths of two modules, and a width of the target feature area is equal to a width of the module; If the target feature area does not include an edge that coincides with a second position detection pattern, determining a next feature area according to a number of edge points in the target feature area, where the second position detection pattern and the first position detection pattern are located at two ends of the first positioning pattern, the next feature area is located between the target feature area and the second position detection pattern, a pixel gray-scale gradient of the edge point is greater than a first threshold, and coordinates of the edge point are the same as coordinates of the starting reference point, and the coordinates are any one of vertical coordinates and horizontal coordinates; Redetermining the next feature area as the target feature area, continuously detecting edge points in the target feature area, and determining a next feature area of the target feature area again according to the number of the edge points in the target feature area until the next feature area includes an edge that coincides with the second position detection pattern; Determining center coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern.
2. The method according to claim 1, wherein The determining the next feature area according to the number of edge points in the target feature area includes: If the number of edge points in the target feature region is 1, determine the next feature region of the rectangle with the edge point as the vertex according to the position of the edge point. The relative position relationship between the edge point and the next feature region is the same as the relative position relationship between the target feature region of the rectangle with the starting reference point as the vertex and the starting reference point.
3. The method according to claim 1, wherein The determining of the next feature region according to the number of edge points in the target feature region includes: If the number of edge points in the target feature region is greater than 1 or equal to 0, determine the next feature region according to the positions of the edge points that have already been the vertices of the feature region.
4. The method according to claim 1, characterized in that, The determining of the central coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern includes: Based on the edge points corresponding to each target feature region, determine the target edge point corresponding to each target feature region; According to the target edge point corresponding to each target feature region, determine the central coordinates of the corresponding module in the first positioning pattern.
5. The method according to claim 4, wherein The determining of the target edge point corresponding to each target feature region based on the edge points corresponding to each target feature region includes: Traverse each target feature region. In each traversal process: If the target feature region includes one edge point, determine the edge point as the target edge point; If the target feature region includes multiple edge points, determine the target edge point corresponding to the target feature region according to the positions of each edge point among the multiple edge points and the position of the previous target edge point; If the number of edge points included in the target feature region is zero, determine the target edge point corresponding to the target feature region according to the position of the previous target edge point.
6. The method according to claim 5, characterized in that, The determining of the target edge point corresponding to the target feature region according to the positions of each edge point among the multiple edge points and the position of the previous target edge point includes: Traverse each edge point among the multiple edge points. In each traversal process: Determine the distance between the position of the edge point and the position of the previous target edge point; Determine whether the difference between the distance and the module length is less than the first threshold; If so, determine the edge point as a candidate edge point; After traversing each edge point among the multiple edge points, determine the target edge point corresponding to the target feature region according to the number of candidate edge points among the multiple edge points.
7. The method according to claim 6, wherein The determining of the target edge point corresponding to the target feature region according to the number of candidate edge points among the multiple edge points includes: If the number of candidate edge points among the multiple edge points is 1, determine the candidate edge point as the target edge point corresponding to the target feature region; If the number of candidate edge points among the multiple edge points is greater than 1, determine the edge point with the largest gray-level gradient among the candidate edge points as the target edge point corresponding to the target feature region.
8. The method according to claim 1, characterized in that The determining of the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point includes: Determine the area of the first positioning pattern based on the position of the reference module and the position of the starting reference point, and detect the edge points in the area of the first positioning pattern by means of gray projection.
9. A positioning graphic detection device for a quick response code, characterized in that Including: A position detection pattern acquisition module, configured to detect a first position detection pattern included in the quick response code according to a gray image of the quick response code to be detected; An edge detection module, configured to obtain the position of the edge of the first position detection pattern by performing edge detection on the first position detection pattern; A starting reference point determination module, configured to determine a starting reference point based on the positional relationship between the first position detection pattern indicated by the version of the quick response code and a first module included in the first positioning pattern, and the position of the edge of the first position detection pattern, where the first module is the module closest to the first position detection pattern among the respective modules of the first positioning pattern, a reference module with the starting reference point as a vertex conforms to the positional relationship with the first position detection pattern, the size of the reference module is the same as that of the module, and the overlapping area between the reference module and the reference position of the first position detection pattern is empty, and there is an edge of the reference module that coincides with the edge where the reference position is located, and the module is the smallest square area constituting the first positioning pattern; An edge point determination module, configured to determine the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point, where determining the edge points included in the first positioning pattern according to the position of the reference module and the position of the starting reference point includes: Determine a target feature area of a rectangle with the starting reference point as a vertex according to the position of the reference module, the overlapping area between the target feature area and the reference position is empty, the length of the target feature area is the sum of the lengths of two modules, and the width of the target feature area is equal to the width of the module; If the target feature area does not contain an edge that coincides with the second position detection pattern, determine the next feature area according to the number of edge points in the target feature area, the second position detection pattern and the first position detection pattern are located at both ends of the first positioning pattern, the next feature area is located between the target feature area and the second position detection pattern, the pixel gray gradient of the edge point is greater than a first threshold, and the coordinates of the edge point are the same as the coordinates of the starting reference point, and the coordinates are any one of the vertical coordinate and the horizontal coordinate; Redetermine the next feature area as the target feature area, continue to detect the edge points in the target feature area, and determine the next feature area of the target feature area again according to the number of the edge points in the target feature area until the next feature area contains an edge that coincides with the second position detection pattern; A positioning pattern determination module, configured to determine the central coordinates of each module in the first positioning pattern according to the edge points included in the first positioning pattern.
Citation Information
Patent Citations
QR code positioning method and device and computer readable medium
CN113139400A
QR code recognition method and apparatus, QR code generation method and apparatus, QR code and trolley
WO2020220388A1