A method, apparatus, device, and medium for parsing reflective QR code images.

Through binarization and edge detection of QR code images, combined with inverse perspective transformation and morphological feature matching, the problem of low success rate of QR code parsing under strong light is solved, and higher parsing accuracy and anti-interference capabilities are achieved.

CN114548136BActive Publication Date: 2024-10-29XIAMEN STAR SMART TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111368352.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2024-10-29
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

In outdoor strong light scenes, the QR code parsing algorithm has a low parsing success rate due to strong reflection interference. Existing methods fail to effectively consider the global information of the image and the perspective projection changes, resulting in unsatisfactory performance.

Method used

By binary processing and edge detection of QR code images, morphological features and inverse perspective transformation are used to determine the change trend of straight line perspective, match the position of Pattern point pairs and locate the fourth point pair, and estimate the change of perspective straight line angle based on the global information of the image. , improve Pattern positioning accuracy and anti-interference ability.

Benefits of technology

It greatly improves the success rate of QR code parsing in strong light environments, enhances the anti-interference ability against local reflections, and significantly improves the robustness of QR code parsing compared to existing algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114548136B_ABST
    Figure CN114548136B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, equipment and medium for analyzing a reflective two-dimensional code image, and the method includes: S1, performing binarization processing on the two-dimensional code image to obtain a binary image, and performing edge detection on the binary image to obtain an edge image; S2, performing two-dimensional code pattern detection on the binary image to obtain the coordinates of a pattern candidate point that may be a pattern, and calculating the coordinates of the pattern center according to the morphological characteristics of the binary image; the edge image is also subjected to inverse perspective transformation, and the linear perspective change trend is determined; S3, matching the positions of three pattern point pairs in the binary image according to the coordinates of the pattern candidate points and the linear perspective transformation trend; S4, locating the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective transformation trend. Since the present invention utilizes the global information of the two-dimensional code edge image, the successful analysis of the two-dimensional code can still be guaranteed under the interference of a strong lighting environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for analyzing a reflective two-dimensional code image. Background Art

[0002] The general process of current QR code parsing technology is: first perform QR code target detection on the input image to obtain the QR code ROI (Region of interest), then perform a binarization algorithm on the ROI to obtain a binary image. Perform a pattern detection algorithm on the binary QR code image to obtain the QR code pattern position. According to the size and relative position of the QR code pattern, estimate the original size of the QR code. Then perform perspective correction and matrix conversion on the QR code image to obtain a BitMatrix.

[0003] However, in outdoor strong light scenes, the QR code images captured by the camera usually have strong reflections. In the QR code parsing algorithm process, strong reflections often cause serious interference to the QR code perspective correction algorithm, resulting in the inability to parse the QR code under strong light outdoors.

[0004] In the current mainstream QR code recognition and parsing algorithms, perspective correction is usually based on the method of calculating the homography matrix of corresponding point pairs.

[0005] Mainstream method 1: Use the pattern detection algorithm to obtain three of the four point pairs required to solve the homography matrix, and then obtain the fourth point required to calculate the homography matrix through estimation and multiple attempts. The effect is poor in scenes with strong reflections and large perspective angles, with a parsing success rate of about 12%, and the performance is very unsatisfactory. An important reason why the mainstream algorithm fails for highly reflective QR codes is that the global information of the image and the changes in perspective projection on the two-dimensional image are not considered when estimating the fourth corresponding point pair.

[0006] Mainstream method 2: Solve the homography matrix by using the four corner points of the QR code outer contour as corresponding point pairs. This method does not take into account possible environmental interference (such as reflections) and cluttered backgrounds in the image, and has poor robustness.

[0007] Therefore, it is very meaningful if the successful parsing of the QR code can still be guaranteed under the interference of a strong lighting environment. Summary of the invention

[0008] The technical problem to be solved by the present invention is to provide a method, device, equipment and medium for parsing reflective two-dimensional code images, which can still ensure the successful parsing of the two-dimensional code under the interference of a strong light environment.

[0009] In a first aspect, the present invention provides a method for parsing a reflective two-dimensional code image, comprising the following steps:

[0010] S1, performing binarization processing on the two-dimensional code image to obtain a binary image, and performing edge detection on the binary image to obtain an edge image;

[0011] S2, performing a two-dimensional code pattern detection on the binary image to obtain the coordinates of the pattern candidate points that may be the pattern, and calculating the coordinates of the center of the pattern according to the morphological features of the binary image;

[0012] Also performing an inverse perspective transformation on the edge map and determining a linear perspective change trend;

[0013] S3, obtaining positions of three pattern point pairs by matching the coordinates of the pattern candidate points and the linear perspective change trend in the binary image;

[0014] S4. Locate the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective change trend.

[0015] In a second aspect, the present invention provides a device for analyzing a reflective two-dimensional code image, characterized in that it includes:

[0016] A preprocessing module, used for performing binarization processing on the two-dimensional code image to obtain a binary image, and performing edge detection on the binary image to obtain an edge image;

[0017] A morphological feature processing module, used to perform two-dimensional code pattern detection on the binary image, obtain the coordinates of the pattern candidate points that may be the pattern, and calculate the coordinates of the center of the pattern according to the morphological features of the binary image;

[0018] An inverse perspective transformation module, used to perform inverse perspective transformation on the edge map and determine the linear perspective change trend;

[0019] A pattern point pair matching module, used for matching the positions of three pattern point pairs in the binary image according to the coordinates of the pattern candidate points and the linear perspective change trend;

[0020] The fourth point pair positioning module is used to locate the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective change trend.

[0021] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.

[0022] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.

[0023] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: the present invention first binarizes the two-dimensional code to obtain a binary image, and matches the two-dimensional code pattern point pairs on the binary image based on the prior knowledge of the vanishing point and the perspective projection theorem, thereby improving the accuracy of pattern positioning; then edge detection is performed on the binary image to obtain an edge image, and the global information of the edge image can be used to locate the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the perspective change trend of the straight line, thereby parsing the entire two-dimensional code image. This method of estimating the perspective straight line angle change trend based on the global information of the image can parse the entire two-dimensional code image as long as the local reflection does not affect the matching of the three pattern point pairs. Compared with other existing parsing algorithms, it greatly improves the anti-interference ability of the two-dimensional code local reflection.

[0024] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.

[0026] Figure 1 is a flow chart of the method in Embodiment 1 of the present invention;

[0027] Figure 2 Schematic diagram of the state of detecting straight lines in an edge map using the Hough straight line transformation algorithm in an embodiment of the present invention, wherein (a) is a horizontal straight line in the detected edge map, and (b) is a vertical straight line in the detected edge map;

[0028] Figure 3 Schematic diagram of the definition of the polar coordinate accumulation plane, where (a) is a schematic diagram of the state of a certain point of the image represented in the linear coordinate system, (b) is a schematic diagram of the state of lines 1, 2, 3, and 4 through point A (X0, Y0) in the linear coordinate system, and (c) is a schematic diagram of the state of lines 1, 2, 3, and 4 when they are represented as four points 1, 2, 3, and 4 in the polar coordinate system ρ-θ;

[0029] Figure 4 Schematic diagram of the state of straight lines mapped to the Hough plane, where (a) and (b) are schematic diagrams of the state of horizontal straight line group and vertical straight line group mapped to the Hough plane respectively;

[0030] Figure 5 A schematic diagram of the state of calculating the eigenvalues ​​of each eigenvector by accumulating the plane to calculate the line parameters of all data points for the horizontal line;

[0031] Figure 6 A schematic diagram of the process of selecting the correct coordinate pairing through a straight line perspective trend;

[0032] Figure 7 It is a schematic diagram of the state of the parallel straight lines in the three-dimensional space on the edge diagram of the two-dimensional code intersecting at the vanishing point on the two-dimensional plane after perspective projection;

[0033] Figure 8 A schematic diagram of the state of making an estimated line through the vanishing point and the center point of the lower left pattern;

[0034] Fig. 9 The schematic diagram of the state of making estimation lines in the horizontal and vertical directions and obtaining the fourth positioning point, and parsing the obtained QR code;

[0035] Fig.10 It is a structural schematic diagram of the device in the second embodiment of the present invention;

[0036] Fig.11 This is a schematic diagram of the structure of an electronic device in Embodiment 3 of the present invention;

[0037] Fig.12 Schematic diagram of the structure of the medium in the fourth embodiment of the present invention. DETAILED DESCRIPTION

[0038] The embodiments of the present application provide a method, device, equipment and medium for parsing a reflective two-dimensional code image, which can ensure successful parsing of the two-dimensional code under the interference of a strong lighting environment.

[0039] The technical solution in the embodiment of the present application has the following general idea: first, the two-dimensional code is binarized to obtain a binary image, and the two-dimensional code pattern point pairs are matched on the binary image based on the prior knowledge of the vanishing point and the perspective projection theorem, thereby improving the accuracy of pattern positioning; then, the binary image is edge detected to obtain an edge image, and the global information of the edge image can be used to locate the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the trend of straight line perspective changes, thereby parsing the entire two-dimensional code image. This method of estimating the trend of perspective straight line angle changes based on the global information of the image can parse the entire two-dimensional code image as long as the local reflection does not affect the matching of the three pattern point pairs. Compared with other existing parsing algorithms, it greatly improves the anti-interference ability of the two-dimensional code local reflection. Embodiment 1

[0040] like Figure 1As shown, this embodiment provides a method for parsing a reflective two-dimensional code image, comprising the following steps:

[0041] S1. Binarize the two-dimensional code image to obtain a binary image, and perform edge detection on the binary image to obtain an edge image; specifically:

[0042] In a large image, the SSD (Single Shot MultiBox Detector) target detection model is used to capture the QR code image, and the FastWindows algorithm is used to calculate the binary image. The Canny edge detection algorithm is then used to detect the edge of the binary image to obtain the edge image.

[0043] S2, performing a two-dimensional code pattern detection on the binary image to obtain the coordinates of the pattern candidate points that may be the pattern, and calculating the coordinates of the center of the pattern according to the morphological features of the binary image;

[0044] Also performing an inverse perspective transformation on the edge map and determining a linear perspective change trend;

[0045] S3, obtaining positions of three pattern point pairs by matching the coordinates of the pattern candidate points and the linear perspective change trend in the binary image;

[0046] S4. Locate the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective change trend.

[0047] Among them, as a better or more specific implementation of this embodiment, the method also has the following characteristics:

[0048] In step S2, the inverse perspective transformation of the edge map is specifically performed as follows:

[0049] S21, applying the Hough straight line transform algorithm to detect straight lines in the edge image, including horizontal straight lines and vertical straight lines;

[0050] like Figure 2 (a) in the figure shows a horizontal straight line in the edge map. Figure 2 As shown in (b) in the figure, it is a vertical straight line in the edge map.

[0051] S22, grouping the horizontal straight lines and the vertical straight lines to obtain a horizontal straight line group and a vertical straight line group; mapping the horizontal straight line group and the vertical straight line group to the Hough plane respectively, and each straight line is represented as a data point; wherein, mapping the horizontal straight line group to the Hough plane means that each straight line in the horizontal straight line group is represented by a data point (ρ, θ) in the accumulation coordinate system to obtain a horizontal straight line accumulator plane; mapping the vertical straight line group to the Hough plane means that each straight line in the vertical straight line group is represented by a data point (ρ, θ) in the accumulation coordinate system to obtain a vertical straight line accumulator plane;

[0052] The cumulative coordinate system is a polar coordinate system, with the abscissa being ρ and the ordinate being θ;

[0053] The so-called Hough line transform is to represent the straight lines in the detected image in the form of a polar coordinate accumulation plane. Figure 3 As shown, this is the definition of the polar coordinate accumulation plane: Figure 3 As shown in (a) in the figure, a point in the image is represented as A(X0, Y0) in the linear coordinate system. Figure 3 As shown in (b) in the figure, draw straight lines 1, 2, 3, and 4 through point A (X0, Y0) in the linear coordinate system, as shown in Figure 3 As shown in (c) in the figure, straight lines 1, 2, 3, and 4 are represented by four points 1, 2, 3, and 4 in the polar coordinate system ρ-θ.

[0054] like Figure 4 As shown, mapping a straight line to the Hough plane means representing the straight line with a data point (ρ, θ) in the cumulative coordinate system, such as Figure 4 As shown in (a) and (b) in the figure, the horizontal straight line group and the vertical straight line group are mapped to the state of the Hough plane respectively.

[0055] S23. Perform PCA principal component analysis on the data points in the two Hough planes, and calculate the main vector direction of each data point as the straight line perspective change trend; specifically: calculate the eigenvalue of each eigenvector according to the line parameters ρ and θ of all data points (ρ, θ) in the horizontal straight line accumulator plane or the vertical straight line accumulator plane, and take the eigenvector with the largest eigenvalue as the main eigenvector and as the straight line angle change trend; then use the general equation of the straight line to represent the main eigenvector, and calculate the θ parameter corresponding to the straight line according to the known straight line ρ parameter.

[0056] like Figure 5As shown, taking the horizontal straight line accumulation plane as an example, the straight line parameters ρ and θ of all data points (ρ, θ) are calculated to calculate the eigenvalues ​​(indicated by the length of the arrow) of each eigenvector (indicated by the direction of the arrow). Since the horizontal straight line is two-dimensional data, two eigenvectors can be calculated (the left arrow and the downward arrow each represent an eigenvector). The eigenvectors are sorted from large to small according to the eigenvalue. The length of the left arrow is greater than the length of the downward arrow, indicating that the left eigenvector is the largest and is retained as the trend of the straight line angle change, while the downward eigenvector is discarded. Using the general equation of the straight line to represent the main eigenvector, the θ parameter corresponding to the straight line can be calculated based on the known straight line ρ parameter.

[0057] The step S3 specifically comprises:

[0058] S31, randomly selecting three points from the Pattern candidate points as a group of possible Pattern pairing points;

[0059] S32, according to the perspective straight line angle transformation trend, draw a horizontal straight line and a vertical straight line through the first point, and calculate the distances from the second point and the third point to the straight line and the vertical straight line respectively;

[0060] S33, judging the size between the distance and a preset threshold value, if the distance is less than the preset threshold value, accepting the group of Pattern pairing points, if the distance is greater than the preset threshold value, excluding the group of Pattern pairing points, selecting the next group of possible Pattern pairing points, and returning to S32 until a group of Pattern pairing points is received or all possible combinations of Pattern pairing points are exhausted.

[0061] like Figure 6 As shown below, an example is given to illustrate the process of screening the correct coordinate pairing through the straight line perspective trend:

[0062] like Figure 6 As shown in (a), it is assumed that after pattern detection, five candidate point coordinates A, B, C, D, and E that may be the pattern are obtained;

[0063] like Figure 6 As shown in (b), D, C, and E are randomly selected as a group of possible pattern pairing points. According to the perspective straight line angle transformation trend, horizontal and vertical straight lines are drawn through one point D, and then the distances from point E and point C to the horizontal and vertical straight lines are calculated respectively. The size between the distance and the preset threshold is determined. If the judgment result is that the distance is greater than the preset threshold, the group of pattern pairing points D, C, and E is excluded, and the next group of possible pattern pairing points is selected;

[0064] like Figure 6As shown in (c) in the figure, A, B, and C are randomly selected as a possible pattern pairing. According to the perspective straight line angle transformation trend, horizontal and vertical straight lines are drawn through point A respectively. The distances from point B and point C to the horizontal and vertical straight lines are calculated respectively. The size between the distance and the preset threshold is determined. If the judgment result is that the distance is less than the threshold, the pattern pairing A, B, and C is accepted. Figure 6 As shown in (d) in the figure, the positions of points A, B, and C are taken as the positions of three pattern point pairs and the process ends.

[0065] The step S4 specifically comprises:

[0066] S41, in the edge map, draw a horizontal estimation line through the vanishing point of the horizontal straight line group and the pattern center of the lower left pattern point pair, and draw a vertical estimation line through the vanishing point of the vertical straight line group and the pattern center of the upper right pattern point pair, and obtain the intersection of the horizontal estimation line and the vertical estimation line, and use the intersection as the position of the fourth pattern point pair required for transformation;

[0067] S42, calculating the homography matrix based on the positions of the four Pattern point pairs, and performing inverse perspective transformation to obtain the parsed QR code image.

[0068] Among them, Figure 7 As shown in the figure, the parallel straight lines in the three-dimensional space on the QR code edge map (contour map) meet at one point on the two-dimensional plane after perspective projection, which is called the vanishing point.

[0069] like Figure 8 As shown, an estimated line is made through the vanishing point and the center point of the lower left pattern. According to the perspective projection theorem, the straight line is parallel to the top and bottom edges of the outer contour of the QR code square in three-dimensional space.

[0070] like Fig. 9 As shown in the figure, we make estimation lines in the horizontal and vertical directions respectively, and the intersection of the estimated lines is the fourth positioning point required for the transformation. Then the homography matrix is ​​calculated from the four corresponding point pairs, and the inverse perspective transformation is performed to obtain Fig. 9 The right picture in the figure is the QR code diagram obtained by parsing.

[0071] Based on the same inventive concept, the present application also provides a device corresponding to the method in Example 1, see Example 2 for details. Embodiment 2

[0072] like Fig.10 As shown, in this embodiment, a device for analyzing a reflective two-dimensional code image is provided, comprising:

[0073] A preprocessing module, used for performing binarization processing on the two-dimensional code image to obtain a binary image, and performing edge detection on the binary image to obtain an edge image;

[0074] A morphological feature processing module, used to perform two-dimensional code pattern detection on the binary image, obtain the coordinates of the pattern candidate points that may be the pattern, and calculate the coordinates of the center of the pattern according to the morphological features of the binary image;

[0075] An inverse perspective transformation module, used to perform inverse perspective transformation on the edge map and determine the linear perspective change trend;

[0076] A pattern point pair matching module, used for matching the positions of three pattern point pairs in the binary image according to the coordinates of the pattern candidate points and the linear perspective change trend;

[0077] The fourth point pair positioning module is used to locate the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective change trend.

[0078] Among them, as a better or more specific implementation of this embodiment, the device also has the following characteristics:

[0079] The specific process of the inverse perspective transformation module performing inverse perspective transformation on the edge map is:

[0080] S21, applying the Hough straight line transform algorithm to detect straight lines in the edge image, including horizontal straight lines and vertical straight lines;

[0081] S22, grouping the horizontal straight lines and the vertical straight lines to obtain a horizontal straight line group and a vertical straight line group; mapping the horizontal straight line group and the vertical straight line group to the Hough plane respectively, and each straight line is represented as a data point; wherein, mapping the horizontal straight line group to the Hough plane means that each straight line in the horizontal straight line group is represented by a data point (ρ, θ) in the cumulative coordinate system to obtain a horizontal straight line accumulator plane; mapping the vertical straight line group to the Hough plane means that each straight line in the vertical straight line group is represented by a data point (ρ, θ) in the cumulative coordinate system to obtain a vertical straight line accumulator plane; the cumulative coordinate system is a polar coordinate system, with the horizontal coordinate being ρ and the vertical coordinate being θ;

[0082] S23. Perform PCA principal component analysis on the data points in the two Hough planes, and calculate the main vector direction of each data point as the straight line perspective change trend; specifically: calculate the eigenvalue of each eigenvector according to the line parameters ρ and θ of all data points (ρ, θ) in the horizontal straight line accumulator plane or the vertical straight line accumulator plane, and take the eigenvector with the largest eigenvalue as the main eigenvector and as the straight line angle change trend; then use the general equation of the straight line to represent the main eigenvector, and calculate the θ parameter corresponding to the straight line according to the known straight line ρ parameter.

[0083] The Pattern point pair matching module specifically implements the following process:

[0084] S31, randomly selecting three points from the Pattern candidate points as a group of possible Pattern pairing points;

[0085] S32, according to the perspective straight line angle transformation trend, draw a horizontal straight line and a vertical straight line through the first point, and calculate the distances from the second point and the third point to the straight line and the vertical straight line respectively;

[0086] S33, judging the size between the distance and a preset threshold value, if the distance is less than the preset threshold value, accepting the group of Pattern pairing points, if the distance is greater than the preset threshold value, excluding the group of Pattern pairing points, selecting the next group of possible Pattern pairing points, and returning to S32 until a group of Pattern pairing points is received or all possible combinations of Pattern pairing points are exhausted.

[0087] The fourth point-to-point positioning module specifically implements the following process:

[0088] S41, in the edge map, draw a horizontal estimation line through the vanishing point of the horizontal straight line group and the pattern center of the lower left pattern point pair, and draw a vertical estimation line through the vanishing point of the vertical straight line group and the pattern center of the upper right pattern point pair, and obtain the intersection of the horizontal estimation line and the vertical estimation line, and use the intersection as the position of the fourth pattern point pair required for transformation;

[0089] S42, calculating the homography matrix based on the positions of the four Pattern point pairs, and performing inverse perspective transformation to obtain the parsed QR code image.

[0090] Since the device introduced in the second embodiment of the present invention is a device used to implement the method of the first embodiment of the present invention, those skilled in the art can understand the specific structure and deformation of the device based on the method introduced in the first embodiment of the present invention, so it is not described here in detail. All devices used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.

[0091] Based on the same inventive concept, the present application provides an electronic device embodiment corresponding to the first embodiment, see the third embodiment for details. Embodiment 3

[0092] This embodiment provides an electronic device, such as Fig.11 As shown, it includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any implementation method in the first embodiment can be implemented.

[0093] Since the electronic device introduced in this embodiment is a device used to implement the method in the first embodiment of the present application, based on the method introduced in the first embodiment of the present application, a person skilled in the art can understand the specific implementation of the electronic device of the present embodiment and its various variations, so how the electronic device implements the method in the embodiment of the present application is not described in detail here. As long as a person skilled in the art implements the device used by the method in the embodiment of the present application, it belongs to the scope of protection of the present application.

[0094] Based on the same inventive concept, the present application provides a storage medium corresponding to the first embodiment, see the fourth embodiment for details. Embodiment 4

[0095] This embodiment provides a computer-readable storage medium, such as Fig.12 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, any implementation method in Example 1 can be implemented.

[0096] The technical solution provided in the embodiments of the present application has at least the following technical effects or advantages: firstly, the two-dimensional code is binarized to obtain a binary image, and the two-dimensional code pattern point pairs are matched on the binary image based on the prior knowledge of the vanishing point and the perspective projection theorem, thereby improving the accuracy of pattern positioning; then, the binary image is edge detected to obtain an edge image, and the global information of the edge image can be used to locate the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the perspective change trend of the straight line, thereby parsing the entire two-dimensional code image. This method of estimating the perspective straight line angle change trend based on the global information of the image can parse the entire two-dimensional code image as long as the local reflection does not affect the matching of the three pattern point pairs. Compared with other existing parsing algorithms, it greatly improves the anti-interference ability of the local reflection of the two-dimensional code.

[0097] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices or systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0098] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0099] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0100] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0101] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A method for analyzing reflective QR code images. Features: The steps include: S1, performing binarization processing on the two-dimensional code image to obtain a binary image, and performing edge detection on the binary image to obtain an edge image; S2, performing a two-dimensional code pattern detection on the binary image to obtain the coordinates of the candidate points of the pattern that may be the pattern, and calculating the center coordinates of the pattern according to the morphological features of the binary image; Also performing an inverse perspective transformation on the edge map and determining a linear perspective change trend; S3, obtaining positions of three pattern point pairs by matching the coordinates of the pattern candidate points and the linear perspective change trend in the binary image; S4, locating the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective change trend; In S2, the inverse perspective transformation of the edge map is specifically performed as follows: S21, applying the Hough straight line transform algorithm to detect straight lines in the edge image, including horizontal straight lines and vertical straight lines; S22, grouping the horizontal straight lines and the vertical straight lines to obtain a horizontal straight line group and a vertical straight line group; mapping the horizontal straight line group and the vertical straight line group to the Hough plane respectively, and each straight line is represented as a data point; wherein, mapping the horizontal straight line group to the Hough plane means that each straight line in the horizontal straight line group is represented by a data point (ρ, θ) in the cumulative coordinate system to obtain a horizontal straight line accumulator plane; mapping the vertical straight line group to the Hough plane means that each straight line in the vertical straight line group is represented by a data point (ρ, θ) in the cumulative coordinate system to obtain a vertical straight line accumulator plane; the cumulative coordinate system is a polar coordinate system, with the horizontal coordinate being ρ and the vertical coordinate being θ; S23, performing PCA principal component analysis on the data points in the two Hough planes, and calculating the principal vector direction of each data point as the linear perspective change trend; Specifically, the eigenvalues ​​of each eigenvector are calculated according to the line parameters ρ and θ of all data points (ρ, θ) in the horizontal line accumulator plane or the vertical line accumulator plane, and the eigenvector with the largest eigenvalue is used as the main eigenvector and the line angle change trend; then the main eigenvector is expressed by the general equation of the line, and the θ parameter corresponding to the line is calculated according to the known line ρ parameter; The S3 is specifically: S31, randomly selecting three points from the Pattern candidate points as a group of possible Pattern pairing points; S32, according to the perspective straight line angle transformation trend, draw a horizontal straight line and a vertical straight line through the first point, and calculate the distances from the second point and the third point to the straight line and the vertical straight line respectively; S33, judging the size between the distance and a preset threshold, if the distance is less than the preset threshold, accepting the group of Pattern pairing points, if the distance is greater than the preset threshold, excluding the group of Pattern pairing points, selecting the next group of possible Pattern pairing points, and returning to S32 until a group of Pattern pairing points is received or all possible combinations of Pattern pairing points are exhausted; The S4 is specifically: S41, in the edge map, draw a horizontal estimation line through the vanishing point of the horizontal straight line group and the pattern center of the lower left pattern point pair, and draw a vertical estimation line through the vanishing point of the vertical straight line group and the pattern center of the upper right pattern point pair, and obtain the intersection of the horizontal estimation line and the vertical estimation line, and use the intersection as the position of the fourth pattern point pair required for transformation; S42, calculating the homography matrix based on the positions of the four Pattern point pairs, and performing inverse perspective transformation to obtain the parsed QR code image.

2. A device for analyzing reflective two-dimensional code images, Features: include: A preprocessing module, used for performing binarization processing on the two-dimensional code image to obtain a binary image, and performing edge detection on the binary image to obtain an edge image; A morphological feature processing module, used to perform two-dimensional code pattern detection on the binary image, obtain the coordinates of the pattern candidate points that may be the pattern, and calculate the coordinates of the center of the pattern according to the morphological features of the binary image; An inverse perspective transformation module, used to perform inverse perspective transformation on the edge map and determine the linear perspective change trend; A pattern point pair matching module, used for matching the positions of three pattern point pairs in the binary image according to the coordinates of the pattern candidate points and the linear perspective change trend; A fourth point pair positioning module is used to locate the position of the fourth point pair according to the positions of the three pattern point pairs obtained by matching and the linear perspective change trend; The specific process of the inverse perspective transformation module performing inverse perspective transformation on the edge map is: S21, applying the Hough straight line transform algorithm to detect straight lines in the edge image, including horizontal straight lines and vertical straight lines; S22, grouping the horizontal straight lines and the vertical straight lines to obtain a horizontal straight line group and a vertical straight line group; mapping the horizontal straight line group and the vertical straight line group to the Hough plane respectively, and each straight line is represented as a data point; wherein, mapping the horizontal straight line group to the Hough plane means that each straight line in the horizontal straight line group is represented by a data point (ρ, θ) in the cumulative coordinate system to obtain a horizontal straight line accumulator plane; mapping the vertical straight line group to the Hough plane means that each straight line in the vertical straight line group is represented by a data point (ρ, θ) in the cumulative coordinate system to obtain a vertical straight line accumulator plane; the cumulative coordinate system is a polar coordinate system, with the horizontal coordinate being ρ and the vertical coordinate being θ; S23, performing PCA principal component analysis on the data points in the two Hough planes, and calculating the principal vector direction of each data point as the linear perspective change trend; Specifically, the eigenvalues ​​of each eigenvector are calculated according to the line parameters ρ and θ of all data points (ρ, θ) in the horizontal line accumulator plane or the vertical line accumulator plane, and the eigenvector with the largest eigenvalue is used as the main eigenvector and the line angle change trend; then the main eigenvector is expressed by the general equation of the line, and the θ parameter corresponding to the line is calculated according to the known line ρ parameter; The Pattern point pair matching module specifically implements the following process: S31, randomly select three points from the Pattern candidate points as a set of possible Pattern pairing points; S32, according to the perspective straight line angle transformation trend, draw a horizontal straight line and a vertical straight line through the first point, and calculate the distances from the second point and the third point to the straight line and the vertical straight line respectively; S33, judging the size between the distance and a preset threshold, if the distance is less than the preset threshold, accepting the group of Pattern pairing points, if the distance is greater than the preset threshold, excluding the group of Pattern pairing points, selecting the next group of possible Pattern pairing points, and returning to S32 until a group of Pattern pairing points is received or all possible combinations of Pattern pairing points are exhausted; The fourth point-to-point positioning module specifically implements the following process: S41, in the edge map, draw a horizontal estimation line through the vanishing point of the horizontal straight line group and the pattern center of the lower left pattern point pair, and draw a vertical estimation line through the vanishing point of the vertical straight line group and the pattern center of the upper right pattern point pair, and obtain the intersection of the horizontal estimation line and the vertical estimation line, and use the intersection as the position of the fourth pattern point pair required for transformation; S42, calculating the homography matrix based on the positions of the four Pattern point pairs, and performing inverse perspective transformation to obtain the parsed QR code image.

3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the method according to claim 1 is implemented.

4. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to claim 1 is implemented.

Citation Information

Patent Citations

  • QR code fast positioning detection algorithm

    CN106991460A

  • DM two-dimensional code identification method and device based on image processing

    CN107545207A

  • Two-dimensional code image restoration method, device, computer equipment and storage medium

    CN111539238A