CN117218328A - Two-dimensional code positioning method, electronic equipment and storage medium - Google Patents

Two-dimensional code positioning method, electronic equipment and storage medium Download PDF

Info

Publication number
CN117218328A
CN117218328A CN202311466381.8A CN202311466381A CN117218328A CN 117218328 A CN117218328 A CN 117218328A CN 202311466381 A CN202311466381 A CN 202311466381A CN 117218328 A CN117218328 A CN 117218328A
Authority
CN
China
Prior art keywords
line segment
positioning
dimensional code
circle
line
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311466381.8A
Other languages
Chinese (zh)
Other versions
CN117218328B (en
Inventor
陈文钊
边旭
冉东来
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Youibot Robotics Technology Co ltd
Original Assignee
Shenzhen Youibot Robotics Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Youibot Robotics Technology Co ltd filed Critical Shenzhen Youibot Robotics Technology Co ltd
Priority to CN202311466381.8A priority Critical patent/CN117218328B/en
Publication of CN117218328A publication Critical patent/CN117218328A/en
Application granted granted Critical
Publication of CN117218328B publication Critical patent/CN117218328B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Analysis (AREA)

Abstract

The application provides a two-dimensional code positioning method, electronic equipment and a computer readable storage medium. The two-dimensional code positioning method comprises the following steps: performing edge detection on the two-dimensional code image to be positioned to obtain a peripheral circle of the two-dimensional code image; detecting a preliminary positioning line segment in the peripheral circle, which accords with a first preset condition, to obtain a first line segment set of the preliminary positioning line segment, wherein the first preset condition is used for indicating the position relationship between the line segment in the circle of the peripheral circle and the peripheral circle; determining target positioning line segments meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segments, wherein the second preset condition is used for indicating the position relationship among the preliminary positioning line segments; and determining a positioning rectangle of the two-dimensional code image based on the second line segment set, wherein the positioning rectangle is used for positioning the coding region of the two-dimensional code image. The application can improve the recognition accuracy when the two-dimensional code is partially lost (such as blocked, damaged, reflected light and the like), and improve the anti-blocking capability of the two-dimensional code.

Description

Two-dimensional code positioning method, electronic equipment and storage medium
Technical Field
The application relates to the technical field of computer vision, in particular to a two-dimensional code positioning method, electronic equipment and a computer readable storage medium.
Background
With the continuous development of computer vision technology, two-dimensional codes (such as QR codes, dataMatrix codes, april tag codes, arUco codes) are applied to more and more fields, and two-dimensional codes can be divided into two-dimensional codes for storing information (such as QR codes, dataMatrix codes) and two-dimensional codes for positioning (such as april tag codes, arUco codes). Generally, a two-dimensional code is provided with a detection pattern (for example, three concentric squares of a QR code, an L-shape of a DataMatrix code, and a peripheral black frame of an ArUco code as shown by a dashed frame in fig. 7) for positioning the two-dimensional code, so as to ensure that information contained in the two-dimensional code can be identified in actual use. However, the existing two-dimensional code cannot be identified normally under the conditions of blocked, damaged and reflective detection patterns, so how to improve the identification accuracy when the two-dimensional code is partially missing (such as blocked, damaged and reflective detection patterns) is a problem to be solved.
Disclosure of Invention
The application provides a two-dimensional code positioning method, electronic equipment and a computer readable storage medium, which can improve the positioning accuracy of a detection pattern when a part of the two-dimensional code is missing (such as the detection pattern is shielded, damaged, reflected and the like), improve the recognition accuracy of the two-dimensional code and improve the shielding resistance of the two-dimensional code.
In a first aspect, the present application provides a two-dimensional code positioning method, where the method includes:
performing edge detection on a two-dimensional code image to be positioned to obtain a peripheral circle of the two-dimensional code image;
detecting a preliminary positioning line segment in the peripheral circle, which accords with a first preset condition, to obtain a first line segment set of the preliminary positioning line segment, wherein the first preset condition is used for indicating the position relationship between the line segment in the circle of the peripheral circle and the peripheral circle;
determining a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segment, wherein the second preset condition is used for indicating the position relationship among the preliminary positioning line segments;
and determining a positioning rectangle of the two-dimensional code image based on the second line segment set, wherein the positioning rectangle is used for positioning the coding region of the two-dimensional code image.
In a second aspect, the present application further provides an electronic device, where the electronic device includes a processor and a memory, where the memory stores a computer program, and when the processor invokes the computer program in the memory, any two-dimensional code positioning method provided by the present application is executed.
In a third aspect, the present application further provides a computer readable storage medium having stored thereon a computer program, the computer program being loaded by a processor to perform the two-dimensional code positioning method.
In the application, in the first aspect, the two-dimensional code is designed to comprise a peripheral circle and a positioning rectangle positioned in the peripheral circle, and the peripheral circle of the two-dimensional code image to be positioned is detected first; detecting the preliminary positioning line segments which meet the first preset condition in the peripheral circle to obtain a first line segment set, and screening out the preliminary positioning line segments as the sides of the potential positioning rectangle; then, detecting a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set, and screening out the target positioning line segment as a potential positioning rectangular side; therefore, the target positioning line segments with the inter-peripheral circle position relationship conforming to the position relationship between the peripheral circle and the edges of the positioning rectangle and the inter-line segment position relationship conforming to the inter-edge relationship of the positioning rectangle can be screened out, and the target positioning line segments are used for determining the positioning rectangle of the two-dimensional code image and realizing the positioning of the two-dimensional code.
In the second aspect, the two-dimensional code is designed to include the peripheral circle and the positioning rectangle located inside the peripheral circle, and because the positional relationship between the edges of the positioning rectangle and the peripheral circle is relatively obvious, even if the positioning rectangle is partially missing (such as blocked, damaged, reflecting, etc.), the preliminary positioning line segment in the peripheral circle conforming to the first predetermined condition is detected by utilizing the positional relationship between the straight line in the circle of the peripheral circle and the peripheral circle (i.e. utilizing the first predetermined condition), so that the preliminary positioning line segment can be screened out as the edge of the potential positioning rectangle, the recognition accuracy of the positioning rectangle is improved, and the recognition accuracy when the two-dimensional code is partially missing is further improved.
In the third aspect, since the peripheral circle can be detected even if it is incomplete (for example, the entire circle can be restored by the semicircle), the anti-blocking property of the two-dimensional code can be improved.
In the fourth aspect, because the positional relationship between the edges of the positioning rectangle is relatively obvious, even if the positioning rectangle is partially missing (such as blocked, damaged, reflected light, etc.), the target positioning line segment meeting the second predetermined condition in the first line segment set is detected by using the positional relationship between the preliminary positioning line segments (that is, using the second predetermined condition), the target positioning line segment can be screened out as the potential edge of the positioning rectangle, so that the recognition accuracy of the positioning rectangle is improved, and the recognition accuracy when the two-dimensional code is partially missing is further improved.
In the fifth aspect, because the positional relationship between the edges of the positioning rectangles is relatively obvious, even if the target positioning line segments are blocked positioning line segments (i.e., the edges of a part of the positioning rectangles are blocked), the positional relationship between each target positioning line segment in the second line segment set can be used to recover the edges of the complete positioning rectangle, thereby improving the recognition accuracy of the positioning rectangles and further improving the recognition accuracy when the two-dimensional code is partially missing.
Therefore, the embodiment of the application can improve the positioning accuracy of the detection pattern when the two-dimensional code part is missing (such as the detection pattern is blocked, damaged, reflected and the like), improve the recognition accuracy when the two-dimensional code part is missing (such as the detection pattern is blocked, damaged, reflected and the like), and improve the anti-blocking capability of the two-dimensional code.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic block diagram of an electronic device according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a two-dimensional code positioning method according to an embodiment of the present application;
fig. 3 is a schematic diagram of a two-dimensional code (including a peripheral circle and a positioning rectangle inside the peripheral circle) according to an embodiment of the present application;
FIG. 4 is a schematic illustration of two-dimensional code being blocked according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating detection of a target location thread from a peripheral circle according to an embodiment of the present application;
FIG. 6 is a schematic illustration of a second set of line segments detected under different occlusion conditions according to an embodiment of the present application;
fig. 7 is a schematic diagram illustrating a detection pattern of a conventional two-dimensional code.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to fall within the scope of the application.
The flow diagrams depicted in the figures are merely illustrative and not necessarily all of the elements and operations/steps are included or performed in the order described. For example, some operations/steps may be further divided, combined, or partially combined, so that the order of actual execution may be changed according to actual situations.
In describing embodiments of the present application, it should be understood that the terms "first," "second," and "second" are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or number of features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more of the described features. In the description of the embodiments of the present application, the meaning of "plurality" is two or more, unless explicitly defined otherwise.
The following description is presented to enable any person skilled in the art to make and use the application. In the following description, details are set forth for purposes of explanation. It will be apparent to one of ordinary skill in the art that the present application may be practiced without these specific details. In other instances, well-known processes have not been described in detail in order to avoid unnecessarily obscuring the description of the embodiments of the application. Thus, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
The embodiment of the application provides a two-dimensional code positioning method, electronic equipment and a computer readable storage medium. The electronic device may be a mobile robot, a cell phone, a computer, etc.
Some embodiments of the application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic block diagram of an electronic device according to an embodiment of the present application.
As shown in fig. 1, the electronic device 100 includes a processor 101 and a memory 102, the processor 101 and the memory 102 being connected by a bus 103, such as an I2C (Inter-integrated Circuit) bus.
In particular, the processor 101 is configured to provide computing and control capabilities to support the operation of the overall electronic device 100. The processor 101 may be a central processing unit (Central Processing Unit, CPU), the processor 101 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Specifically, the Memory 102 may be a Flash chip, a Read-Only Memory (ROM) disk, an optical disk, a U-disk, a removable hard disk, or the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 1 is merely a block diagram of a portion of the structure associated with an embodiment of the present application and is not intended to limit the electronic device to which an embodiment of the present application is applied, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or may have a different arrangement of components.
The processor 101 is configured to run a computer program stored in the memory 102, and implement any one of the two-dimensional code positioning methods provided by the embodiments of the present application when the computer program is executed. For example, the processor 101 is configured to run a computer program stored in the memory 102, and when the computer program is executed, the following steps may be implemented:
performing edge detection on a two-dimensional code image to be positioned to obtain a peripheral circle of the two-dimensional code image; detecting a preliminary positioning line segment in the peripheral circle, which accords with a first preset condition, to obtain a first line segment set of the preliminary positioning line segment, wherein the first preset condition is used for indicating the position relationship between the line segment in the circle of the peripheral circle and the peripheral circle; determining a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segment, wherein the second preset condition is used for indicating the position relationship among the preliminary positioning line segments; and determining a positioning rectangle of the two-dimensional code image based on the second line segment set, wherein the positioning rectangle is used for positioning the coding region of the two-dimensional code image.
It should be noted that, for convenience and brevity of description, specific working processes of the above-described electronic device may refer to corresponding processes in the following two-dimensional code positioning method embodiments, which are not described herein again.
In the following, the two-dimensional code positioning method provided in the embodiment of the present application will be described in detail by taking the electronic device shown in fig. 1 as an execution body of the two-dimensional code positioning method as an example, and in order to simplify and facilitate description, the execution body will be omitted in the subsequent method embodiments. It should be noted that, the scenario in fig. 1 is only used to explain the two-dimensional code positioning method provided by the embodiment of the present application, but does not form a limitation on the application scenario of the two-dimensional code positioning method provided by the embodiment of the present application.
Referring to fig. 2, fig. 2 is a flow chart of a two-dimensional code positioning method according to an embodiment of the application. The two-dimensional code positioning method comprises the following steps 201-204, wherein:
201. and carrying out edge detection on the two-dimensional code image to be positioned to obtain a peripheral circle of the two-dimensional code image.
For a better understanding of the present embodiment, the following first describes the part names related to the present embodiment:
1. target endpoints of line segments (e.g., in-circle line segment, preliminary location line segment, target location line segment): refers to the end point (such as the end point a) closest to the distance between the two end points (such as the end point a and the end point b) of the line segment and the peripheral circle. If the two endpoints of the line segment are equal to the distance between the peripheral circle, both the two endpoints of the line segment can be used as target endpoints.
2. Distance between line segments and circle (e.g., distance between line segments in circle and peripheral circle): the distance between the target end point of the line segment and the circle.
3. Distance between line segment and circle center (such as distance between line segment in circle and circle center of peripheral circle): the distance between the target end point of the line segment and the center of the circle.
As shown in fig. 3, the two-dimensional code in this embodiment includes a peripheral circle (as shown by the large circular dotted box in fig. 3) and a positioning rectangle (as shown by the rectangular dotted box in fig. 3) inside the peripheral circle. Further, the two-dimensional code may further include an inner circle (as shown by a small circular dotted frame in fig. 3) located inside the positioning rectangle, where the inner circle is used for fine tuning the center of the peripheral circle, so as to improve accuracy of the restored peripheral circle.
There are various ways to determine the peripheral circle in step 201, including, illustratively:
(1) In some embodiments, the peripheral circle of the two-dimensional code image is not blocked, and at this time, a complete arc line of the periphery of the two-dimensional code image can be completely detected by some edge detection algorithms (such as Sobel algorithm, canny algorithm, laplacian algorithm, etc.), so that the peripheral circle of the two-dimensional code image can be obtained.
(2) In some embodiments, in order to avoid the problem that the encoding area of the two-dimensional code image cannot be identified normally due to the shielding of the peripheral circle, the circular arc line (such as a semicircle) on the periphery of the two-dimensional code image may be detected by an edge detection algorithm (such as a Sobel algorithm, a Canny algorithm, a Laplacian algorithm, etc.), and then the complete circle is constructed by using the circular arc line as the peripheral circle of the two-dimensional code image.
Therefore, the two-dimensional code can normally identify the coding region of the two-dimensional code image when the two-dimensional code is shielded by adopting the peripheral circle.
202. And detecting the preliminary positioning line segments which meet a first preset condition in the peripheral circle to obtain a first line segment set of the preliminary positioning line segments.
The preliminary positioning line segment refers to a line segment in the peripheral circle, which meets a first preset condition.
The first line segment set is a set of line segments meeting a first preset condition in the peripheral circle. I.e. the first set of line segments is a set of preliminary locating line segments.
Wherein the first predetermined condition is used for indicating a positional relationship between an in-circle segment of the peripheral circle and the peripheral circle.
In order to improve the probability that the line segment in the first line segment set is the edge of the positioning rectangle, so as to reduce the line segment data processing amount required for determining the positioning rectangle, further improve the recognition accuracy and recognition rate of the positioning rectangle, in step 202, all line segments in the peripheral circle can be recognized first, and then the line segment meeting the first preset condition is added into the first line segment set of the peripheral circle as a preliminary positioning line segment.
The first predetermined condition may include at least one of a length of the line segment being greater than a preset length threshold, a distance between the line segment and the peripheral circle being less than a first preset distance threshold, and a distance between the line segment and a center of the peripheral circle being greater than a second preset distance threshold.
According to the first aspect, since the edges of the positioning rectangle are relatively longer line segments in the two-dimensional code image, the line segments which are longer than the preset length threshold value are used as the primary positioning line segments and added into the first line segment set, the line segments which obviously do not belong to the edges of the positioning rectangle can be filtered, the probability that the line segments in the first line segment set are the edges of the positioning rectangle is improved, the line segment data processing amount required by determining the positioning rectangle is reduced, and the recognition accuracy and the recognition rate of the positioning rectangle are improved.
In the second aspect, since the area occupied by the coding region is relatively large, the edge of the positioning rectangle is relatively close to the peripheral circle, and the line segment which obviously does not belong to the edge of the positioning rectangle can be filtered out by taking the line segment which is smaller than the first preset distance threshold value between the peripheral circle and the line segment as the primary positioning line segment and adding the primary positioning line segment into the first line segment set, so that the probability that the line segment in the first line segment set is the edge of the positioning rectangle is improved, the line segment data processing amount required by determining the positioning rectangle is reduced, and the recognition accuracy and the recognition rate of the positioning rectangle are improved.
In the third aspect, since the area occupied by the coding region is relatively large, the edge of the positioning rectangle is relatively far away from the center of the peripheral circle, and the line segment which is more than the second preset distance threshold from the center of the peripheral circle is taken as the primary positioning line segment and added into the first line segment set, the line segment which obviously does not belong to the edge of the positioning rectangle can be filtered out, so that the probability that the line segment in the first line segment set is the edge of the positioning rectangle is improved, the line segment data processing amount required by determining the positioning rectangle is reduced, and the recognition accuracy and recognition rate of the positioning rectangle are improved.
There are various ways of determining the first set of segments in step 202 for different settings of the first predetermined condition, including, illustratively:
(1) The first preset condition is that the length of the line segment is greater than a preset length threshold value, and the distance between the line segment and the peripheral circle is smaller than a first preset distance threshold value. At this time, in step 202, a line segment with a length greater than a preset length threshold and a distance from the peripheral circle less than a first preset distance threshold is added to the first line segment set as a preliminary positioning line segment. At this time, the step 202 may specifically include the following steps 2021a to 2024a:
2021A, detecting an in-circle segment of the peripheral circle.
Where in-circle line segments refer to line segments detected within the peripheral circle. For example, as shown in (a) of fig. 5, all the line segments detected in the peripheral circle include line segment 1, line segment 2, … line segment 9, and then line segment 1, line segment 2, …, line segment 9 are all in-circle line segments of the peripheral circle.
2022A, detecting the distance between the line segment within the circle and the peripheral circle.
The distance between the line segment in the circle and the peripheral circle refers to the distance between the target endpoint of the line segment in the circle and the peripheral circle.
The distance between the two end points of the line segment in the circle (such as the two end points of the line segment 6 in fig. 5) and the peripheral circle can be detected, and the end point closest to the peripheral circle (such as the end point g of the line segment 6 in fig. 5) is taken as the target end point of the line segment in the circle.
Illustratively, the target end point of the line segment within the circle may be detected in step 2022A, and then, the distance between the target end point of the line segment within the circle and the peripheral circle may be detected as the distance between the line segment within the circle and the peripheral circle. For example, referring to fig. 5, in fig. 5, the target end points of the line segments 1, 2, 3, 4, 5, 6, 7, 8, and 9 are a, f, and c (or a, assuming that the distance from the point a to the circle is equal to the distance from the point c to the circle), respectively, e, h, g, d, d, c, d, as shown by the line segment 6 in fig. 5, the target end point of the line segment 6 is the point g, and the distance between the target end point g of the line segment 6 and the peripheral circle is the distance between the line segment 6 and the peripheral circle.
2023A, if the length of the line segment in the circle is greater than a preset length threshold, and the distance between the line segment in the circle and the peripheral circle is less than a first preset distance threshold, using the line segment in the circle as a preliminary positioning line segment.
2024A, based on the preliminary locating line segments, obtaining a first set of line segments of the preliminary locating line segments.
For example, first, all the line segments within the peripheral circle may be detected in step 2021A, and as shown in (a) of fig. 5, each line segment detected within the peripheral circle may be an in-circle line segment of the peripheral circle. Then, in step 2022A, the distance between the target end point of the line segment in each circle and the peripheral circle may be determined as the distance between the line segment in each circle and the peripheral circle. If the length of the line segment in the circle is greater than the preset length threshold and the distance between the line segment in the circle and the peripheral circle is less than the first preset distance threshold, step 2023A is entered, and the line segment in the circle is used as a preliminary positioning line segment; otherwise, if the length of the line segment in the circle is smaller than or equal to the preset length threshold (as shown in (b) of fig. 5, the length of the line segment 5 is smaller than or equal to the preset length threshold, so the line segment 5 is not used as a preliminary positioning line segment, filtering of the line segment 5 is realized), or the distance between the line segment in the circle and the peripheral circle is larger than or equal to the first preset distance threshold (as shown in (b) of fig. 5, the distance between the line segment 2 and the peripheral circle is larger than or equal to the first preset distance threshold, so the line segment 2 is not used as a preliminary positioning line segment, filtering of the line segment 2 is realized), the line segment in the circle is filtered. By analogy, after processing is completed for all the in-circle segments of the peripheral circle according to steps 2022a to 2023a, a first segment set of preliminary positioning segments is obtained (refer to (c) in fig. 5).
(2) The first preset condition is that the length of the line segment is larger than a preset length threshold value, and the distance between the line segment and the center of the peripheral circle is larger than a second preset distance threshold value. At this time, in step 202, a line segment with a length greater than the preset length threshold and a distance greater than the second preset distance threshold from the center of the peripheral circle is added to the first line segment set as a preliminary positioning line segment. At this time, the step 202 may specifically include the following steps 2021b to 2024b:
2021B, detecting an in-circle segment of the peripheral circle.
2022B, detecting the distance between the line segment in the circle and the center of the peripheral circle.
The distance between the inner line segment of the circle and the center of the peripheral circle refers to the distance between the target endpoint of the inner line segment of the circle and the center of the peripheral circle.
Illustratively, in step 2022B, the target end point of the line segment in the circle may be detected first, and then, the distance between the target end point of the line segment in the circle and the center of the peripheral circle may be detected as the distance between the line segment in the circle and the center of the peripheral circle. For example, as shown by a line segment 6 in fig. 5, a target end point of the line segment 6 is a point g, and a distance between the target end point g of the line segment 6 and a center O of the peripheral circle is a distance between the line segment 6 and the center O of the peripheral circle.
2023B, if the length of the line segment in the circle is greater than a preset length threshold, and the distance between the line segment in the circle and the center of the peripheral circle is greater than a second preset distance threshold, using the line segment in the circle as a preliminary positioning line segment.
2024B, based on the preliminary locating line segments, obtaining a first set of line segments of the preliminary locating line segments.
For example, first, all the line segments within the peripheral circle may be detected in step 2021B, and as shown in (a) of fig. 5, each line segment detected within the peripheral circle may be an in-circle line segment of the peripheral circle. Then, in step 2022B, the distance between the target end point of the line segment in each circle and the center of the peripheral circle may be determined as the distance between the line segment in each circle and the center of the peripheral circle. If the length of the line segment in the circle is greater than the preset length threshold and the distance between the line segment in the circle and the center of the peripheral circle is greater than the second preset distance threshold, step 2023B is entered, and the line segment in the circle is used as a preliminary positioning line segment; otherwise, if the length of the line segment in the circle is smaller than or equal to the preset length threshold (as shown in (b) of fig. 5, the length of the line segment 5 is smaller than or equal to the preset length threshold, so the line segment 5 is not used as a preliminary positioning line segment, filtering of the line segment 5 is realized), or the distance between the line segment in the circle and the center of the peripheral circle is smaller than or equal to the second preset distance threshold (as shown in (b) of fig. 5, the distance between the line segment 6 and the center of the peripheral circle is smaller than or equal to the second preset distance threshold, so the line segment 6 is not used as a preliminary positioning line segment, filtering of the line segment 6 is realized), and the line segment in the circle is filtered. By analogy, after processing is completed for all the in-circle segments of the peripheral circle according to steps 2022b to 2023b, a first segment set of preliminary positioning segments is obtained (refer to (c) in fig. 5).
The specific values of the preset length threshold, the first preset distance threshold and the second preset distance threshold can be set according to actual service scene requirements, and the specific values of the preset length threshold, the first preset distance threshold and the second preset distance threshold are not limited.
(3) The first preset condition is that the length of the line segment is larger than a preset length threshold value, the distance between the line segment and the peripheral circle is smaller than a first preset distance threshold value, and the distance between the line segment and the center of the peripheral circle is larger than a second preset distance threshold value. At this time, in step 202, a line segment with a length greater than a preset length threshold, a distance between the line segment and the peripheral circle being less than a first preset distance threshold, and a distance between the line segment and the center of the peripheral circle being greater than a second preset distance threshold is used as a preliminary positioning line segment and added into the first line segment set. At this time, the step 202 may specifically include the following steps 2021c to 2025c:
2021C, detecting an in-circle segment of the peripheral circle.
2022C, detecting the distance between the line segment within the circle and the peripheral circle.
2023C, detecting the distance between the line segment in the circle and the center of the peripheral circle.
2024C, if the length of the line segment in the circle is greater than a preset length threshold, the distance between the line segment in the circle and the peripheral circle is less than a first preset distance threshold, and the distance between the line segment in the circle and the center of the peripheral circle is greater than a second preset distance threshold, using the line segment in the circle as a preliminary positioning line segment.
2025D, based on the preliminary locating line segment, obtaining a first set of line segments of the preliminary locating line segment.
203. And determining a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segment.
The second preset condition is used for indicating the position relation between the preliminary positioning line segments.
The target positioning line segments are line segments meeting a second preset condition in the preliminary positioning line segments of the first line segment set.
The second line segment set is a set of line segments meeting a second preset condition in the preliminary positioning line segments of the first line segment set. I.e. the second set of line segments is a set of target locating line segments.
Illustratively, the second predetermined condition includes that the target end point of the preliminary locating line segment coincides with the target end point of at least one preliminary locating line segment in the first set of line segments. At this time, step 203 may specifically include the following steps 2031a to 2033a:
2031A, obtaining target endpoints of each preliminary positioning line segment in the first line segment set.
In some embodiments, reference may be made to the detection method of the "target end point of line segment in circle" in step 2022A, and the target end points of the preliminary positioning line segments may be detected again. At this time, the distances between the two end points of the preliminary positioning line segment (e.g., the two end points of the line segment 4 in fig. 5) and the peripheral circle, respectively, may be detected, and the end point closest to the peripheral circle (e.g., the end point e of the line segment 4 in fig. 5) may be used as the target end point of the line segment in the circle.
In other embodiments, the detected "target end points of the line segments in the circle" in step 202 may be used to obtain the target end points of the corresponding preliminary positioning line segments.
2032A, traversing each preliminary positioning line segment in the first line segment set, and if the target endpoint of the current traversing line segment coincides with the target endpoints of other line segments in the first line segment set, taking the current traversing line segment as the target positioning line segment.
If the target end point of the current traversed line segment coincides with the target end point of any other preliminary positioning line segment in the first line segment set, it may be determined that the target end point of the current traversed line segment coincides with the target end points of other line segments in the first line segment set. Otherwise, if the target end points of the current traverse line segment are not coincident with the target end points of all the preliminary positioning line segments in the first line segment set, it can be determined that the target end points of the current traverse line segment are not coincident with the target end points of other line segments in the first line segment set.
2033A, obtaining a second line segment set of the target positioning line segment based on the target positioning line segment.
For example, first, in step 2031A, target endpoints of each preliminary positioning line segment in the first line segment set may be obtained, as shown in (c) in fig. 5, where the target endpoints of line segment 1, line segment 3, line segment 4, line segment 7, line segment 8, and line segment 9 are a, a (or c), and e, d, c, d, respectively. Then, whether the target end point of each preliminary positioning line segment is coincident with the target end points of other line segments in the first line segment set is respectively judged, and by way of example, each preliminary positioning line segment in the first line segment set can be traversed, and whether the target end point of the current traversed line segment is coincident with the target end points of other line segments in the first line segment set is judged. If the target end point of the current traversed line segment coincides with the target end points of the other line segments in the first line segment set, step 2032A is entered, and the current traversed line segment is taken as the target positioning line segment (as shown in (d) of fig. 5, the target end point a of the line segment 1 coincides with the target end point a of the line segment 3, the target end point c of the line segment 8 coincides with the target end point c of the line segment 3, and the target end point d of the line segment 7 coincides with the target end point d of the line segment 9, so that the line segments 1, 3, 7, 8 and 9 are taken as the target positioning line segments); otherwise, if the target end point of the current traversed line segment is not coincident with the target end points of the other line segments in the first line segment set (as shown in (d) of fig. 5, the target end point e of the line segment 4 is not coincident with the target end points of the other line segments in the first line segment set, so the line segment 4 is not used as a target positioning line segment, and the filtering of the line segment 4 is realized), the preliminary positioning line segment is filtered. And so on, after processing all the preliminary positioning line segments of the first line segment set according to steps 2031 a-2032 a, a second line segment set of the target positioning line segment is obtained (as shown in (e) in fig. 5).
Because two adjacent edges of the positioning rectangle can intersect to form the corner point of the positioning rectangle, the second preset condition is set as ' the target end point of the preliminary positioning line segment coincides with the target end point of at least one preliminary positioning line segment in the first line segment set ', and if the target end point of the current traversing line segment coincides with the target end points of other line segments in the first line segment set ', the current traversing line segment is taken as the target positioning line segment ', the preliminary positioning line segments which intersect to form the corner point can be screened out as the target positioning line segment, the line segments which obviously do not belong to the edge of the positioning rectangle are filtered out, the probability that the line segments in the second line segment set are the edge of the positioning rectangle ' is improved, and the recognition accuracy of the positioning rectangle is further improved.
204. And determining the positioning rectangle of the two-dimensional code image based on the second line segment set.
The positioning rectangle is used for positioning the coding region of the two-dimensional code image.
There are various ways to determine the positioning rectangle of the two-dimensional code image in step 204, which illustratively includes:
(1) The positioning rectangle of the two-dimensional code image is not occluded (as shown by the two-dimensional code labeled "209" in fig. 4). At this time, the target positioning line segment in the second line segment set is a complete positioning rectangular side. Each line segment in the second line segment set can be combined to be used as a positioning rectangle of the two-dimensional code image, so that the coding region of the two-dimensional code image is positioned.
(2) The positioning rectangle of the two-dimensional code image is blocked. Referring to fig. 4 and 6, the two-dimensional code image has a plurality of blocked positioning rectangles, including the following cases (1) - (4). At this time, part of the target positioning line segments (i.e., the blocked positioning line segments) in the second line segment set are not the sides of the complete positioning rectangle. At this time, an incomplete target positioning line segment (i.e., a blocked positioning line segment) may be found out from the second line segment set, and then the blocked positioning line segment is restored, so that all edges of the positioning rectangle of the two-dimensional code image are restored, thereby obtaining the positioning rectangle of the two-dimensional code image, and step 204 may specifically include the following steps 2041 to 2043.
(1) One included angle of the positioning rectangle is blocked (as shown by a two-dimensional code labeled "1" in fig. 4), and at this time, the second line segment set detected for the two-dimensional code image may be shown by referring to (a) in fig. 6.
(2) A set of diagonal corners of the positioning rectangle are blocked (as shown by the two-dimensional code labeled "188" in fig. 4), and at this time, the second line segment set detected for the two-dimensional code image may be referred to as (b) in fig. 6.
(3) Opposite sides of the positioning rectangle are blocked (as shown by the two-dimensional codes labeled "4" and "21" in fig. 4), at this time, the second line segment set detected for the two-dimensional code image may be shown by referring to (c) in fig. 6.
(4) A set of diagonal corners of the positioning rectangle are blocked (as shown by the two-dimensional codes labeled "4" and "26" in fig. 4), and at this time, the second line segment set detected for the two-dimensional code image may be referred to as (d) in fig. 6.
2041. And acquiring a target positioning line segment meeting a third preset condition in the second line segment set as a blocked positioning line segment.
The third predetermined condition is that only one end point of the target positioning line segment is a corner point, that is, the target positioning line segment and other target positioning line segments in the second line segment set form only one included angle.
For example, each target positioning line segment in the second line segment set may be respectively determined, and whether each target positioning line segment and other target positioning line segments in the second line segment set form only one included angle is detected; if the target positioning line segment (e.g., line segment 3 in fig. 5 (e)) and other target positioning line segments in the second line segment set form only one included angle (e.g., line segment 1 and other line segments form 1 included angle in fig. 5 (e)), the target positioning line segment meets a third predetermined condition, and the target positioning line segment meeting the third predetermined condition is regarded as a blocked positioning line segment. Otherwise, if the target positioning line segment (e.g., line segment 3) and other target positioning line segments in the second line segment set form two included angles (e.g., 2 included angles are formed by the line segment 3 and other line segments in fig. 5 (e)), the target positioning line segment does not meet the third predetermined condition, and the target positioning line segment that does not meet the third predetermined condition is taken as a complete positioning line segment.
2042. And recovering the blocked positioning line segment to obtain a recovered positioning line segment of the blocked positioning line segment.
Specifically, the corner point of the included angle formed between the target positioning line segments in the second line segment set may be obtained first as the complete positioning corner point. For the difference between the complete positioning angular point and the blocked positioning line segment, the method for recovering the blocked positioning line segment in step 2042 includes the following cases 1) to 3):
case 1): the shielded positioning line segment at least comprises a first shielding line segment, the complete positioning angular point at least comprises a first complete angular point and a second complete angular point, the first complete angular point is positioned on the first shielding line segment, and the distance between the first complete angular point and the second complete angular point is equal to the length of a preset rectangular edge of the two-dimensional code image; for example, as shown in the foregoing case (1) (refer to fig. 6 (a)), the case (2) (refer to fig. 6 (b)) and the case (3) (refer to fig. 6 (c)), the step 2042 may specifically include the following steps A1 to A3:
a1, acquiring angular points of included angles formed between target positioning line segments in the second line segment set, and taking the angular points as complete positioning angular points.
The complete positioning angular points at least comprise a first complete angular point and a second complete angular point.
A2, if the distance between the first complete corner point and the second complete corner point is equal to the length of a preset rectangular edge of the two-dimensional code image and the first complete corner point is located on the first shielding line segment, acquiring an intersection point between an extension line of the first shielding line segment and the first straight line as an unknown positioning corner point of the first shielding line segment.
The first straight line is a straight line formed between the second complete corner point and the circle center of the peripheral circle.
And A3, extending the first shielding line segment to the unknown positioning angular point to obtain a recovered positioning line segment of the first shielding line segment.
The length of the preset rectangular side refers to the length of the side of the preset two-dimensional code positioning rectangle.
For example, as shown in (a) in fig. 6, for the second line segment set shown in (a) in fig. 6, 3 complete corner points may be determined, respectively: the angle point formed by the line segment 1 and the line segment 2 (marked as 12), the angle point formed by the line segment 2 and the line segment 4 (marked as 24), the angle point formed by the line segment 3 and the line segment 4 (marked as 34), the angle point 12 formed by the line segment 1 and the line segment 2 is assumed to be a first complete angle point, the angle point 24 formed by the line segment 2 and the line segment 4 is assumed to be a second complete angle point, the first shielding line segment is the line segment 1, and because the distance between the angle point 12 of the first complete angle point and the angle point 24 of the second complete angle point is equal to the length of a preset rectangular edge of the two-dimensional code image and the angle point 12 of the first complete angle point is positioned on the line segment 1, the intersection point between the extension line of the first shielding line segment and the first straight line (namely the intersection point between the second complete angle point 24 and the circle center of the peripheral circle) can be used as an unknown positioning angle point of the line segment 1, and the unknown positioning angle point of the line segment 1 is prolonged to be used as the positioning point after the restoration of the line segment 1. And so on, all the occluded locating line segments in case 1) can be restored.
Case 2): the shielded positioning line segment at least comprises a third shielding line segment and a fourth shielding line segment, the complete positioning angular point at least comprises a third complete angular point and a fourth complete angular point, the third complete angular point is positioned on the third shielding line segment, the fourth complete angular point is positioned on the fourth shielding line segment, the distance between the third complete angular point and the fourth complete angular point is larger than the length of a preset rectangular edge of the two-dimensional code image, and the third shielding line segment is not parallel to the fourth shielding line segment; for example, as shown in the foregoing case (1) (refer to fig. 6 (a)), case (4) (refer to fig. 6 (d)), step 2042 may specifically include steps B1 to B3 as follows:
b1, acquiring angular points of included angles formed between target positioning line segments in the second line segment set, and taking the angular points as complete positioning angular points.
The complete positioning angular points at least comprise a third complete angular point and a fourth complete angular point, wherein the third complete angular point is positioned on the third shielding line segment, and the fourth complete angular point is positioned on the fourth shielding line segment.
And B2, if the distance between the third complete corner point and the fourth complete corner point is larger than the length of the preset rectangular edge of the two-dimensional code image and the third shielding line segment is not parallel to the fourth shielding line segment, acquiring an extension line intersection point between an extension line of the third shielding line segment and an extension line of the fourth shielding line segment.
And B3, respectively extending the third shielding line segment and the fourth shielding line segment to the intersection point of the extension lines to obtain a recovered positioning line segment of the third shielding line segment and a recovered positioning line segment of the fourth shielding line segment.
For example, as shown in (d) of fig. 6, for the second line segment set shown in (d) of fig. 6, 2 complete corner points may be determined, respectively: the angle point (marked as 12) formed by the line segment 1 and the line segment 2, the angle point (marked as 34) formed by the line segment 3 and the line segment 4, the angle point 12 formed by the line segment 1 and the line segment 2 is assumed to be a third complete angle point, the angle point 34 formed by the line segment 3 and the line segment 4 is assumed to be a fourth complete angle point, the third shielding line segment is assumed to be the line segment 1, the fourth shielding line segment is assumed to be the line segment 3, the distance between the angle point 12 of the third complete angle point and the angle point 34 of the fourth complete angle point is larger than the preset rectangular edge length of the two-dimensional code image, the angle point 12 of the third complete angle point is on the line segment 1, the angle 34 of the fourth complete angle point is on the line segment 3, and the line segment 1 is not parallel to the line segment 3, so that an intersection point between an extension line of the third shielding line segment (namely the line segment 1) and an extension line of the fourth shielding line segment (namely the line segment 3) can be used as an extension line extension intersection point, the line segment 1 is extended to an extension point after the extension line segment 1 is restored, and the line segment 3 is extended to an extension point after the extension point is restored to the intersection point. And so on, all the occluded locating line segments in case 2) can be restored.
Case 3): the shielded positioning line segment at least comprises a third shielding line segment and a fourth shielding line segment, the complete positioning angular point at least comprises a third complete angular point and a fourth complete angular point, the third complete angular point is positioned on the third shielding line segment, the fourth complete angular point is positioned on the fourth shielding line segment, the distance between the third complete angular point and the fourth complete angular point is equal to the length of a preset rectangular edge of the two-dimensional code image, and the third shielding line segment and the fourth shielding line segment are positioned on the same straight line; for example, as shown in the foregoing case (3) (refer to (C) in fig. 6), the step 2042 may specifically include the following steps C1 to C2:
and C1, acquiring angular points of included angles formed between target positioning line segments in the second line segment set, and taking the angular points as complete positioning angular points.
The complete positioning angular points at least comprise a third complete angular point and a fourth complete angular point, wherein the third complete angular point is positioned on the third shielding line segment, and the fourth complete angular point is positioned on the fourth shielding line segment.
And C2, if the distance between the third complete corner point and the fourth complete corner point is equal to the length of a preset rectangular edge of the two-dimensional code image and the third shielding line segment and the fourth shielding line segment are on the same straight line, acquiring the line segment between the third complete corner point and the fourth complete corner point as a recovered positioning line segment of the third shielding line segment or as a recovered positioning line segment of the fourth shielding line segment.
For example, as shown in (c) in fig. 6, for the second line segment set shown in (c) in fig. 6, 4 complete corner points may be determined, respectively: the angle between the third complete corner point 13 and the fourth complete corner point 24 is equal to the preset rectangular edge length of the two-dimensional code image, the third complete corner point 13 is positioned on the line segment 1, the fourth complete corner point 24 is positioned on the line segment 2, and the line segment 1 and the line segment 2 are on the same straight line, so that the line segment formed between the third complete corner point 13 and the fourth complete corner point 24 can be positioned after the restoration of the line segment 1 or the line segment 2 after the restoration of the line segment 2. And so on, all the occluded locating line segments in case 3) can be restored.
As can be seen, as shown in fig. 6, by recovering the blocked positioning line segments in the manners of the steps A1-A3, B1-B3, or C1-C2, the blocked sides or corner points of the positioning rectangle can be restored by using the non-blocked corner points in the two-dimensional code image and the position relationship between the blocked positioning line segments and the non-blocked corner points (as shown in the right part of each arrow in fig. 6, wherein the right angle represents the detected non-blocked corner point, the dot represents the blocked corner point of the positioning rectangle, and the dotted line represents the blocked side of the positioning rectangle).
2043. And based on the recovered positioning line segments, obtaining the positioning rectangle of the two-dimensional code image.
In some embodiments, the second line segment set includes a blocked positioning line segment and no complete positioning line segment, and at this time, all the recovered positioning line segments determined in step 2042 may be combined to be used as a positioning rectangle of the two-dimensional code image, so as to position the encoding region of the two-dimensional code image.
In some embodiments, the second line segment set includes a blocked positioning line segment and a complete positioning line segment, where all the complete positioning line segments and the recovered positioning line segments of the blocked positioning line segments determined in step 2042 may be combined to be used as a positioning rectangle of the two-dimensional code image, so as to position the coding region of the two-dimensional code image.
Further, in order to improve the decoding rate of the two-dimensional code and improve the shielding resistance of the two-dimensional code, a higher recognition rate can be maintained under severe conditions (such as factory ground), maintenance cost caused by code replacement due to breakage is reduced, in the embodiment, the two-dimensional code is encoded by adopting a redundant information encoding principle, and based on a preset redundant information encoding and decoding algorithm, the region in the positioning rectangle of the two-dimensional code image is recognized, so that the recognition result of the two-dimensional code image is obtained. The preset redundancy information encoding and decoding algorithm can be a Reed-Solomon algorithm or other encoding algorithms for protecting original data by adding redundancy data. Therefore, the two-dimensional code can directly encode characters and characters, product information can be directly encoded on the two-dimensional code, and two functions of positioning and information storage can be achieved by using the two-dimensional code.
For example, in order to improve the decoding rate of the two-dimensional code, the encoding region of the two-dimensional code in this embodiment is encoded by using a Reed-Solomon algorithm (i.e. the encoding method is consistent with the encoding method of the QR code and the DataMatrix code), and this encoding method has the advantage that even if a part of information is lost or is erroneous, the complete information can still be recovered (for example, 30% of information errors are allowed in the two-dimensional code provided in this embodiment at most); meanwhile, this also means that the two-dimensional code (CopperTag for short) provided in this embodiment is allowed to encode letters and other symbols. Reed-Solomon encoding allows any information to be extended with redundant content, and such extended information can be perfectly error-correction decoded after noisy transmission, as long as the number of errors is less than a predefined value. This allows Reed-Solomon encoding on noisy media (e.g., radio waves, telephone lines, magnetic disks, flash memory, etc.) to maintain information integrity, i.e., all transmitted information can be properly reconstructed after reception, even if received with some errors. Therefore, after the positioning rectangle of the two-dimensional code image is detected in step 204, the Reed-Solomon algorithm may be used to decode the encoding region of the two-dimensional code image, so as to obtain the decoding information of the two-dimensional code image, thereby improving the recognition rate of the two-dimensional code image.
From the above, it can be seen that, in the first aspect, by designing the two-dimensional code to include a peripheral circle and a positioning rectangle inside the peripheral circle, the peripheral circle of the two-dimensional code image to be positioned is detected first; detecting the preliminary positioning line segments which meet the first preset condition in the peripheral circle to obtain a first line segment set by utilizing the position relation between the edges of the positioning rectangle and the peripheral circle (namely utilizing the first preset condition), so as to screen out the preliminary positioning line segments as the edges of the potential positioning rectangle; then, detecting a target positioning line segment meeting a second preset condition from the first line segment set by utilizing the position relation (namely utilizing the second preset condition) existing between the edges of the positioning rectangle to obtain a second line segment set, so that the target positioning line segment is screened out as the potential edge of the positioning rectangle; therefore, the target positioning line segments with the inter-peripheral circle position relationship conforming to the position relationship between the peripheral circle and the edges of the positioning rectangle and the inter-line segment position relationship conforming to the inter-edge relationship of the positioning rectangle can be screened out, and the target positioning line segments are used for determining the positioning rectangle of the two-dimensional code image and realizing the positioning of the two-dimensional code.
In the second aspect, the two-dimensional code is designed to include the peripheral circle and the positioning rectangle located inside the peripheral circle, and because the positional relationship between the edges of the positioning rectangle and the peripheral circle is relatively obvious, even if the positioning rectangle is partially missing (such as blocked, damaged, reflecting, etc.), the preliminary positioning line segment in the peripheral circle conforming to the first predetermined condition is detected by utilizing the positional relationship between the straight line in the circle of the peripheral circle and the peripheral circle (i.e. utilizing the first predetermined condition), so that the preliminary positioning line segment can be screened out as the edge of the potential positioning rectangle, the recognition accuracy of the positioning rectangle is improved, and the recognition accuracy when the two-dimensional code is partially missing is further improved.
In the third aspect, since the peripheral circle can be detected even if it is incomplete (for example, the entire circle can be restored by the semicircle), the anti-blocking property of the two-dimensional code can be improved.
In the fourth aspect, because the positional relationship between the edges of the positioning rectangle is relatively obvious, even if the positioning rectangle is partially missing (such as blocked, damaged, reflected light, etc.), the target positioning line segment meeting the second predetermined condition in the first line segment set is detected by using the positional relationship between the preliminary positioning line segments (that is, using the second predetermined condition), the target positioning line segment can be screened out as the potential edge of the positioning rectangle, so that the recognition accuracy of the positioning rectangle is improved, and the recognition accuracy when the two-dimensional code is partially missing is further improved.
In the fifth aspect, because the positional relationship between the edges of the positioning rectangles is relatively obvious, even if the target positioning line segments are blocked positioning line segments (i.e., the edges of a part of the positioning rectangles are blocked), the positional relationship between each target positioning line segment in the second line segment set can be used to recover the edges of the complete positioning rectangle, thereby improving the recognition accuracy of the positioning rectangles and further improving the recognition accuracy when the two-dimensional code is partially missing.
Therefore, the embodiment of the application can improve the positioning accuracy of the detection pattern when the two-dimensional code part is missing (such as the detection pattern is blocked, damaged, reflected and the like), improve the recognition accuracy when the two-dimensional code part is missing (such as the detection pattern is blocked, damaged, reflected and the like), and improve the anti-blocking capability of the two-dimensional code; the high recognition rate can be maintained under severe conditions (such as factory ground), and the maintenance cost caused by code changing due to breakage is reduced.
It will be appreciated by those of ordinary skill in the art that all or part of the steps in the two-dimensional code positioning method described above may be performed by instructions, or by controlling associated hardware by instructions, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present application provides a computer readable storage medium in which a plurality of computer programs are stored, where the computer programs can be loaded by a processor to execute any one of the two-dimensional code positioning methods provided by the embodiment of the present application. For example, the computer program can be loaded by a processor to perform the steps of:
performing edge detection on a two-dimensional code image to be positioned to obtain a peripheral circle of the two-dimensional code image; detecting a preliminary positioning line segment in the peripheral circle, which accords with a first preset condition, to obtain a first line segment set of the preliminary positioning line segment, wherein the first preset condition is used for indicating the position relationship between the line segment in the circle of the peripheral circle and the peripheral circle; determining a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segment, wherein the second preset condition is used for indicating the position relationship among the preliminary positioning line segments; and determining a positioning rectangle of the two-dimensional code image based on the second line segment set, wherein the positioning rectangle is used for positioning the coding region of the two-dimensional code image.
Wherein the computer-readable storage medium may comprise: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
In the embodiments of the two-dimensional code positioning method, the computer readable storage medium and the electronic device, the descriptions of the embodiments are emphasized, and the related descriptions of other embodiments can be referred to for a part of an embodiment that is not described in detail. It may be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process and the beneficial effects of the computer readable storage medium, the electronic device and the corresponding units described above may refer to the description of the two-dimensional code positioning method in the above embodiment, which is not described herein in detail.
The two-dimensional code positioning method, the electronic device and the computer readable storage medium provided by the embodiment of the application are described in detail, and specific examples are applied to the description of the principle and the implementation mode of the application, and the description of the above embodiment is only used for helping to understand the method and the core idea of the application; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in light of the ideas of the present application, the present description should not be construed as limiting the present application.

Claims (10)

1. The two-dimensional code positioning method is characterized in that the two-dimensional code comprises a peripheral circle and a positioning rectangle positioned inside the peripheral circle, and the method comprises the following steps:
performing edge detection on a two-dimensional code image to be positioned to obtain a peripheral circle of the two-dimensional code image;
detecting a preliminary positioning line segment in the peripheral circle, which accords with a first preset condition, to obtain a first line segment set of the preliminary positioning line segment, wherein the first preset condition is used for indicating the position relationship between the line segment in the circle of the peripheral circle and the peripheral circle;
determining a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segment, wherein the second preset condition is used for indicating the position relationship among the preliminary positioning line segments;
and determining a positioning rectangle of the two-dimensional code image based on the second line segment set, wherein the positioning rectangle is used for positioning the coding region of the two-dimensional code image.
2. The two-dimensional code positioning method according to claim 1, wherein the first predetermined condition includes that a length of a line segment is greater than a preset length threshold value, and a distance between the line segment and a peripheral circle is smaller than a first preset distance threshold value;
Detecting the preliminary positioning line segment meeting a first preset condition in the peripheral circle to obtain a first line segment set of the preliminary positioning line segment, wherein the method comprises the following steps:
detecting an in-circle segment of the peripheral circle;
detecting the distance between the line segment in the circle and the peripheral circle;
if the length of the line segment in the circle is larger than a preset length threshold value and the distance between the line segment in the circle and the peripheral circle is smaller than a first preset distance threshold value, the line segment in the circle is used as a preliminary positioning line segment;
and obtaining a first line segment set of the preliminary positioning line segments based on the preliminary positioning line segments.
3. The two-dimensional code positioning method according to claim 1, wherein the first predetermined condition includes that a length of a line segment is greater than a preset length threshold value, and a distance between the line segment and a center of a peripheral circle is greater than a second preset distance threshold value;
detecting the preliminary positioning line segment meeting a first preset condition in the peripheral circle to obtain a first line segment set of the preliminary positioning line segment, wherein the method comprises the following steps:
detecting an in-circle segment of the peripheral circle;
detecting the distance between the line segment in the circle and the center of the peripheral circle;
if the length of the line segment in the circle is larger than a preset length threshold value and the distance between the line segment in the circle and the center of the peripheral circle is larger than a second preset distance threshold value, the line segment in the circle is used as a preliminary positioning line segment;
And obtaining a first line segment set of the preliminary positioning line segments based on the preliminary positioning line segments.
4. The two-dimensional code positioning method according to claim 1, wherein the second predetermined condition includes that a target end point of a preliminary positioning line segment coincides with a target end point of at least one preliminary positioning line segment in the first line segment set;
determining a target positioning line segment meeting a second preset condition from the first line segment set to obtain a second line segment set of the target positioning line segment, wherein the second line segment set comprises:
acquiring target endpoints of each preliminary positioning line segment in the first line segment set;
traversing each preliminary positioning line segment in the first line segment set, and taking the current traversing line segment as a target positioning line segment if the target end point of the current traversing line segment coincides with the target end points of other line segments in the first line segment set;
and obtaining a second line segment set of the target positioning line segment based on the target positioning line segment.
5. The two-dimensional code positioning method according to claim 1, wherein the determining the positioning rectangle of the two-dimensional code image based on the second line segment set includes:
acquiring target positioning line segments meeting a third preset condition in the second line segment set as blocked positioning line segments;
Restoring the shielded positioning line segment to obtain a restored positioning line segment of the shielded positioning line segment;
and based on the recovered positioning line segments, obtaining the positioning rectangle of the two-dimensional code image.
6. The two-dimensional code positioning method according to claim 5, wherein the blocked positioning line segment at least comprises a first blocking line segment;
the restoring the blocked positioning line segment to obtain a restored positioning line segment of the blocked positioning line segment comprises the following steps:
acquiring angular points of included angles formed between target positioning line segments in the second line segment set as complete positioning angular points, wherein the complete positioning angular points at least comprise a first complete angular point and a second complete angular point;
if the distance between the first complete corner point and the second complete corner point is equal to the length of a preset rectangular edge of the two-dimensional code image and the first complete corner point is located on the first shielding line segment, acquiring an intersection point between an extension line of the first shielding line segment and a first straight line as an unknown positioning corner point of the first shielding line segment, wherein the first straight line is a straight line formed between the second complete corner point and the circle center of the peripheral circle;
And extending the first shielding line segment to the unknown positioning angular point to obtain a recovered positioning line segment of the first shielding line segment.
7. The two-dimensional code positioning method according to claim 5, wherein the blocked positioning line segments at least include a third blocking line segment and a fourth blocking line segment;
the restoring the blocked positioning line segment to obtain a restored positioning line segment of the blocked positioning line segment comprises the following steps:
acquiring corner points of included angles formed between target positioning line segments in the second line segment set as complete positioning corner points, wherein the complete positioning corner points at least comprise a third complete corner point and a fourth complete corner point, the third complete corner point is positioned on the third shielding line segment, and the fourth complete corner point is positioned on the fourth shielding line segment;
if the distance between the third complete corner point and the fourth complete corner point is greater than the length of the preset rectangular edge of the two-dimensional code image, acquiring an extension line intersection point between an extension line of the third shielding line segment and an extension line of the fourth shielding line segment;
and respectively extending the third shielding line segment and the fourth shielding line segment to the intersection point of the extension lines to obtain a recovered positioning line segment of the third shielding line segment and a recovered positioning line segment of the fourth shielding line segment.
8. The two-dimensional code positioning method according to claim 1, wherein the two-dimensional code is encoded by using a redundant information encoding principle, the method further comprising:
and identifying the area in the positioning rectangle of the two-dimensional code image based on a preset redundant information encoding and decoding algorithm to obtain an identification result of the two-dimensional code image.
9. An electronic device comprising a processor and a memory, wherein the memory stores a computer program, and wherein the processor executes the two-dimensional code positioning method according to any one of claims 1 to 8 when calling the computer program in the memory.
10. A computer-readable storage medium, having stored thereon a computer program that is loaded by a processor to perform the two-dimensional code positioning method of any one of claims 1 to 8.
CN202311466381.8A 2023-11-07 2023-11-07 Two-dimensional code positioning method, electronic equipment and storage medium Active CN117218328B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311466381.8A CN117218328B (en) 2023-11-07 2023-11-07 Two-dimensional code positioning method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311466381.8A CN117218328B (en) 2023-11-07 2023-11-07 Two-dimensional code positioning method, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117218328A true CN117218328A (en) 2023-12-12
CN117218328B CN117218328B (en) 2024-03-08

Family

ID=89041086

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311466381.8A Active CN117218328B (en) 2023-11-07 2023-11-07 Two-dimensional code positioning method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117218328B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120031973A1 (en) * 2009-04-10 2012-02-09 Beijing Sigone Venture Limited Two-dimensional array code
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN110414649A (en) * 2019-07-29 2019-11-05 广州柔视智能科技有限公司 Localization method, device, terminal and the storage medium of DM code
CN112329496A (en) * 2020-12-02 2021-02-05 库卡机器人(广东)有限公司 Rectangular two-dimensional code identification method and device and electronic equipment
CN113496134A (en) * 2020-04-08 2021-10-12 顺丰科技有限公司 Two-dimensional code positioning method, device, equipment and storage medium
CN116883498A (en) * 2023-07-06 2023-10-13 中国电子科技集团公司第五十四研究所 Visual cooperation target feature point positioning method based on gray centroid extraction algorithm

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120031973A1 (en) * 2009-04-10 2012-02-09 Beijing Sigone Venture Limited Two-dimensional array code
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN110414649A (en) * 2019-07-29 2019-11-05 广州柔视智能科技有限公司 Localization method, device, terminal and the storage medium of DM code
CN113496134A (en) * 2020-04-08 2021-10-12 顺丰科技有限公司 Two-dimensional code positioning method, device, equipment and storage medium
CN112329496A (en) * 2020-12-02 2021-02-05 库卡机器人(广东)有限公司 Rectangular two-dimensional code identification method and device and electronic equipment
CN116883498A (en) * 2023-07-06 2023-10-13 中国电子科技集团公司第五十四研究所 Visual cooperation target feature point positioning method based on gray centroid extraction algorithm

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
徐义钊: "复杂背景下二维码实时识别技术的研究与开发", <中国优秀硕士学位论文全文数据库 (信息科技辑)>, no. 2, pages 138 - 642 *

Also Published As

Publication number Publication date
CN117218328B (en) 2024-03-08

Similar Documents

Publication Publication Date Title
EP3605398B1 (en) Method and device for generating and identifying identification code
US10929628B2 (en) QR code positioning method and apparatus
US9449210B2 (en) Method and system for detecting a correction pattern in a QR code
CA2632867C (en) Method and device for generating image code and method and device for decoding image code
CN112329496B (en) Rectangular two-dimensional code identification method and device and electronic equipment
US20100084470A1 (en) Two-dimensional barcode localization for camera based devices
US6941026B1 (en) Method and apparatus using intensity gradients for visual identification of 2D matrix symbols
CN117218328B (en) Two-dimensional code positioning method, electronic equipment and storage medium
JP4460903B2 (en) ID mark recognition method for semiconductor wafer
US11893764B1 (en) Image analysis for decoding angled optical patterns
WO2022021687A1 (en) Method for positioning quick response code area, and electronic device and storage medium
CN112819827A (en) LED electrode offset detection method and device based on polar coordinate transformation and storage medium
CN111768345A (en) Method, device and equipment for correcting back image of identity card and storage medium
CN111768346A (en) Method, device and equipment for correcting back image of identity card and storage medium
CN118015029A (en) Method and device for detecting corner points of tabs and storage medium
CN112183695B (en) Coding method, coding pattern reading method, and photographing apparatus
CN111768344A (en) Method, device and equipment for correcting front image of identity card and storage medium
US10832415B2 (en) Window image detection method and device
CN113496134A (en) Two-dimensional code positioning method, device, equipment and storage medium
CN117197422B (en) Identification code positioning method, electronic equipment and storage medium
CN113627578B (en) Two-dimensional code generation method, identification device, two-dimensional code, device and medium
CN112101059B (en) Bar code positioning method, bar code positioning device, terminal equipment and storage medium
CN117350317B (en) Decoding method and device for bar code image and electronic equipment
CN115578563A (en) Image segmentation method, system, storage medium and electronic equipment
CN116882430A (en) QR code image identification method, electronic equipment and system based on feature extraction

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant