CN113139400A - QR code positioning method and device and computer readable medium - Google Patents

QR code positioning method and device and computer readable medium Download PDF

Info

Publication number
CN113139400A
CN113139400A CN202110682471.5A CN202110682471A CN113139400A CN 113139400 A CN113139400 A CN 113139400A CN 202110682471 A CN202110682471 A CN 202110682471A CN 113139400 A CN113139400 A CN 113139400A
Authority
CN
China
Prior art keywords
edge
points
code
determining
locator
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
CN202110682471.5A
Other languages
Chinese (zh)
Other versions
CN113139400B (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.)
Zhejiang Huaray Technology Co Ltd
Original Assignee
Zhejiang Huaray 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 Zhejiang Huaray Technology Co Ltd filed Critical Zhejiang Huaray Technology Co Ltd
Priority to CN202110682471.5A priority Critical patent/CN113139400B/en
Publication of CN113139400A publication Critical patent/CN113139400A/en
Application granted granted Critical
Publication of CN113139400B publication Critical patent/CN113139400B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1452Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses a QR code positioning method, a QR code positioning device and a computer readable medium, and belongs to the technical field of image processing. The method comprises the following steps: carrying out coarse positioning on the QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code; sampling any pre-edge line to obtain a plurality of pre-edge points, and detecting a locator of the pre-edge line to obtain a first detection result; determining quasi edge points of the pre-edge lines based on the first detection result; and determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines. Therefore, each pre-edge line of the QR code is independently positioned, the positioning precision of the outer contour of the QR code can be effectively improved, the problem that the outer contour of the QR code cannot be accurately positioned and cannot be decoded due to the fact that the QR code is inclined, transmitted, bent and the like in the prior art is solved, and the applicability of the QR code is improved.

Description

QR code positioning method and device and computer readable medium
Technical Field
The invention relates to the technical field of image processing, in particular to a QR code positioning method, a QR code positioning device and a computer readable medium.
Background
With the development of information technology in China, the application of Quick Response (QR) codes is more and more extensive, and the QR codes are applied to the fields of mobile phone payment, express logistics, automatic production lines and the like. This is mainly because the QR code has advantages of large capacity of stored information, easy reading, and strong anti-contamination capability. Accurate positioning of the QR code is the basis for QR code identification. Since the key feature of the QR code is to have three identically shaped locators, the locators provide an advantageous basis for QR code localization.
The traditional QR code positioning method is mainly characterized in that a QR code image is preprocessed and scanned to obtain the position information of a locator, and then a fourth locator corner point is presumed according to the geometric relationship between the locator corner points and the QR code, so that the outline position of the QR code is determined.
However, the conventional positioning method can obtain a high recognition accuracy under ideal camera imaging conditions, but cannot accurately position the QR code in oblique, transmissive and curved scenes, so that the QR code cannot be effectively recognized.
Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for positioning a QR code, and a computer-readable medium, which can accurately position a QR code outline in any scene, and improve the positioning accuracy of the QR code outline.
In order to achieve the above object, according to a first aspect of embodiments of the present invention, there is provided a QR code positioning method, including: carrying out coarse positioning on the quick response QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code; sampling any pre-edge line to obtain a plurality of pre-edge points, and detecting a locator of the pre-edge line to obtain a first detection result; if the first detection result represents that the two ends of the pre-edge line are distributed with the locators, determining the pre-edge points of the locator segments on the pre-edge line as quasi-edge points; if the first detection result represents that only one end of the pre-edge line is distributed with the locator, filtering the edge points on the pre-edge line if the edge points interfere with the edge lines to obtain quasi-edge points; and determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines.
Optionally, the determining the positioning result of the QR code based on the quasi edge points of all the pre-edge lines includes: for any of the pre-edge lines: performing linear fitting based on the quasi edge points to obtain quasi edge lines; determining an quasi-angular point of the QR code according to the intersection result of any two quasi-edge lines; and determining the quasi-angular point as a positioning result of the QR code.
Optionally, the pre-edge line includes a locator segment and a non-locator segment; the filtering the edge points if the edge points are interfered on the pre-edge line to obtain the quasi-edge points comprises the following steps: determining the pre-edge points of the locator segments as quasi-edge points, and selecting any quasi-edge point as a reference point; determining, for any pre-edge point of the non-locator segment, an angle between the pre-edge point and the reference point; and selecting an angle meeting a preset condition from the plurality of angles, and determining a pre-edge point corresponding to the angle as a quasi-edge point.
Optionally, the selecting an angle satisfying a preset condition from the plurality of angles includes: sequencing a plurality of angles in a sequence from small to large, and determining the angle positioned in the middle of the angle sequencing as a reference angle; and determining the absolute value of the error between the angle and the reference angle according to any angle, sequencing a plurality of absolute values of the error from small to large, selecting the absolute values of the error meeting the preset number from the error sequencing, and determining the angle corresponding to the absolute value of the error as the angle meeting the preset condition.
Optionally, the sampling processing performed on any of the pre-edge lines to obtain a plurality of pre-edge points includes: for any of the pre-edge lines: performing locator detection, and determining preset caliper points of the preset edge line based on a second detection result to obtain a plurality of preset caliper points; for any of the preset caliper points: collecting edge points along the searching direction according to the direction from the outside to the inside of the edge; selecting edge points with the largest pixel gradient from the acquired edge points as candidate edge points, wherein the searching direction is used for indicating the normal direction which passes through the preset caliper point and is perpendicular to the preset edge line; and selecting candidate edge points with the pixel gradient larger than a first preset threshold value from the candidate edge points of the pre-edge line as pre-edge points.
Optionally, the determining the preset caliper point of the pre-edge line based on the second detection result includes:
if the second detection result represents that the two ends of the pre-edge line are distributed with the locators, setting a first preset number of preset caliper points on the locator segments along the extension direction of the pre-edge line; if the second detection result represents that only one end of the pre-edge line is distributed with the locator, a first preset number of preset caliper points are arranged on the locator segment along the extension direction of the pre-edge line, and a second preset number of preset caliper points are arranged on the non-locator segment.
Optionally, the performing coarse positioning on the QR code to obtain a coarse positioning result includes: carrying out image processing on the QR code to obtain position information of a plurality of locators; determining the position relation between any two locators based on the position information of the locators; for any locator: determining outer corner points of the locators according to the locator position information and the position relation;
in order to achieve the above object, according to a second aspect of the embodiments of the present invention, there is also provided a positioning apparatus for a QR code, the apparatus including: the coarse positioning module is used for performing coarse positioning on the quick response QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code; the detection module is used for sampling any pre-edge line to obtain a plurality of pre-edge points and detecting a locator of the pre-edge line to obtain a first detection result; the first determining module is used for determining the pre-edge point of the locator segment on the pre-edge line as a quasi-edge point if the first detection result represents that locators are distributed at both ends of the pre-edge line; the second determining module is used for filtering a plurality of pre-edge points to obtain quasi-edge points if the first detection result represents that only one end of the pre-edge line is distributed with a locator; and the third determining module is used for determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines.
To achieve the above object, according to a third aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including: one or more processors; memory for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out the method according to the first aspect.
To achieve the above object, according to a fourth aspect of the embodiments of the present invention, there is also provided a computer readable medium having a computer program stored thereon, the program, when executed by a processor, implementing the method according to the first aspect.
Compared with the prior art, the embodiment of the invention provides a QR code positioning method, a QR code positioning device and a computer readable medium, wherein the positioning method comprises the steps of firstly carrying out coarse positioning on a QR code to obtain a coarse positioning result, and carrying out sampling treatment on any pre-edge line in the coarse positioning result to obtain a plurality of pre-edge points; then, carrying out locator detection on the pre-edge line, and if the first detection result represents that the locators are distributed at both ends of the pre-edge line, determining the pre-edge points of the locator segments on the pre-edge line as quasi-edge points; if the first detection result represents that only one end of the pre-edge line is distributed with the locator, filtering the edge points on the pre-edge line if the edge points are interfered to obtain quasi edge points; and finally, determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines. Therefore, each pre-edge line of the QR code is independently positioned, the positioning precision of the outer contour of the QR code can be effectively improved, the problem that the outer contour of the QR code cannot be accurately positioned and cannot be decoded due to the fact that the QR code is inclined, transmitted, bent and the like in the prior art is solved, and the applicability of the QR code is improved.
It is to be understood that the teachings of the present invention need not achieve all of the above-described benefits, but rather that specific embodiments may achieve specific technical results, and that other embodiments of the present invention may achieve benefits not mentioned above.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein like or corresponding reference numerals designate like or corresponding parts throughout the several views.
FIG. 1 is a schematic flow chart of a QR code positioning method according to an embodiment of the present invention;
FIG. 2 is a schematic flowchart of coarse positioning to QR codes to obtain a coarse positioning result according to another embodiment of the present invention;
FIG. 3 is a schematic flow chart of sampling any pre-edge line to obtain a plurality of pre-edge points according to yet another embodiment of the present invention;
FIG. 4 is a schematic flow chart of a pre-edge point filtering process for a pre-edge line according to another embodiment of the present invention;
FIG. 5 is a diagram illustrating QR code locator features in accordance with another embodiment of the present invention;
FIG. 6 is a binarized image of a QR code in another embodiment of the present invention;
FIG. 7 is a schematic diagram of a locator according to another embodiment of the present invention;
FIG. 8 is a schematic diagram illustrating a center point of a QR code according to another embodiment of the present invention;
fig. 9 is a schematic diagram of acquiring an outer corner of a QR code according to another embodiment of the present invention;
FIG. 10 is a diagram illustrating a coarse positioning result of a QR code according to another embodiment of the present invention;
FIG. 11 is a schematic diagram illustrating the positions of predetermined caliper points on the pre-edge line of a dual locator according to yet another embodiment of the present invention;
FIG. 12 is a schematic diagram illustrating the positions of predetermined caliper points on a pre-edge line of a single anchor according to yet another embodiment of the present invention;
FIG. 13 is a schematic diagram illustrating edge points collected based on predetermined caliper points according to yet another embodiment of the present invention;
FIG. 14 is a diagram illustrating pre-edge points of a QR code according to still another embodiment of the present invention;
FIG. 15 is a diagram illustrating non-locator segment pre-edge point angles in accordance with yet another embodiment of the present invention;
FIG. 16 is a diagram illustrating quasi-edge points of a QR code according to still another embodiment of the present invention;
FIG. 17 is a diagram illustrating quasi-edge lines of a QR code according to still another embodiment of the present invention;
fig. 18 is a schematic block diagram of a QR code positioning apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, a schematic flowchart of a QR code positioning method according to an embodiment of the present invention is shown. A QR code positioning method comprises the following operation processes: s101, carrying out coarse positioning on the QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code; s102, sampling any pre-edge line to obtain a plurality of pre-edge points, and detecting a locator of the pre-edge line to obtain a first detection result; s103, if the first detection result represents that the two ends of the pre-edge line are distributed with the locators, determining the pre-edge points of the locator segments on the pre-edge line as quasi-edge points; s104, if the first detection result represents that only one end of the pre-edge line is distributed with the locator, filtering the edge points on the pre-edge line if the edge points interfere with the pre-edge line to obtain quasi-edge points; and S105, determining the positioning result of the QR code based on the quasi edge points of all the pre-edge lines.
In S101, a specific implementation of the coarse positioning is not limited, and the coarse positioning may be performed based on a full-image scanning method, or may be performed based on another conventional method. As long as the pre-margin line of the QR code can be acquired by coarse positioning.
It should be noted that the pre-edge line is not necessarily a quasi-edge line of the QR code, but the pre-edge line is a basis for determining the quasi-edge line of the QR code.
In S102, the collection method of the pre-edge line is not limited, and the pre-edge point of the pre-edge line may be collected by using a model, or a preset caliper point may be set on the pre-edge line, and then the pre-edge point on the pre-edge line is collected based on the preset caliper point.
The key feature of the QR code is that the QR code has three locators with the same shape, for example, the upper left corner, the upper right corner and the lower left corner of the QR code have the locators with the same shape respectively, so that the position of the locator on the pre-edge line is detected, and the quasi-edge point of the pre-edge line is determined based on the detection result, thereby being beneficial to positioning the QR code and simplifying the positioning step of the QR code.
In S103, the pre-edge line includes a locator segment and a non-locator segment, and when the first detection result represents that the locators are respectively distributed at two ends of the pre-edge line, because the two locators can determine the quasi-edge line corresponding to the pre-edge line, the pre-edge point of the non-locator segment does not need to be considered when determining the quasi-edge point of the quasi-edge line, and only the pre-edge point of the locator segment is considered, and the pre-edge point of the locator segment is determined as the quasi-edge point of the pre-edge line. Therefore, the positioning steps of the outline of the QR code can be simplified, the positioning efficiency is improved, and accurate positioning of the accurate edge points on the pre-edge line is achieved.
In S104, when the first detection result represents that the pre-edge line has only one end with a locator, since one locator cannot determine the quasi-edge line corresponding to the pre-edge line, when determining the quasi-edge point of the quasi-edge line, all the pre-edge points on the pre-edge line need to be filtered, and the quasi-edge point of the pre-edge line is determined based on the filtering result, therefore, by filtering all the pre-edge points on the pre-edge line, the pre-edge points belonging to noise can be effectively removed, thereby realizing the accurate positioning of the quasi-edge points on the pre-edge line, and further being beneficial to accurately positioning the QR code outline.
In S105, the positioning result of the QR code is not limited, and the positioning result of the QR code may be all quasi-edge lines of the QR code or all quasi-corner points of the QR code.
For example, for any pre-edge line: performing linear fitting based on the quasi-edge points to obtain quasi-edge lines; each pre-edge line is provided with a corresponding quasi-edge line; calculating the intersection point of every two aligned edge lines according to the clockwise sequence; determining quasi-angular points of the QR code according to the intersection result of any two quasi-edge lines, as shown in FIG. 17; and determining the accurate corner points as the positioning result of the QR code.
In the embodiment, firstly, the QR code is roughly positioned to obtain a positioning result, then, sampling processing is carried out on any pre-edge line in the positioning result to obtain a plurality of pre-edge points, and the position of a locator on the pre-edge line is detected; then determining whether the pre-edge points on the pre-edge lines are quasi-edge points or not based on the detection result; and finally, determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines. Therefore, each pre-edge line of the QR code is independently positioned, so that the positioning accuracy of the outer contour of the QR code can be effectively improved, the calculation process is simple, and the method is suitable for positioning the outer contour of the QR code in any scene.
As shown in fig. 2, a schematic flowchart of performing coarse positioning on a QR code to obtain a coarse positioning result in another embodiment of the present invention. The embodiment is further optimized on the basis of the previous embodiment. The method comprises the following steps of carrying out rough positioning on a QR code to obtain a rough positioning result, wherein the rough positioning result at least comprises the following operation procedures: s201, carrying out image processing on the QR code to obtain position information of a plurality of locators; s202, determining the position relation between any two locators based on the position information of the locators; s203, for any locator: determining outer corner points of the locators based on the locator position information and the position relation; s204, determining a pre-edge line of the QR code based on the sequential connection result of all the outer corner points, and determining the pre-edge as a coarse positioning result.
For ease of understanding, each step of the above embodiment will be described in detail below in conjunction with a QR code in a transmission scenario.
As shown in fig. 5, the main characteristic of the QR code locator is that the length ratio of the black and white modules in the locator is 1:1:3:1: 1.
In S201, performing binarization processing on the QR code to obtain a binarized image, as shown in fig. 6; and scanning the binary image to obtain the position information of a plurality of locators. The position information of the locator is used for being characterized by the coordinates of four vertexes of the locator, for example, the position information of the locator A is
Figure 400425DEST_PATH_IMAGE001
As shown in fig. 7.
Note that the binarization processing may be implemented by using OSTU threshold segmentation, or may be implemented by using adaptive threshold segmentation.
In S202, for any locator: determining a locator center point according to the locator position information; a positional relationship between any two locators is determined based on a number of locator center points. The positions of the center point of the locator A, the center point of the locator B and the center point of the locator C are sequentially expressed as
Figure 934174DEST_PATH_IMAGE002
Wherein, in order
Figure 51035DEST_PATH_IMAGE003
For example, the coordinate calculation formula is shown in formula (1):
Figure 746458DEST_PATH_IMAGE004
formula (1).
The distance between the center points of any two locators is calculated, resulting in 3 distances, expressed as:
Figure 456925DEST_PATH_IMAGE005
and selecting the maximum distance from the three distances, determining a group of locators corresponding to the maximum distance as a diagonal relationship, and enabling the two groups of locators corresponding to the rest 2 distances to be in the same-side relationship. Thus, the positional relationship between any two locators in the QR code can be efficiently determined.
In S203, based on a set of locators of diagonal relationship, determining a QR code center point
Figure 59945DEST_PATH_IMAGE006
As shown in fig. 8;
Figure 172258DEST_PATH_IMAGE006
the calculation formula is shown in formula (2):
Figure 100899DEST_PATH_IMAGE007
formula (2).
Taking locator a as an example, 4 vertices of locator a are divided into 2 groups in the diagonal direction:
Figure 95400DEST_PATH_IMAGE008
centering the QR code
Figure 643056DEST_PATH_IMAGE009
Respectively connecting two vertexes in each group to obtain 4 straight lines, as shown in fig. 9; the linear relationship of the 4 straight lines is shown in the following formula (3):
Figure 468930DEST_PATH_IMAGE010
formula (3).
For two straight lines in each group, the intersecting angle of the two straight lines is respectively calculated, and the angle calculation formula is shown as formula (4):
Figure 709418DEST_PATH_IMAGE011
formula (4).
Selecting a set of vertices corresponding to the smallest angle from two angles, as in FIG. 9
Figure 253532DEST_PATH_IMAGE012
In the group, the distance between the center point of the QR code and two vertexes is calculated, and the distance calculation formula is shown in formula (5):
Figure 401617DEST_PATH_IMAGE013
formula (5).
Selecting the vertex corresponding to the maximum distance from the two distances, and determining the vertex as the external corner point of the locator A
Figure 222942DEST_PATH_IMAGE014
Similarly, the outer corner point of the locator A
Figure 758966DEST_PATH_IMAGE014
Similar to the calculation process of (1), the outer corner point of locator B is calculated
Figure 5357DEST_PATH_IMAGE015
And the outer corner point of the locator C
Figure 894815DEST_PATH_IMAGE016
According to the symmetry relation of the parallelogram of the QR code, the center point of the QR code and the outer corner point of the locator B
Figure 226439DEST_PATH_IMAGE015
(ii) a Determining the fourth outer corner point of QR code
Figure 136627DEST_PATH_IMAGE017
The location information of (a) is stored in the storage unit,
Figure 530699DEST_PATH_IMAGE017
is represented by the following formula (6):
Figure 348482DEST_PATH_IMAGE018
formula (6).
In S204, sequentially connecting the 4 outer corner points to obtain a QR code outline; several pre-edge lines of the QR code are determined based on the QR code profile, and the several pre-edge lines are determined as a result of coarse positioning of the QR code, as shown in fig. 10.
The present embodiment obtains locator position information based on image processing, and determines two locators in a diagonal relationship based on the locator position information; then determining the position information of the center point of the QR code based on the two locators of the diagonal relationship; determining outer corner points of the locator based on the position information of the center point of the QR code and the position information of the locator, and finally sequentially connecting all the outer corner points of the QR code to determine a coarse positioning result of the QR code; therefore, coarse positioning of the outer contour of the QR code can be realized, and the calculation process is simplified.
As shown in fig. 3, a schematic flow chart of sampling any pre-edge line to obtain a plurality of pre-edge points according to another embodiment of the present invention. The embodiment is further optimized on the basis of the previous embodiment. Sampling any pre-edge line to obtain a plurality of intervention edge points, wherein the method at least comprises the following operation flows: s301, for any pre-edge line: performing locator detection, and determining preset caliper points of the preset edge line based on a second detection result to obtain a plurality of preset caliper points; s302, aiming at any preset caliper point: collecting edge points along the searching direction according to the direction from the outside to the inside of the edge; selecting edge points with the largest pixel gradient from the acquired edge points as candidate edge points, wherein the searching direction is used for indicating the normal direction which passes through a preset caliper point and is perpendicular to a preset edge line; s303, select a candidate edge point with a pixel gradient greater than a first preset threshold from the candidate edge points of the pre-edge line as a pre-edge point.
For ease of understanding, each step of the above embodiment will be described in detail below in conjunction with a QR code in a transmission scenario.
In S301, the pre-edge line includes a locator segment and a non-locator segment. The locator segment is used for indicating the positions where the locators are distributed on the pre-edge line, namely the line segment where the pre-edge line is overlapped with the locator edge; the non-locator segment is used to indicate a location on the pre-edge line where no locator is distributed, i.e., a line segment on the pre-edge line that does not overlap with the locator edge.
If the second detection result represents that the two ends of the pre-edge line are distributed with the locators, setting a first preset number of preset caliper points on the locator segments along the extension direction of the pre-edge line; if the second detection result represents that the preset edge line only has one end distributed with the locator, the preset caliper points with the first preset number are arranged on the locator segment along the extension direction of the preset edge line, and the preset caliper points with the second preset number are arranged on the non-locator segment.
As shown in fig. 11, when two ends of the pre-edge line are respectively distributed with one locator, 2 preset caliper points are arranged in each locator segment of the pre-edge line. Since the length ratio of the black and white modules in the locator edge is 1:1:3:1:1, the locator edge is composed of 7 unit lengths. To make the spacing of the 2 preset caliper points more uniform across the entire locator edge, two preset caliper points are therefore placed in the locator segment at locations 2/7 and 5/7 of the length of the locator edge.
As shown in fig. 12, when only one end of the pre-edge line is distributed with one locator, a preset caliper point is respectively set at the 2/7 and 5/7 positions of the locator segment, and 10 preset caliper points are set at equal intervals in the non-locator segment.
In S302, as shown in fig. 13, for any one of the preset caliper points of the locator segment: collecting edge points from outside to inside in the searching direction towards the edge direction according to a first specific step length, and selecting the edge point with the largest pixel gradient from the collected edge points as a candidate edge point; for any preset caliper point of the non-locator segment: collecting edge points from outside to inside in the searching direction towards the edge direction according to a second specific step length, and selecting the edge point with the largest pixel gradient from the collected edge points as a candidate edge point; wherein the second specific step size is larger than the first specific step size. E.g. a second specific step size ofAntiLabelLength,The first specific step size isLabelLength;
The length relationship between the first specific step size and the second specific step size is as shown in equation (7):
Figure 878821DEST_PATH_IMAGE019
formula (7).
Here, the edge point where the pixel gradient is the largest is used to indicate the position where the pixel change is the most severe by light-dark or by dark-light.
In S303, the obtained QR code pre-edge points are as shown in fig. 14. The first preset threshold is the pixel gradient threshold. The outer edge of the QR code is a data area, black and white modules in the QR code are sequenced randomly, and all preset caliper points can not be positioned to the outermost edge of the QR code, so that the pixel gradient threshold value is used; the method can effectively filter the candidate edge points, and improves the accuracy of the QR code outline positioning result.
In the embodiment, the preset caliper points are arranged on the preset edge line, the edge points are collected according to a specific rule based on the preset caliper points, then the collected edge points are filtered to obtain candidate edge points, and the candidate edge points meeting the pixel gradient threshold value are selected from the candidate edge points; and finally, taking the selected candidate edge points as pre-edge points. Therefore, the preset edge line can be repositioned again based on the preset caliper points, the positioning precision of the QR code outer contour is improved, and the accurate positioning of the QR code outer contour is facilitated.
FIG. 4 is a schematic flow chart of a pre-edge point filtering process for a pre-edge line according to an embodiment of the present invention. The embodiment is further optimized on the basis of the previous embodiment. Filtering the edge points on the pre-edge line if the edge points interfere to obtain the quasi-edge points, wherein the method comprises the following operation flows: s401, determining the pre-edge points of the locator segments as quasi-edge points; s402, selecting any quasi-edge point as a reference point, and determining an angle between a pre-edge point and the reference point aiming at any pre-edge point of a non-locator segment; s403, selecting an angle meeting preset conditions from the plurality of angles, and determining a pre-edge point corresponding to the angle as a quasi-edge point.
Specifically, a plurality of angles are sorted from small to large, and the angle in the middle of the angle sorting is determined as a reference angle; and determining the absolute value of the error between the angle and the reference angle according to any angle, sequencing a plurality of absolute values of the error from small to large, selecting the absolute values of the error meeting the preset number from the error sequencing, and determining the angle corresponding to the absolute value of the error as the angle meeting the preset condition.
When there are only 1 locator on the pre-edge lineThen an inner edge culling operation is required for the non-locator segment. Arbitrarily selecting a quasi-edge point on the locator segment as a reference point
Figure 756647DEST_PATH_IMAGE020
The angle between the pre-edge point and the reference point on the non-locator segment is calculated in turn, as shown in fig. 15. Obtaining a set of corresponding angles of all the pre-edge points, expressed as:
Figure 434753DEST_PATH_IMAGE021
(ii) a Wherein, it is assumed that the non-location segment is pre-edge point
Figure 931593DEST_PATH_IMAGE022
The calculation formula of the angle between the pre-edge point and the reference point is shown as the formula (8):
Figure 441072DEST_PATH_IMAGE023
formula (8).
Sorting all angles in the angle set from small to large, and selecting the angle with the n/2 th sequence number from the angle sorting as a reference angle
Figure 99586DEST_PATH_IMAGE024
. Sequentially to other angles in the angle set
Figure 592885DEST_PATH_IMAGE024
And (3) performing difference to obtain an absolute value of the error of the angle, wherein a specific calculation formula is shown as a formula (9):
Figure 627837DEST_PATH_IMAGE025
formula (9).
Absolute value of error
Figure 195084DEST_PATH_IMAGE026
Sorting according to the sequence from small to large and setting an error absolute value sieveSelecting a ratio threshold value of
Figure 149134DEST_PATH_IMAGE027
For example, the screening ratio threshold for the absolute value of the error is 30%; then, the quantity is reserved from small to large according to the absolute value of the error as
Figure 5094DEST_PATH_IMAGE028
The preset caliper point of the non-locator segment of (a). The relationship between the error absolute value screening ratio threshold and the remaining number of non-locator segment preset caliper points is shown in the following formula (10):
Figure 702792DEST_PATH_IMAGE029
formula (10).
The embodiment can effectively eliminate the pre-edge points on the inner side and the outer side of the pre-edge line by filtering the pre-edge points, and reserve the pre-edge points meeting the requirements, so that the quasi-edge points of the QR code are obtained, and the positioning accuracy and the positioning precision of the QR code are improved.
Performing filtering processing on all the pre-edge points on the pre-edge line, and determining quasi-edge points of the pre-edge line based on the filtering result, as shown in fig. 16; for any pre-margin line: performing linear fitting based on the quasi-edge points to obtain quasi-edge lines; each pre-edge line is provided with a corresponding quasi-edge line; calculating the intersection point of every two aligned edge lines according to the clockwise sequence; determining quasi-angular points of the QR code according to the intersection result of any two quasi-edge lines, as shown in FIG. 17; and determining the accurate corner points as the positioning result of the QR code.
It should be understood that, in the embodiments of the present invention, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and the inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
It should be noted that the method in the embodiment of the present invention is applicable not only to the QR code in the transmission scene, but also to the QR code positioning in the curved scene or the oblique scene, and thus the applicability of the QR code positioning is improved.
Fig. 18 is a schematic block diagram of a positioning apparatus for a QR code according to an embodiment of the present invention. A positioning apparatus of a QR code, the apparatus 180 comprising: the coarse positioning module 181 is configured to perform coarse positioning on the QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code; the detection module 182 is configured to perform sampling processing on any pre-edge line to obtain a plurality of pre-edge points, and perform locator detection on the pre-edge line to obtain a first detection result; the first determining module 183 is configured to determine a pre-edge point of a locator segment on the pre-edge line as a quasi-edge point if the first detection result represents that locators are distributed at both ends of the pre-edge line; the second determining module 184 is configured to, if the first detection result represents that only one end of the pre-edge line has the locator, perform filtering processing on the plurality of pre-edge points to obtain quasi-edge points; and a third determining module 185, configured to determine a positioning result of the QR code based on the quasi-edge points of all the pre-edge lines.
In an alternative embodiment, the third determination module 185 includes: a fitting unit for, for any pre-edge line: performing linear fitting based on the quasi-edge points to obtain quasi-edge lines; the first determining unit is used for determining an alignment corner point of the QR code according to the intersection result of any two alignment edge lines; and the second determining unit is used for determining the accurate corner point as a positioning result of the QR code.
In an alternative embodiment, the pre-edge line includes a locator segment and a non-locator segment; the second determination module 184 includes: the determining unit is used for determining the pre-edge points of the locator segments as quasi-edge points and selecting any quasi-edge point as a reference point; the selecting unit is used for determining an angle between a pre-edge point and a reference point aiming at any pre-edge point of the non-locator segment; and selecting an angle meeting a preset condition from the plurality of angles, and determining a pre-edge point corresponding to the angle as a quasi-edge point.
In an alternative embodiment, the selecting unit includes: the reference subunit is used for sequencing a plurality of angles from small to large and determining the angle positioned in the middle of the angle sequencing as a reference angle; and the determining subunit is used for determining the absolute value of the error between the angle and the reference angle according to any angle, the selecting subunit is used for sequencing a plurality of absolute values of the error from small to large, selecting the absolute values of the error meeting the preset number from the error sequencing, and determining the angle corresponding to the absolute value of the error as the angle meeting the preset condition.
In an alternative embodiment, the detection module 182 includes: a detection unit for, for any pre-edge line: performing locator detection, and determining preset caliper points of the preset edge line based on a second detection result to obtain a plurality of preset caliper points; a sampling unit for any preset caliper point: collecting edge points along the searching direction according to the direction from the outside to the inside of the edge; selecting edge points with the largest pixel gradient from the acquired edge points as candidate edge points, wherein the searching direction is used for indicating the normal direction which passes through the preset caliper point and is perpendicular to the preset edge line; the selecting unit is used for selecting candidate edge points with pixel gradient larger than a first preset threshold value from the candidate edge points of the pre-edge line as the pre-edge points.
In an alternative embodiment, the detection unit comprises: the first setting subunit is used for setting a first preset number of preset caliper points on the locator segment along the extension direction of the pre-edge line if the second detection result represents that the locators are distributed at both ends of the pre-edge line; and the second setting subunit is used for setting a first preset number of preset caliper points on the locator segment along the extension direction of the pre-edge line if the first detection result represents that only one end of the pre-edge line is provided with the locator, and setting a second preset number of preset caliper points on the non-locator segment.
In an alternative embodiment, coarse positioning module 181 includes: the image processing unit is used for carrying out image processing on the QR code to obtain position information of a plurality of locators; the first determining unit is used for determining the position relation between any two locators based on the position information of the locators; a second determining unit configured to, for any locator: determining outer corner points of the locators according to the locator position information and the position relation; and the third determining unit is used for determining a pre-edge line of the QR code based on the sequential connection result of all the outer corner points and determining the pre-edge as a coarse positioning result.
The device can execute the QR code positioning method provided by the embodiment of the invention, and has the corresponding functional module and beneficial effects of executing the fatigue measurement method. For details of the technology that are not described in detail in this embodiment, reference may be made to the QR code positioning method provided in the embodiment of the present invention.
According to still another embodiment of the present invention, there is also provided an electronic apparatus including: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the QR code positioning method provided by the above embodiment of the invention.
Another aspect of the embodiments of the present invention provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, causes the processor to perform at least the following operation steps: s101, carrying out coarse positioning on the QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code; s102, sampling any pre-edge line to obtain a plurality of pre-edge points, and detecting a locator of the pre-edge line to obtain a first detection result; s103, if the first detection result represents that the two ends of the pre-edge line are distributed with the locators, determining the pre-edge points of the locator segments on the pre-edge line as quasi-edge points; s104, if the first detection result represents that only one end of the pre-edge line is distributed with the locator, filtering the edge points on the pre-edge line if the edge points interfere with the pre-edge line to obtain quasi-edge points; and S105, determining the positioning result of the QR code based on the quasi edge points of all the pre-edge lines.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A QR code positioning method is characterized by comprising the following steps:
carrying out coarse positioning on the quick response QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code;
sampling any pre-edge line to obtain a plurality of pre-edge points, and detecting a locator of the pre-edge line to obtain a first detection result;
if the first detection result represents that the two ends of the pre-edge line are distributed with the locators, determining the pre-edge points of the locator segments on the pre-edge line as quasi-edge points; if the first detection result represents that only one end of the pre-edge line is distributed with the locator, filtering the edge points on the pre-edge line if the edge points interfere with the edge lines to obtain quasi-edge points;
and determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines.
2. The method according to claim 1, wherein the determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines comprises:
for any of the pre-edge lines: performing linear fitting based on the quasi edge points to obtain quasi edge lines;
determining an quasi-angular point of the QR code according to the intersection result of any two quasi-edge lines;
and determining the quasi-angular point as a positioning result of the QR code.
3. The method of claim 1, wherein the pre-edge line comprises a locator segment and a non-locator segment; the filtering the edge points if the edge points are interfered on the pre-edge line to obtain the quasi-edge points comprises the following steps:
determining the pre-edge points of the locator segments as quasi-edge points;
selecting any quasi-edge point as a reference point, and determining an angle between the pre-edge point and the reference point aiming at any pre-edge point of the non-locator segment;
and selecting an angle meeting a preset condition from the plurality of angles, and determining a pre-edge point corresponding to the angle as a quasi-edge point.
4. The method according to claim 3, wherein the selecting the angle satisfying the preset condition from the plurality of angles comprises:
sequencing a plurality of angles in a sequence from small to large, and determining the angle positioned in the middle of the angle sequencing as a reference angle;
determining, for any angle, an absolute value of an error between the angle and the reference angle;
and sequencing the plurality of error absolute values in a descending order, selecting the error absolute values meeting the preset number from the error sequencing, and determining the angle corresponding to the error absolute value as the angle meeting the preset condition.
5. The method according to claim 1, wherein the sampling for any of the pre-edge lines to obtain a plurality of pre-edge points comprises:
for any of the pre-edge lines: performing locator detection, and determining preset caliper points of the preset edge line based on a second detection result to obtain a plurality of preset caliper points;
for any of the preset caliper points: collecting edge points along the searching direction according to the direction from the outside to the inside of the edge; selecting edge points with the largest pixel gradient from the acquired edge points as candidate edge points, wherein the searching direction is used for indicating the normal direction which passes through the preset caliper point and is perpendicular to the preset edge line;
and selecting candidate edge points with the pixel gradient larger than a first preset threshold value from the candidate edge points of the pre-edge line as pre-edge points.
6. The method of claim 5, wherein the determining the preset caliper point of the pre-edge line based on the second detection result comprises:
if the second detection result represents that the two ends of the pre-edge line are distributed with the locators, setting a first preset number of preset caliper points on the locator segments along the extension direction of the pre-edge line;
if the second detection result represents that only one end of the pre-edge line is distributed with the locator, a first preset number of preset caliper points are arranged on the locator segment along the extension direction of the pre-edge line, and a second preset number of preset caliper points are arranged on the non-locator segment.
7. The method according to claim 1, wherein the coarsely positioning the QR code to obtain a coarsely positioning result comprises:
carrying out image processing on the QR code to obtain position information of a plurality of locators;
determining the position relation between any two locators based on the position information of the locators;
for any locator: determining outer corner points of the locators according to the locator position information and the position relation;
and determining a pre-edge line of the QR code based on the results of the sequential connection of all the outer corner points, and determining the pre-edge as a coarse positioning result.
8. A QR code positioning apparatus, comprising:
the coarse positioning module is used for performing coarse positioning on the quick response QR code to obtain a coarse positioning result; the coarse positioning result comprises a plurality of pre-edge lines of the QR code;
the detection module is used for sampling any pre-edge line to obtain a plurality of pre-edge points and detecting a locator of the pre-edge line to obtain a first detection result;
the first determining module is used for determining the pre-edge point of the locator segment on the pre-edge line as a quasi-edge point if the first detection result represents that locators are distributed at both ends of the pre-edge line;
the second determining module is used for filtering a plurality of pre-edge points to obtain quasi-edge points if the first detection result represents that only one end of the pre-edge line is distributed with a locator;
and the third determining module is used for determining the positioning result of the QR code based on the quasi-edge points of all the pre-edge lines.
9. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-7.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202110682471.5A 2021-06-21 2021-06-21 QR code positioning method and device and computer readable medium Active CN113139400B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110682471.5A CN113139400B (en) 2021-06-21 2021-06-21 QR code positioning method and device and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110682471.5A CN113139400B (en) 2021-06-21 2021-06-21 QR code positioning method and device and computer readable medium

Publications (2)

Publication Number Publication Date
CN113139400A true CN113139400A (en) 2021-07-20
CN113139400B CN113139400B (en) 2021-10-15

Family

ID=76815845

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110682471.5A Active CN113139400B (en) 2021-06-21 2021-06-21 QR code positioning method and device and computer readable medium

Country Status (1)

Country Link
CN (1) CN113139400B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104517108A (en) * 2013-09-29 2015-04-15 北大方正集团有限公司 Method and system for determining edge line of QR code binarized image
CN104966089A (en) * 2015-06-24 2015-10-07 福建联迪商用设备有限公司 Two-dimensional code image edge detection method and device
CN105373793A (en) * 2015-11-25 2016-03-02 暨南大学 Vertex positioning method for QR code image geometric correction
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN112085708A (en) * 2020-08-19 2020-12-15 浙江华睿科技有限公司 Method and equipment for detecting defects of straight line edge in product outer contour

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104517108A (en) * 2013-09-29 2015-04-15 北大方正集团有限公司 Method and system for determining edge line of QR code binarized image
CN104966089A (en) * 2015-06-24 2015-10-07 福建联迪商用设备有限公司 Two-dimensional code image edge detection method and device
CN105373793A (en) * 2015-11-25 2016-03-02 暨南大学 Vertex positioning method for QR code image geometric correction
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN112085708A (en) * 2020-08-19 2020-12-15 浙江华睿科技有限公司 Method and equipment for detecting defects of straight line edge in product outer contour

Also Published As

Publication number Publication date
CN113139400B (en) 2021-10-15

Similar Documents

Publication Publication Date Title
US10438038B2 (en) Decoding method and system for QR code with one damaged position detection pattern
JP4301775B2 (en) Two-dimensional code reading device, two-dimensional code reading method, two-dimensional code reading program, and recording medium for the program
KR100828539B1 (en) Detection method of two dimensional code, detection device thereof, and storage medium having detection program storaged therein
CN101155238B (en) Image region detection method and device therefor
CN109215016B (en) Identification and positioning method for coding mark
CN102521838A (en) Image searching/matching method and system for the same
JP2011113197A (en) Method and system for image search
WO2005076214A1 (en) Method and system for image processing for profiling with uncoded structured light
CN107092905B (en) Method for positioning instrument to be identified of power inspection robot
EP3163604B1 (en) Position detection apparatus, position detection method, information processing program, and storage medium
CN114792104A (en) Method for identifying and decoding ring-shaped coding points
CN114549400A (en) Image identification method and device
CN113139400B (en) QR code positioning method and device and computer readable medium
Collins et al. Site model acquisition and extension from aerial images
JP6011885B2 (en) Code reading apparatus and code reading method
CN112560839A (en) Automatic identification method and system for reading of pointer instrument
CN113033233B (en) Positioning method, device and storage medium for geometric deformation QR code
CN108664940A (en) A kind of partial fingerprints matching process and system
CN111199163A (en) Edge detection and positioning identification method of annular code
JPH03192474A (en) Three-dimensional shape measuring system
CN115511902A (en) Angular point feature extraction method and system
CN111401377B (en) Meter data reading method and device, electronic equipment and storage medium
CN116863176B (en) Image template matching method for digital intelligent manufacturing
JP4552409B2 (en) Image processing device
CN109934036A (en) A kind of method and system for distinguishing QR code by single position sensing figure

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 310051 8 / F, building a, 1181 Bin'an Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Zhejiang Huarui Technology Co.,Ltd.

Address before: 310051 8 / F, building a, 1181 Bin'an Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant before: ZHEJIANG HUARAY TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant