CN110263597B - Quick and accurate QR (quick response) code correction method and system - Google Patents

Quick and accurate QR (quick response) code correction method and system Download PDF

Info

Publication number
CN110263597B
CN110263597B CN201910564802.8A CN201910564802A CN110263597B CN 110263597 B CN110263597 B CN 110263597B CN 201910564802 A CN201910564802 A CN 201910564802A CN 110263597 B CN110263597 B CN 110263597B
Authority
CN
China
Prior art keywords
image
line
coordinates
row
pixel
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.)
Active
Application number
CN201910564802.8A
Other languages
Chinese (zh)
Other versions
CN110263597A (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 Youxiang Computing Technology Co ltd
Original Assignee
Shenzhen Youxiang Computing 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 Youxiang Computing Technology Co ltd filed Critical Shenzhen Youxiang Computing Technology Co ltd
Priority to CN201910564802.8A priority Critical patent/CN110263597B/en
Publication of CN110263597A publication Critical patent/CN110263597A/en
Application granted granted Critical
Publication of CN110263597B publication Critical patent/CN110263597B/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/146Methods for optical code recognition the method including quality enhancement steps
    • 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/146Methods for optical code recognition the method including quality enhancement steps
    • G06K7/1473Methods for optical code recognition the method including quality enhancement steps error correction

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (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 Processing (AREA)

Abstract

The invention provides a quick and accurate QR code correction method and system, comprising the following steps: scanning a binary image A (x, y) of the QR code to obtain central pixel coordinates of three position detection graphs in the image A (x, y); solving the first type pixel coordinate of the fourth vertex in the image A (x, y); solving a second type of pixel coordinates of a fourth vertex in the image A (x, y); carrying out weighted average on the first pixel coordinate and the second pixel coordinate of the fourth vertex in the image A (x, y) to obtain the pixel coordinate of the fourth vertex in the image A (x, y); performing anti-perspective transformation on four vertexes in the image A (x, y) to obtain standard pixel coordinates of the four vertexes; and (4) solving a perspective transformation matrix according to the original pixel coordinates and the standard pixel coordinates of the four vertexes in the image A (x, y), and obtaining a corrected standard image. The calculation process is simple and more accurate, the defects of the existing QR code correction method can be effectively overcome, and the method has high practical value. The invention is applied to the technical field of image processing and computer vision.

Description

Quick and accurate QR (quick response) code correction method and system
Technical Field
The invention relates to the technical field of image processing and computer vision, in particular to a quick and accurate QR code correction method and system.
Background
With the coming of the information age, the progress of computer science and the intellectualization of mobile phones, the barcode technology comes along. The bar code technology is an important method for automatically acquiring information. Barcodes are generally classified into one-dimensional barcodes and two-dimensional barcodes according to the difference of information storage dimensions. Compared with a one-dimensional bar code, the two-dimensional bar code has the advantages of large storage capacity, strong confidentiality, low cost and good reliability.
China's exploration of two-dimensional barcode technology started in the last 90 th century, starting late. However, due to the rapid development of science and technology in China, the rapid rise of the logistics industry and the popularization of smart phones, the application of the two-dimensional bar code technology in China is increasingly wide. At present, the two-dimensional barcode occupying the major market in China is a QR code. The QR code is one of matrix two-dimensional bar codes, namely QR, namely 'Quick Response', and has the meaning of Quick Response. The QR code is the first barcode that directly encodes non-english characters, and thus the barcode is mainly applied to many asian countries such as china, japan, korea, and the like.
The main task of QR code recognition is to perform a series of arithmetic operations on the acquired QR code image to acquire the information contained therein. The whole recognition system mainly comprises 3 parts: image preprocessing algorithm, positioning algorithm and correction algorithm. Where the correction algorithm is an essential key component. This is because the QR code image acquired in the image acquisition process often has various linear and nonlinear distortions due to the error of the acquisition equipment itself and the error caused by environmental factors and human factors. These distortions can have a large impact on the accuracy of the image.
At present, Hough transformation is mostly adopted in a correction algorithm to obtain edge information and an inclination angle of an image, the effect is general, the accuracy is not high, and the subsequent decoding process is directly influenced.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a quick and accurate QR code correction method and system.
The technical scheme is as follows:
a quick and accurate QR code correction method comprises the following steps:
step 101, scanning and clustering a binarized image A (x, y) of a QR code to obtain pixel coordinates of three vertexes in the image A (x, y), namely central pixel coordinates of three position detection graphs in the QR code image;
102, solving a first type of pixel coordinate of a fourth vertex in the image A (x, y) according to the pixel coordinates of the three vertices in the image A (x, y) and a parallelogram rule;
103, obtaining a peripheral straight line of the image A (x, y) according to the pixel coordinates of the three vertexes in the image A (x, y), and obtaining a second type of pixel coordinates of a fourth vertex in the image A (x, y) according to the pixel coordinates of the three vertexes in the image A (x, y) and the slope of the peripheral straight line;
104, carrying out weighted average on the first pixel coordinate and the second pixel coordinate of the fourth vertex in the image A (x, y) to obtain the pixel coordinate of the fourth vertex in the image A (x, y);
105, performing inverse perspective transformation on four vertexes in the image A (x, y) to obtain standard pixel coordinates of the four vertexes;
and 106, solving a perspective transformation matrix according to the original pixel coordinates and the standard pixel coordinates of the four vertexes in the image A (x, y), and obtaining a corrected standard image according to the perspective transformation matrix.
Further preferably, in step 101, the scanning and clustering are performed on the binarized image a (x, y) of the QR code to obtain pixel coordinates of three vertices in the image a (x, y), specifically:
step 201, scanning an image A (x, y) line by line, connecting adjacent pixels with the same color in the same line, and forming a plurality of black and white line segments in each line;
step 202, screening five continuous line segments with the length ratio of 1:1:3:1:1 in each line as a line segment group, screening the initial pixel coordinates of the line segments with the length ratio of 3 in each line segment group as line cluster coordinates, carrying out line clustering on all the line cluster coordinates under the condition of the distance between the line cluster coordinates, and taking three categories containing the first three line cluster coordinates as line scanning results;
step 203, scanning the image A (x, y) row by row, connecting adjacent pixels with the same color in the same row, and forming a plurality of black and white line segments in each row;
step 204, screening five continuous line segments with the length ratio of 1:1:3:1:1 in each row to serve as a row line segment group, screening the initial pixel coordinates of the line segments with the length ratio of 3 in each row line segment group to serve as row clustering coordinates, carrying out row clustering on all the row clustering coordinates under the condition of the distance between the line segments, and taking three categories containing the row clustering coordinates with the number of the first three as row scanning results;
step 205, finding the intersection of the line scanning result and the column scanning result to obtain three clustered binary images, and calculating the central pixel coordinates of the three clustered binary images, that is, the pixel coordinates of three vertexes in the image a (x, y).
Further preferably, in step 202, the line clustering coordinates are clustered on the condition that the distance between the line clustering coordinates is less than 4; in step 204, the row clustering coordinates are subjected to row clustering under the condition that the distance between the row clustering coordinates and the column clustering coordinates is less than 4.
Further preferably, in step 102, the first type pixel coordinates of the fourth vertex in the image a (x, y) are:
dot4_1=(x 04_1 ,y 04_1 )=(x 02 +x 03 -x 01 ,y 02 +y 03 -y 01 )
in the formula,(x 04_1 ,y 04_1 ) Is the first type of pixel coordinate of the fourth vertex in image A (x, y); (x) 01 ,y 01 ) Is the pixel coordinate of the first vertex dot1 in image A (x, y); (x) 02 ,y 02 ) Is the pixel coordinate of the second vertex dot2 in image A (x, y); (x) 03 ,y 03 ) Is the pixel coordinate of the third vertex dot3 in the image a (x, y), wherein the point dot2 and the point dot3 are located on a diagonal line in the QR code image.
Further preferably, the step 103 specifically includes:
step 301, scanning the column where the dot1 is located from bottom to top, and recording the start pixel coordinate (x) of the second black line segment 01 1 ,y 01 ) The column in which dot2 is located is scanned from bottom to top, and the start pixel coordinate (x) of the second black segment is recorded 02 2 ,y 02 ) And calculating the slope angle theta of a connecting line between the point dot1 and the point dot2 12
Step 302, in theta 12 Taking the obtained wave step length as a center, wherein the wave step length is 0.1 degree, the whole wave step length does not exceed 1 degree, and a slope angle set containing 21 angle values is obtained;
step 303, calculate the point (x) 01 1 ,y 01 ) Respectively taking 21 angle values of the slope angle set as slope angles for one point on the straight line to obtain 21 straight lines;
step 304, calculate the point (x) 02 2 ,y 02 ) Respectively taking 21 angle values of the slope angle set as slope angles for one point on the straight line to obtain 21 straight lines, and combining the straight lines obtained in the step 303 to obtain 42 straight lines;
step 305, screening out the straight line which is most intersected with the image A (x, y) from the 42 straight lines as a peripheral straight line between the point dot1 and the point dot2, and recording the slope n theta of the straight line 12
Step 306, obtaining a peripheral straight line between the point dot1 and the point dot3 by the same method as the steps 301 to 305, and recording the slope n theta 13
307, marking the slope of two peripheral straight lines as n theta according to the pixel coordinates of three vertexes dot1, dot2 and dot3 12 And n θ 13 The coordinates of the last vertex of a quadrilateral, i.e., the coordinates dot4_2 (x) of the second type of pixel of the fourth vertex in image A (x, y) can be determined 04_2 ,y 04_2 )。
Further preferably, in step 104, the pixel coordinates of the fourth vertex in the image a (x, y) are:
ndot4=t×dot4_1+(1-t)×dot4_2
wherein t is a weighting factor.
Further preferably, in step 105, the standard pixel coordinates of the four vertices are dot1 ═ 4, dot2 ═ 4, LTH-3, dot3 ═ LTH-3,4, and dot4 ═ LTH-3, where LTH is the side length of the standard image.
Further preferably, the process of obtaining the side length LTH of the standard image is as follows:
step 401, calculating the side length lth of the image a (x, y):
Figure BDA0002109235450000031
in the formula (I), the compound is shown in the specification,
Figure BDA0002109235450000032
(ii) represents the total length of all line segments in the same row or column, and v (i) represents the length of the first line segment in a group of row or column line segments in that row or column;
step 402, for LTH, in an array which is incremented by 4, the nearest integer is found as LTH.
A quick and accurate QR code correction system comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the steps of the method when executing the computer program.
The invention has the beneficial technical effects that:
the method respectively obtains the pixel coordinate of the fourth vertex in the QR code image through a method based on a parallelogram rule and a method based on peripheral straight line information of the QR code image, then performs weighting processing on two pixel coordinates of the fourth vertex to obtain a final coordinate, obtains a perspective transformation matrix through the pixel coordinates of the four vertices, and finally corrects the original image of the QR code according to the perspective transformation matrix.
Drawings
FIG. 1 is a diagram illustrating a symbol structure of a QR code in this embodiment;
FIG. 2 is a schematic structural diagram of a QR code position detection pattern in the present embodiment;
FIG. 3 is a schematic flow diagram of a method for rapid and accurate QR code correction;
FIG. 4 is a flow chart of a process for determining pixel coordinates of three vertices;
FIG. 5 is a diagram illustrating the relationship between three cluster centers in this embodiment;
fig. 6 is a flowchart illustrating the process of obtaining the second type of pixel coordinate of the fourth vertex.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more clearly understood, the present invention is further described in detail with reference to the following specific embodiments and accompanying drawings. It should be noted that, in the drawings or the description, the undescribed contents and parts of english are abbreviated as those well known to those skilled in the art. Some specific parameters given in the present embodiment are merely exemplary, and the values may be changed to appropriate values accordingly in different embodiments.
Reading in a preliminarily positioned binary image A (x, y) containing a QR code, wherein in the acquisition process of the QR code image, the positioned image vertex generally has burrs and a small amount of noise to a certain degree. Therefore, if the entire image is scanned directly and the obtained vertex of the outermost periphery is directly used as the outermost periphery point in the process of identifying the QR code region, a very large error occurs.
As shown in fig. 1-2, the QR code symbol is a two-dimensional barcode array composed of a series of square blocks, in which the position detection patterns are alternately changed in depth from 1:1:3:1:1, and this property is stable in the case where the image distortion is not too severe and the rotation is arbitrary.
In this embodiment, the whole image is scanned row by row and column by column, 3 vertexes are found according to the characteristics of the QR code image, then coordinates of the 4 th vertex are obtained by two different methods, the two results are weighted and averaged, the accuracy of the calculation result is improved, finally, a transformation matrix is calculated according to the coordinates of the 4 vertexes, and the QR code image is corrected according to the transformation matrix, referring to fig. 3, which specifically includes the following steps:
step 101, scanning and clustering a binarized image A (x, y) of a QR code to obtain pixel coordinates of three vertexes in the image A (x, y), namely central pixel coordinates of three position detection graphs in the QR code image;
102, solving a first type of pixel coordinate of a fourth vertex in the image A (x, y) according to the pixel coordinates of the three vertices in the image A (x, y) and a parallelogram rule;
103, obtaining a peripheral straight line of the image A (x, y) according to the pixel coordinates of the three vertexes in the image A (x, y), and obtaining a second type of pixel coordinates of a fourth vertex in the image A (x, y) according to the pixel coordinates of the three vertexes in the image A (x, y) and the slope of the peripheral straight line, wherein the contour line of the image A (x, y) indicated by the peripheral straight line of the image A (x, y) after the peripheral blank area is removed;
104, performing weighted average on the first pixel coordinate and the second pixel coordinate of the fourth vertex in the image A (x, y) to obtain the pixel coordinate of the fourth vertex in the image A (x, y);
105, performing inverse perspective transformation on four vertexes in the image A (x, y) to obtain standard pixel coordinates of the four vertexes;
and step 106, obtaining a perspective transformation matrix according to the original pixel coordinates and the standard pixel coordinates of the four vertexes in the image A (x, y), and obtaining a corrected standard image according to the perspective transformation matrix.
Referring to fig. 4, in step 101, scanning and clustering are performed on the binarized image a (x, y) of the QR code to obtain pixel coordinates of three vertices in the image a (x, y), specifically:
step 201, scanning the image a (x, y) line by line, connecting adjacent pixels with the same color in the same line, and forming a plurality of black and white line segments in each line because pixel points of the binary image a (x, y) are not black, namely white;
step 202, screening five continuous line segments with the length ratio of 1:1:3:1:1 in each line as a line segment group, screening the initial pixel coordinates of the line segments with the length ratio of 3 in each line segment group as line cluster coordinates, carrying out line clustering on all the line cluster coordinates under the condition of the distance between the line cluster coordinates, and taking three categories containing the first three line cluster coordinates as line scanning results;
taking the first row as an example, assuming that the first row is divided into m line segments, the number of pixels of each line segment is represented by a one-dimensional vector (v ═ v 1 ,v 2 ,...,v m ) If the ratio of the number of pixels of a line segment to the number of pixels of the next 4 line segments is found to satisfy 1:1:3:1:1, a certain serial number i exists, so that
v(i):v(i+1):v(i+2):v(i+3):v(i+4)=1:1:3:1:1
The method comprises the steps of screening out the initial pixel coordinates of a line segment with the serial number of i +2 as line cluster coordinates, summarizing and clustering the line cluster coordinates in each line, and taking three categories with the number of the line cluster coordinates being three as line scanning results, wherein the line cluster coordinates are clustered under the condition that the distance between the line cluster coordinates is smaller than 4, and therefore the obtained three line scanning results are clusters of the pixel coordinates of three position detection graphs obtained under the condition of line-by-line scanning.
Step 203, scanning the image A (x, y) column by column, connecting adjacent pixels with the same color in the same column, and forming a plurality of black and white line segments in each column;
204, screening five continuous line segments with the length ratio of 1:1:3:1:1 in each row to serve as a row line segment group, screening the initial pixel coordinates of the line segments with the length ratio of 3 in each row line segment group to serve as row clustering coordinates, carrying out row-column clustering on all the row clustering coordinates under the condition that the distance between the row clustering coordinates and the column clustering coordinates is less than 4, and taking three categories with the number of the row clustering coordinates being three as row scanning results; the three column scan results obtained here, i.e. the clustering of the pixel coordinates of the three position detection profiles obtained in case of column-by-column scanning, are the same principle as in step 201-202.
Step 205, obtaining the intersection of the line scanning result and the column scanning result to obtain three clustered binary images, and calculating the central pixel coordinates of the three clustered binary images, that is, the pixel coordinates of three vertexes in the image a (x, y), that is, the coordinates of the central pixels of the three position detection graphs in the QR code graph; referring to fig. 5, in this embodiment, dot1, dot2, and dot3 are used to represent central pixel points of three position detection patterns, where dot2 and dot3 are located on a diagonal line in a QR code image, and the specific calculation process is as follows:
Figure BDA0002109235450000061
in the formula, N 1 Is the total number of all pixel points in the first cluster intersection; x' 1 And y' 1 Respectively is the horizontal and vertical coordinates of each pixel point in the first cluster intersection, and the dot1 is recorded as (x) 01 ,y 01 ) Is the central pixel of the first cluster intersection, i.e. the first vertex; the same method can determine the center pixel dot2 of the second cluster intersection (x) 02 ,y 02 ) I.e. the second vertex; the central pixel dot3 intersecting the third cluster (x) 03 ,y 03 ) I.e. the third vertex.
In step 102, the first type pixel coordinate of the fourth vertex in the image a (x, y) is:
dot4_1=(x 04_1 ,y 04_1 )=(x 02 +x 03 -x 01 ,y 02 +y 03 -y 01 )
wherein (x) 04_1 ,y 04_1 ) Is the first type of pixel coordinate of the fourth vertex in image A (x, y); (x) 01 ,y 01 ) Is the pixel coordinate of the first vertex dot1 in image A (x, y); (x) 02 ,y 02 ) Is the pixel coordinate of the second vertex dot2 in image A (x, y); (x) 03 ,y 03 ) Is the pixel coordinate of the third vertex dot3 in the image a (x, y), wherein the point dot2 and the point dot3 are located on a diagonal line in the QR code image.
Referring to fig. 6, in step 103, a peripheral slope is calculated according to peripheral information of the QR barcode, and then a second-type pixel coordinate of a fourth vertex is calculated according to coordinate information of 3 vertices dot1, dot2, and dot3 and peripheral slope information, which includes the following processes:
step 301, two points dot1 and dot2 form a straight line, the line where the point dot1 is located is scanned from bottom to top, the line sequentially passes through a black line segment, a white line segment and a black line segment, and the initial pixel coordinate (x) of the second black line segment is recorded 01 1 ,y 01 ) (ii) a Similarly, scanning the column where dot2 is located from bottom to top also sequentially passes through the black line segment, the white line segment, and the black line segment, and records the initial pixel coordinate (x) of the second black line segment 02 2 ,y 02 ) Simultaneously, the slope angle theta of the connecting line between the point dot1 and the point dot2 is obtained 12
Figure BDA0002109235450000071
Step 302, with θ 12 As a center, the fluctuation step is 0.1 degree, the whole is not more than 1 degree, and a slope angle set containing 21 angle values is obtained, specifically, { theta [ [ theta ] ] [ ] 12 -1,θ 12 -0.9,θ 12 -0.8,...,θ 12 -0.1,θ 1212 +0.1,...,θ 12 +0.8,θ 12 +0.9,θ 12 +1};
Step 303, calculate the point (x) 01 1 ,y 01 ) Respectively taking 21 angle values of the slope angle set as slope angles for one point on the straight line to obtain 21 straight lines;
step 304, calculate the point (x) 02 2 ,y 02 ) Respectively taking 21 angle values of the slope angle set as slope angles for one point on the straight line to obtain 21 straight lines, and combining the straight lines obtained in the step 303 to obtain 42 straight lines;
step 305, screening out the intersection of 42 straight lines and the image A (x, y)The most concentrated line is taken as the peripheral line between point dot1 and point dot2, and its slope n θ is recorded 12
Step 306, obtaining a peripheral straight line between the point dot1 and the point dot3 by the same method as the steps 301 to 305, and recording the slope n theta 13
Step 307, marking the pixel coordinates of the three vertexes dot1, dot2 and dot3 and the slopes of the two peripheral straight lines as n theta 12 And n θ 13 The coordinates of the last vertex of a parallelogram, i.e. the coordinates dot4_2(x, y) of the second type of pixel of the fourth vertex in image A (x, y) can be found 04_2 ,y 04_2 )。
In step 104, the pixel coordinates of the fourth vertex in image a (x, y) are:
ndot4=t×dot4_1+(1-t)×dot4_2。
in step 105, on the premise of the known four vertices dot1, dot2, dot3, and dot4, the standard pixel coordinates of the four vertices are dot1 ═ (4,4), dot2 ═ 4, LTH-3, dot3 ═ LTH-3,4, and dot4 ═ LTH-3, where LTH is the side length of the standard image, and the standard image is a square of LTH × LTH, where the side length LTH of the standard image is obtained by:
step 401, calculating the side length lth of the image a (x, y):
Figure BDA0002109235450000072
in the formula (I), the compound is shown in the specification,
Figure BDA0002109235450000073
(ii) represents the total length of all line segments in the same row or column, and v (i) represents the length of the first line segment in a set of row or column line segments in that row or column;
step 402, for LTH, finding the nearest integer as LTH in an array with 4 increments. Where the 4 increments are {1,5,9,13,17,21,25, 29.., 177}, e.g., where LTH is 24.1, then LTH is the closest integer of 25.
In step 106, the relationship between the original image, the perspective transformation matrix and the corrected standard image is:
Figure BDA0002109235450000081
in the formula, the coordinates of the original image are (x, y), the coordinates of the standard image are (p, q), H is a perspective transformation matrix, and omega is a scale factor;
wherein, the perspective transformation matrix can be calculated according to the original pixel coordinates and the standard pixel coordinates of the four vertexes.
The above description of the preferred embodiments of the invention has been included for the purpose of illustrating the technical features of the invention in detail, and it is not intended to limit the inventive content to the specific forms described in the embodiments, and other modifications and variations made in accordance with the spirit of the inventive content may be protected by this patent. The subject matter of the present disclosure is defined by the claims, not by the detailed description of the embodiments.

Claims (9)

1. A quick and accurate QR code correction method is characterized by comprising the following steps:
step 101, scanning and clustering a binary image A (x, y) of a QR code to obtain pixel coordinates of three vertexes in the image A (x, y), namely central pixel coordinates of three position detection graphs in the QR code image;
102, solving a first type of pixel coordinate of a fourth vertex in the image A (x, y) according to the pixel coordinates of the three vertices in the image A (x, y) and a parallelogram rule;
103, obtaining a peripheral straight line of the image A (x, y) according to the pixel coordinates of the three vertexes in the image A (x, y), and obtaining a second type of pixel coordinates of a fourth vertex in the image A (x, y) according to the pixel coordinates of the three vertexes in the image A (x, y) and the slope of the peripheral straight line;
104, carrying out weighted average on the first pixel coordinate and the second pixel coordinate of the fourth vertex in the image A (x, y) to obtain the pixel coordinate of the fourth vertex in the image A (x, y);
105, performing inverse perspective transformation on four vertexes in the image A (x, y) to obtain standard pixel coordinates of the four vertexes;
and step 106, obtaining a perspective transformation matrix according to the original pixel coordinates and the standard pixel coordinates of the four vertexes in the image A (x, y), and obtaining a corrected standard image according to the perspective transformation matrix.
2. The quick and accurate QR code correction method according to claim 1, wherein in step 101, the scanning and clustering are performed on the binarized image a (x, y) of the QR code to obtain pixel coordinates of three vertices in the image a (x, y), specifically:
step 201, scanning an image A (x, y) line by line, connecting adjacent pixels with the same color in the same line, and forming a plurality of black and white line segments in each line;
step 202, screening out five continuous line segments with the length ratio of 1:1:3:1:1 in each line as a line segment group, screening out the initial pixel coordinate of the line segment with the length ratio of 3 in each line segment group as a line clustering coordinate, carrying out line clustering on all the line clustering coordinates under the condition of the distance between the line segment groups, and taking three categories containing the first three line clustering coordinates as line scanning results;
step 203, scanning the image A (x, y) row by row, connecting adjacent pixels with the same color in the same row, and forming a plurality of black and white line segments in each row;
step 204, screening out five continuous line segments with the length ratio of 1:1:3:1:1 in each row as a row line segment group, screening out the initial pixel coordinate of the line segment with the length ratio of 3 in each row line segment group as a row clustering coordinate, carrying out row clustering on all the row clustering coordinates under the condition of the distance between the line segments, and taking three categories containing the first three row clustering coordinates as row scanning results;
step 205, finding the intersection of the line scanning result and the column scanning result to obtain three clustered binary images, and calculating the central pixel coordinates of the three clustered binary images, that is, the pixel coordinates of three vertexes in the image a (x, y).
3. The method for quickly and accurately correcting the QR code according to claim 2, wherein in step 202, the row clustering coordinates are clustered under the condition that the distance between the row clustering coordinates is less than 4; in step 204, the row clustering coordinates are subjected to row clustering under the condition that the distance between the row clustering coordinates and the column clustering coordinates is less than 4.
4. The method for quick and accurate QR code correction according to claim 1, wherein in step 102, the first type pixel coordinate of the fourth vertex in the image A (x, y) is:
dot4_1=(x 04_1 ,y 04_1 )=(x 02 +x 03 -x 01 ,y 02 +y 03 -y 01 )
wherein (x) 04_1 ,y 04_1 ) Is the first type of pixel coordinate of the fourth vertex in image A (x, y); (x) 01 ,y 01 ) Is the pixel coordinate of the first vertex dot1 in image A (x, y); (x) 02 ,y 02 ) Is the pixel coordinate of the second vertex dot2 in image A (x, y); (x) 03 ,y 03 ) Is the pixel coordinate of the third vertex dot3 in the image a (x, y), wherein the point dot2 and the point dot3 are located on a diagonal line in the QR code image.
5. The method for quickly and accurately correcting the QR code according to claim 4, wherein the step 103 specifically comprises:
step 301, scanning the column where the dot1 is located from bottom to top, and recording the start pixel coordinate (x) of the second black line segment 01 1 ,y 01 ) Scanning the column where dot2 is located from bottom to top, and recording the starting pixel coordinate (x) of the second black segment 02 2 ,y 02 ) And calculating the slope angle theta of a connecting line between the point dot1 and the point dot2 12
Step 302, with θ 12 Taking the obtained wave step length as a center, wherein the wave step length is 0.1 degree, the whole wave step length does not exceed 1 degree, and a slope angle set containing 21 angle values is obtained;
step 303, calculate the point (x) 01 1 ,y 01 ) Respectively taking 21 angle values of the slope angle set as slope angles for one point on the straight line to obtain 21 straight lines;
step 304, with point (x) 02 2 ,y 02 ) Respectively taking 21 angle values of the slope angle set as slope angles for one point on the straight line to obtain 21 straight lines, and combining the straight lines obtained in the step 303 to obtain 42 straight lines;
step 305, screening out the straight line which is most intersected with the image A (x, y) from the 42 straight lines as a peripheral straight line between the point dot1 and the point dot2, and recording the slope n theta of the straight line 12
Step 306, obtaining a peripheral straight line between the point dot1 and the point dot3 by the same method as the steps 301 to 305, and recording the slope n theta 13
Step 307, marking the pixel coordinates of the three vertexes dot1, dot2 and dot3 and the slopes of the two peripheral straight lines as n theta 12 And n θ 13 The coordinates of the last vertex of a quadrilateral, i.e. the coordinates dot4_2 (x) of the second type of pixel of the fourth vertex in image A (x, y) can be determined 04_2 ,y 04_2 )。
6. The method for quickly and accurately correcting the QR code according to claim 5, wherein in the step 104, the pixel coordinate of the fourth vertex in the image A (x, y) is as follows:
ndot4=t×dot4_1+(1-t)×dot4_2
wherein t is a weighting factor.
7. The method for rapidly and accurately correcting the QR code according to claim 2, wherein the coordinates of the standard pixels of the four vertices in step 105 are dot1 ═ (4,4), dot2 ═ (4, LTH-3), dot3 ═ (LTH-3,4), and dot4 ═ (LTH-3 ), where LTH is the side length of the standard image.
8. The quick and accurate QR code correction method according to claim 7, wherein the length LTH of the side of the standard image is obtained by the following steps:
step 401, calculating the side length lth of the image a (x, y):
Figure FDA0002109235440000031
in the formula (I), the compound is shown in the specification,
Figure FDA0002109235440000032
(ii) represents the total length of all line segments in the same row or column, and v (i) represents the length of the first line segment in a group of row or column line segments in that row or column;
step 402, for LTH, finding the nearest integer as LTH in an array with 4 increments.
9. A fast and accurate QR code correction system comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method according to any one of claims 1 to 8 when executing the computer program.
CN201910564802.8A 2019-06-27 2019-06-27 Quick and accurate QR (quick response) code correction method and system Active CN110263597B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910564802.8A CN110263597B (en) 2019-06-27 2019-06-27 Quick and accurate QR (quick response) code correction method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910564802.8A CN110263597B (en) 2019-06-27 2019-06-27 Quick and accurate QR (quick response) code correction method and system

Publications (2)

Publication Number Publication Date
CN110263597A CN110263597A (en) 2019-09-20
CN110263597B true CN110263597B (en) 2022-08-19

Family

ID=67922064

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910564802.8A Active CN110263597B (en) 2019-06-27 2019-06-27 Quick and accurate QR (quick response) code correction method and system

Country Status (1)

Country Link
CN (1) CN110263597B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113378595B (en) * 2020-03-10 2023-09-22 顺丰科技有限公司 Two-dimensional code positioning method, device, equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101398895A (en) * 2007-09-26 2009-04-01 杨高波 Image preprocess method based on data matrix two-dimension bar code identification

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100828539B1 (en) * 2005-09-20 2008-05-13 후지제롯쿠스 가부시끼가이샤 Detection method of two dimensional code, detection device thereof, and storage medium having detection program storaged therein

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101398895A (en) * 2007-09-26 2009-04-01 杨高波 Image preprocess method based on data matrix two-dimension bar code identification

Also Published As

Publication number Publication date
CN110263597A (en) 2019-09-20

Similar Documents

Publication Publication Date Title
CN107633192B (en) Bar code segmentation and reading method based on machine vision under complex background
US6778703B1 (en) Form recognition using reference areas
CN108920992B (en) Deep learning-based medicine label bar code positioning and identifying method
CN105989317B (en) Two-dimensional code identification method and device
CN110348264B (en) QR two-dimensional code image correction method and system
US20050199729A1 (en) Reconstruction of virtual raster
CN108573511B (en) Point-distributed cooperative coding mark and identification and positioning method thereof
CN108256375B (en) One-dimensional bar code scanning method
CN113506276B (en) Marker and method for measuring structural displacement
US20040086182A1 (en) Barcode detection system
CN102763121B (en) Method for decoding a linear bar code
CN109190434B (en) Bar code recognition algorithm based on sub-pixel level corner detection
CN111311497B (en) Bar code image angle correction method and device
CN101833644A (en) Correction graph searching method based on dynamic template
CN110263597B (en) Quick and accurate QR (quick response) code correction method and system
US20060043189A1 (en) Method and apparatus for determining the vertices of a character in a two-dimensional barcode symbol
CN112419225B (en) SOP type chip detection method and system based on pin segmentation
CN112101058B (en) Automatic identification method and device for test paper bar code
Bodnár et al. A novel method for barcode localization in image domain
CN110969612B (en) Two-dimensional code printing defect detection method
CN202267974U (en) Positioning system used for two-dimension code and two-dimension code identification device
CN112597868A (en) Test paper identification and correction method based on no positioning point
CN111178111A (en) Two-dimensional code detection method, electronic device, storage medium and system
CN116110069A (en) Answer sheet identification method and device based on coding mark points and relevant medium thereof
CN112800798B (en) Aztec code positioning method

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