Ring QR code positioning location detection generation and recognition method

Through the detection and recognition method of the position detection and recognition of the ring QR code, the QR code is identified using red extraction and image correction technology, which solves the problem of difficulty in identifying existing QR codes under adverse conditions, and improves fault tolerance and recognition accuracy.

CN114897000BActive Publication Date: 2025-02-18CHENGDU AEROSPACE SIRUI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210557041.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-20
Publication Date
2025-02-18
Estimated Expiration
2042-05-20

AI Technical Summary

Technical Problem

The existing QR codes are difficult to identify and cannot be identified after wrinkling, overlapping, bending, and contamination, and the fault tolerance of the QR code after inserting the visible icon is reduced.

Method used

The ring QR code position detection generation and recognition method is used to generate a red ring QR code through encoding, identification and decoding steps, and the QR code is identified using red extraction and image correction technology, and the QR code information is obtained through the decoding and recognition steps.

Benefits of technology

It effectively solves the problem of QR code identification difficulties caused by uneven paper, overlapping text, bending, wrinkling and contamination, improves the fault tolerance of QR codes, and can effectively identify QR code information when overlapping text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114897000B_ABST
    Figure CN114897000B_ABST
Patent Text Reader

Abstract

The present invention provides a method for detecting, generating and identifying a circular two-dimensional code positioning position, including a coding step, a two-dimensional code identification step and a decoding and identification step; when the method identifies the two-dimensional code, the problem of uneven paper, overlapping text, slight bending and slight wrinkles of the paper, and partial contamination of the two-dimensional code that cannot be identified can be solved. The present technology generates a two-dimensional code and prints it in red. When identifying the two-dimensional code, red is extracted, and then detection and identification are performed based on three solid red center points and one solid center point in the image, and then the image is corrected to solve the problem of image deviation. After the image processing is completed, the two-dimensional code is identified again and decoded according to the rules. The advantage of using red for the two-dimensional code is that it can form an obvious color difference with the black text on the paper, so that even if the two-dimensional code overlaps with the text, the two-dimensional code information can be effectively identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention specifically relates to a method for detecting, generating and identifying a circular two-dimensional code positioning position. Background Art

[0002] With the development of science and technology, QR codes have become a convenient carrier for information dissemination, and the integration of QR codes is getting higher and higher. Users can obtain relevant product information or link to relevant web pages to browse more information by scanning QR codes. At present, when generating QR codes, visual icons are often inserted in the center of the QR code to increase the visual effect and achieve personalization. However, after inserting the visual icon, the information carried by the QR code will be reduced, and the fault tolerance of the QR code will be reduced. Existing QR codes are difficult to recognize or cannot be recognized after wrinkles, text overlap, bending, and contamination occur. Summary of the invention

[0003] The purpose of the present invention is to provide a method for detecting, generating and identifying a circular two-dimensional code positioning position in view of the deficiencies in the prior art, which can well solve the above-mentioned problems.

[0004] In order to achieve the above requirements, the technical solution adopted by the present invention is: to provide a circular two-dimensional code positioning position detection generation and recognition method, the circular two-dimensional code positioning position detection generation and recognition method comprises an encoding step, a two-dimensional code recognition step and a decoding recognition step;

[0005] The encoding steps are as follows:

[0006] S1: Provides coded text content;

[0007] S2: Provides additional required parameter information: character set encoding, error correction level;

[0008] S3: Verify the validity of the text content;

[0009] S4: Obtain a default error correction level L, and obtain the error correction level from the additional parameters to replace the default value;

[0010] S5: Get the default character set encoding and replace the default value with the character set encoding obtained from the additional parameters;

[0011] S6: Get the default encoding mode BYTE;

[0012] S7: Define header information and append content, including: character set encoding 8 bits, data encoding mode 4 bits, data length information 16 bits, statistical string number 8 bits, version information 4 bits;

[0013] S8: define data content information and attach content, the content includes: only the text content information that needs to be encoded;

[0014] S9: append termination information, fill 8 bits, cyclically fill 0xEC and 0x11 data, fill the data bit space, and obtain the final data codeword information;

[0015] S10: Generate error correction codeword information according to the data codeword information, interleave the data in blocks, and obtain final total data codeword information;

[0016] S11: Check whether the data capacity is consistent with the current version;

[0017] S12: Check whether there is currently any padding bit information. If there is any padding bit information, add a corresponding number of bits to fill the bits, and obtain the final codeword data after the padding.

[0018] S13: convert the final codeword information into a 0, 1 array of the current version data capacity to generate the data content of the original drawing;

[0019] S14: Start mask mapping data content;

[0020] S15: Calculate version information, including: version number, error correction level, mask pattern number, BCH error correction code, a total of 20 bits;

[0021] S16: Convert the version information into an array of 0 and 1 data;

[0022] S17: Encapsulate the two-dimensional code object, encapsulate the current error correction level, mask pattern serial number, encoding mode, version information, data content bit information, version bit information, the version bit information includes: version number, error correction level, mask pattern serial number, BCH error correction code, a total of 20 bits of 0, 1 represented data string;

[0023] S18: After the encoding is completed, the QR code object is passed to the data processing program and the image rendering program to render the QR code graphic information.

[0024] The advantages of the circular two-dimensional code positioning position detection generation and recognition method are as follows:

[0025] This method can solve the problems of uneven paper, overlapping text, slight bending and wrinkling of paper, and partial contamination of the QR code when recognizing the QR code. This technology generates a QR code and prints it in red. When recognizing the QR code, red will be extracted, and then detection and recognition will be performed based on the three solid red center points and one solid center point in the image. The image is then corrected to solve the image deviation problem. After the image processing is completed, the QR code is recognized again and decoded according to the rules. The advantage of using red for the QR code is that it can form a significant color difference with the black text on the paper, so that even if the QR code overlaps with the text, the QR code information can be effectively recognized. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The same reference numerals are used in these drawings to represent the same or similar parts. The exemplary embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0027] Figure 1 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown.

[0028] Figure 2 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown.

[0029] Figure 3 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown.

[0030] Figure 4 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown.

[0031] Figure 5 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown.

[0032] Figure 6 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown.

[0033] Figure 7 A schematic diagram of a circular QR code in a method for detecting, generating and identifying a circular QR code according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0034] In order to make the objectives, technical solutions and advantages of the present application more clear, the present application is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0035] In the following description, references to "one embodiment", "an embodiment", "an example", "an example", etc. indicate that the embodiment or example described in this way may include specific features, structures, characteristics, properties, elements or limitations, but not every embodiment or example necessarily includes the specific features, structures, characteristics, properties, elements or limitations. In addition, repeated use of the phrase "according to one embodiment of the present application" may refer to the same embodiment, but does not necessarily refer to the same embodiment.

[0036] For the sake of simplicity, certain technical features well known to those skilled in the art are omitted in the following description.

[0037] According to an embodiment of the present application, a method for detecting, generating and identifying a circular QR code is provided as follows:

[0038] 1. Coding steps

[0039] 1. Provide coded text content;

[0040] 2. Provide additional required parameter information: character set encoding, error correction level;

[0041] 3. Verify the validity of the text content (empty string, character data range, character length limit, etc.);

[0042] 4. Get the default error correction level L, and get the error correction level from the additional parameters to replace the default value;

[0043] 5. Get the default character set encoding and get the character set encoding from the additional parameters to replace the default value;

[0044] 6. Get the default encoding mode BYTE;

[0045] 7. Define the header information and attach the content, including: character set encoding 8 bits, data encoding mode 4 bits, data length information 16 bits, statistical string number 8 bits, version information 4 bits;

[0046] (In order of listing)

[0047] 8. Define data content information and attach content, which includes: only text content information that needs to be encoded;

[0048] 9. Append termination information, fill 8 bits, cyclically fill 0xEC and 0x11 data, fill the data bit space, and obtain the final data codeword information;

[0049] 10. Generate error correction codeword information according to the data codeword information, interleave the data in blocks (interleave the data codeword blocks with the data codeword blocks, and interleave the error correction codeword blocks with the error correction codeword blocks), and obtain the final total data codeword information;

[0050] 11. Check whether the data capacity is consistent with the current version;

[0051] 12. Check whether there is any padding bit information at present. If there is any padding bit information, add the corresponding number of bits to fill (the default value is 0) to obtain the final codeword data after filling;

[0052] 13. Convert the final codeword information into a 0, 1 array of the current version data capacity to generate the data content of the original drawing;

[0053] 14. Start masking data content (including array data of 0 and 1);

[0054] 15. Calculate version information (including: version number, error correction level, mask pattern number, BCH error correction code, a total of 20 bits);

[0055] 16. Convert the version information into an array of 0 and 1 data;

[0056] 17. Encapsulate the QR code object, including the current error correction level, mask pattern number, coding mode, version information, data content bit information (final data codeword information), and version bit information (including version number, error correction level, mask pattern number, BCH error correction code, a total of 20 bits of data string represented by 0 and 1);

[0057] 18. After the encoding is completed, the QR code object is passed to the data processing program and the image rendering program to render the QR code graphic information.

[0058] 2. QR code recognition

[0059] 2.1 Red extraction:

[0060] Purpose: Extract the red ring code from the file for identification

[0061] Implementation: Convert the image format to HSV format,

[0062] For a detailed explanation of HSV, please see Baidu Encyclopedia: Extract the red part;

[0063] 1. Set the maximum and minimum values ​​for extracting red respectively:

[0064] Maximum color range (H=180S=255V=177)

[0065] Minimum color range (H=0S=45V=0)

[0066] 2. Use Imgproc.cvtColor(img,hsv,Imgproc.COLOR_BGR2HSV) to convert the image format;

[0067] 3. Use Imgproc.GaussianBlur(hsv,blur,new Size(3,3),0) to Gaussian blur the image, which can further eliminate noise or impurities;

[0068] 4. Use Core.inRange(blur,new Scalar(min_h,min_s,min_v),new Scalar(max_h,max_s,max_v),range) to extract the Gaussian blurred image according to the red range value;

[0069] 5. Use Core.bitwise_not(range,range); perform binary "not" operation on the extracted image to obtain the black and white image of the ring code. Complete this step to achieve the purpose, see Figure 1 ;

[0070] 2.2 Pre-detection purpose: detect locators, preliminarily organize positioning information, and determine whether the graphics can be further identified; 1. Use Imgproc.threshold(target,target,0,255,Imgproc.THRESH_OTSU); function to binarize the image, so that the image obtained only has two types of images, black and white, with values ​​of 0 and 255 respectively;

[0071] 2. Use Imgproc.findContours(target,contours,hierarchy,

[0072] Imgproc.RETR_TREE,Imgproc.CHAIN_APPROX_TC89_KCOS);

[0073] The function searches for contours in the image and obtains a collection of contours. These contours may be nested, so a tree-like nested structure is set here. We can use the hierarchy variable to obtain the nesting of contours and the contours associated with them; ( Figure 2 1. Filter the contours that meet the characteristics for all contours. The characteristic condition is "having two sub-contours". According to this condition, the entire contour set is traversed and the contours that meet the conditions are stored in another set "contour set that meets the conditions". 3. Filter the contours that meet the circular characteristics from the traversal of "contour set that meets the conditions". The specific characteristics of the circle are as follows:

[0074] (1) Use the Imgproc.approxPolyDP(matOfPoint2f,approx,0.01*Imgproc.arcLength(matOfPoint2f,true),true); function to obtain the closed fitting edge graph composed of the contour points;

[0075] (2) Determine the number of edges of the fitted edge graph. If the number is less than 7 or greater than 16, it does not meet the characteristics of a circle.

[0076] (3) Use Imgproc.contourArea(matOfPoint); function to calculate the area of ​​the contour;

[0077] (4) Use Imgproc.arcLength(matOfPoint2f,true); function to calculate the contour perimeter. If the perimeter is 0, it does not meet the feature.

[0078] (5) Using the roundness ratio formula:

[0079] Roundness ratio = 4*π*(area / (circumference*circumference)); if the value is within the range of 0.93 to 1.2, it meets the characteristics;

[0080] 4. Through the previous step, we get a contour set "contour set that meets the circle feature", see Figure 3 ;

[0081] 5. Find the starting point (the feature is a square image), traverse the "contour set that meets the circular feature" to obtain the grandchild contour of the contour, and use Imgproc.arcLength(new MatOfPoint2f(contours.get(secChild).toArray()),true); calculate the perimeter of the grandchild contour, and finally take the longest one among these perimeters as the starting point. Because the size difference between the starting point and the center image of other locators has been set before the graphic is generated, the graphic of the starting point will always be larger than other locating points, so the contour of the starting point is obtained and its mark is stored;

[0082] 6. Traverse the "contour set that meets the circle feature" and use RotatedRect rect = Imgproc.minAreaRect (new MatOfPoint2f (contour.toArray ())); the function calculates the minimum enclosing rectangle of each contour, and the function return value is taken as rect.center as the center coordinate point information of the contour, and save it to the "locator center coordinate set"; 7. As of the above steps, the identification of the relevant information of the locator is completed and the following data is finally obtained:

[0083] ·Set of center coordinates of the positioning point

[0084] Starting point coordinates

[0085] Total outline collection

[0086] 2.3 Purpose of graphic correction: Due to different shooting angles or actual conditions, the graphics appear tilted or deformed in the 2D plane and cannot be accurately recognized, so the graphics need to be corrected to a recognizable state.

[0087] accomplish:

[0088] 1. Get the center coordinates of the figure. Based on the four coordinate information of the locator in the second step, calculate the center coordinates of the four points. The algorithm is as follows:

[0089] (1) Traverse the four locator coordinates, take the first coordinate point and the other three coordinate points to calculate the midpoint coordinate formula of the line segment between the two points: p2 = {(p1.x-p0.x)^2, (p1.y-p0.y)^2};

[0090] (2) Find the length of the hypotenuse of p2, len = abs(sqrt(p2.x + p2.y)). During the traversal, determine whether the length of len is larger than the previous one. Finally, when jumping out of the traversal, take the largest length and record the current point coordinate pA. This coordinate is considered to be the diagonal coordinate of point 0.

[0091] (3) Use the line segment midpoint coordinate formula to find the center coordinates of the entire code map:

[0092] center(x,y)={(p0.x+pA.x / 2),(p0.y+pA.y) / 2};

[0093] 2. Find the distance from the starting point to the midpoint of the figure using the formula: R = Math.sqrt(Math.pow(Math.abs(center.x-start.x),2)+Math.pow(Math.abs(center.y-start.y),2));

[0094] 3. The formula for finding the degree of the starting point on the circle relative to the horizontal line is: degree = Math.atan2(center.y-start.y,start.x-center.x)*(180 / Math.PI);

[0095] 4. Based on the known "distance between the starting point and the midpoint", "center coordinates" and "degree of the starting point", the ideal coordinates of the other three positioning points are inferred, and the coordinates are calculated in turn using the formula for finding a point on a circle. The formula is as follows:

[0096] (1)Point.x=center.xR*Math.sin(Math.PI*(angle-90)

[0097] / 180);

[0098] (2)Point.y=center.yR*Math.cos(Math.PI*(angle-90)

[0099] / 180);

[0100] Based on the coordinates of the starting point, the second positioning point degree clockwise is the starting point degree - 90, the third positioning point degree is the starting point degree - 180, and the fourth positioning point degree is the starting point degree - 270. In this way, the above formula is applied to obtain the ideal coordinates of the four points;

[0101] 5. Sort the actual locator coordinate points. Based on the ideal coordinate points obtained in the previous step, the distance between each actual coordinate point and the ideal coordinate points 1, 2, 3, and 4 can be calculated in turn. If the current actual coordinate point is close to the first ideal coordinate point after calculation, it is ranked 1, thus obtaining an ordered array of actual coordinate points.

[0102] 6. Combine the two arrays of ideal coordinates and actual coordinates, perform position difference calculation on the two coordinate points that match the order, and finally add up the position difference values. If the difference value is > 5, it means that the graph is irregular and needs to be corrected ( Figure 4 Indicate);

[0103] 7. If there is a deviation, use the affine transformation and other functions provided by opencv to correct the graphics. The specific process is as follows:

[0104] Use Imgproc.getPerspectiveTransform(srcPoints, dstPoints); the function passes in the actual coordinate point and the ideal coordinate point array, and calculates a transformation model M;

[0105] Use Imgproc.warpPerspective(mat,resultMat,m,newSize);

[0106] The function is transformed to finally obtain a corrected image, which can be used for real code recognition. ( Figure 5 is the calibration result).

[0107] 2.4 Code Recognition Purpose: Use the established rule characteristics and the images obtained in the previous two steps to perform the final code recognition.

[0108] accomplish:

[0109] 1. The initial steps of code recognition are basically the same as those of pre-detection. Both require obtaining the locator coordinates and center coordinates. The difference is that the code contour extraction and judgment are added. The specific process is as follows;

[0110] 2. In "Pre-detection" Step 3 When judging whether the contour is a code point contour, the judgment algorithm is as follows:

[0111] (1) First, we need to exclude the contour of the locator. This logic has been known through the rules of two-layer nested contours.

[0112] (2) Use the Imgproc.contourArea(contour) function to calculate the contour area;

[0113] (3) Use the Imgproc.approxPolyDP(newMatOfPoint2f(contour.toArray()),approx,0.001*area,true); function to calculate the contour fitting edge graphics;

[0114] (4) If the number of fitted edges is less than 3 or the area is 0, it is not a code point contour, otherwise it is preliminarily judged to be a code point;

[0115] After obtaining the "preliminary code point contour set", it is necessary to finally determine whether these contours are code points in the subsequent steps;

[0116] 3. Get the information from the previous step, "locator center coordinate set", "all contours", "code point contours", "starting point center coordinates";

[0117] 4. Find the center coordinates of the image. step As mentioned in the figure correction, the "center coordinates of the entire figure" are obtained;

[0118] 5. Calculate the distance from the "starting point" to the "center" and use the formula for the length of the line segment between two points on the coordinate axis to get the value, which is named "radius";

[0119] 6. Roughly calculate the distance between the four code tracks in order to further screen the code contour. Since the spacing between the code tracks is 0.12 times the "radius", the spacing = radius * 0.12. The value can be used to obtain the distance between the four tracks and the center point in turn, as follows:

[0120] (1) Track 1 = Radius - Pitch

[0121] (2) Code track 2 = radius (track where the starting point is located)

[0122] (3) Track 3 = Radius + Pitch

[0123] (4) Track 4 = Radius + 2* Spacing

[0124] (5) Code range = code track 4 + spacing (further screening of code profile basis)

[0125] 7. Traverse the code contour and further filter the code contour. Judge by the code range obtained in the above steps. The process is as follows:

[0126] (1) Use Moments moments = Imgproc.moments(con); calculate the contour image moments, and obtain the image center coordinates of the contour;

[0127] (2) Calculate the distance from the code contour to the midpoint of the image. If the distance is greater than the previously calculated code contour range distance, or less than the distance of code track 1, it means that it is not a code contour and is directly excluded. The specific judgment rule is: if code_r>code_area_range or

[0128] code_r<(code_1_r-top_radius / 2);

[0129] After these steps, the code contours that meet the conditions are filtered out. Figure 6 ;

[0130] 8. Traverse the filtered code points and partition them into four sets according to code track set 1, code track set 2, code track set 3, and code track set 4. The specific algorithm is as follows:

[0131] (1) Subtract the distance between the code point and the midpoint from the distances of the four code tracks calculated previously and take the absolute value to obtain four diff values. The one with the smallest diff value indicates that it is the closest and is classified as the code track.

[0132] (2) Finally, four groups of code contours are obtained;

[0133] 9. At this step, the code recognition starts. The logic is roughly summarized as: clockwise with 5 degrees as a unit scale, get a coordinate point, and then read the color value of the coordinate point. 0 represents data, and 255 represents no data. In this way, the coordinates of four tracks can be obtained in one clockwise movement, and the code recognition will be completed in one traversal. The detailed process is as follows:

[0134] (1) Application

[0135] Imgproc.threshold(mat,thresholdImg,130,255,Imgproc.THRESH_BINARY); The function converts the image into a binary image, whose image value is only 0 (black) or 255 (white);

[0136] (2) Calculate the degree of the starting point, which is abstractly understood as 0 degrees at the starting point of a circle clockwise;

[0137] (3) Calculate the scanning start angle. Set two scanning start angles, one scanNextAngle, as the scanning start angle of the first, second, and third code tracks, and two scanNextAngle4 as the scanning start angle of the fourth code track. The calculation method is:

[0138] ①double scanNextAngle=startPointAngle+2.5;

[0139] ②double scanNextAngle4=startPointAngle-2.5;

[0140] (4) Perform 72 traversals, because 360 / 5=72, and the degree interval where the locator is located (accounting for 20 degrees) will be skipped during the traversal;

[0141] (5) During the traversal, the formula for calculating the coordinates of points on the circle is used to obtain three coordinates for each unit scale. The distance of the first coordinate is -2, the second remains unchanged, and the distance of the third is +2. In this way, the number of sampling points is increased to improve the error tolerance rate and ensure that the color can be effectively read;

[0142] (6) Read the data on code track 1. It is necessary to distinguish between version data and real data. Version data occupies 10-40 degrees and 190-230 degrees.

[0143] (7) Each time a unit scale is traversed, scanNextAngle-=5, scanNextAngle4

[0144] -=5, angleInner+=5 to ensure the continuous accumulation of unit scale;

[0145] (8) After the entire cycle is completed, the coordinate point set of the entire code is obtained, which includes:

[0146] Version 1 coordinate set, version 2 coordinate set, code track 1 coordinate set, code track 2 coordinate set, code track 3 coordinate set, code track 4 coordinate set; 10. Traverse the coordinates in the coordinate set one by one, and read the color value from the binary image according to these coordinates. If one of the three sampling points is 0, the data is 1, otherwise it is 0. Finally, all data sets are read to complete the code recognition; see Figure 7 .

[0147] 3. Decoding and recognition steps

[0148] 1. Get the complete int data array (the complete 0 and 1 data information recognized);

[0149] 2. Verify whether the data features conform to the QR code features;

[0150] 3. Infer the current data version based on the features;

[0151] 4. Copy the data to be parsed and split it into 2 versions and 1 data content;

[0152] 5. Compare the two parsed version information to see if they are the same. If they are the same, you only need to parse the version once. If they are different, you need to guess them separately. If version 1 fails to parse, try to parse version 2.

[0153] 6. Analyze the original version data to obtain the version number, error correction level, and mask pattern number;

[0154] 7. Obtain the version object, error correction level object, and mask information;

[0155] 8. Get the total effective data capacity of the current version (the amount of data that can be accommodated);

[0156] 9. Get the total capacity of time data of the current version (the actual amount of data contained);

[0157] 10. Get the number of remaining bits of the current version (the remaining bits that cannot fully occupy 8 bits);

[0158] 11. Check whether the data length matches;

[0159] 12. Eliminate the mask information to obtain unmasked data;

[0160] 13. Obtain the error correction block information of the current error correction level, and calculate the total number of error correction codewords, the total number of error correction codeword bits, the total number of data codewords, and the total number of data codeword bits;

[0161] 14. Number of check data codeword bits + number of error correction codeword bits + remaining bits = total capacity of valid data;

[0162] 15. Obtain data codeword data, obtain error correction codeword data, and obtain data block object information according to the data codeword, error correction codeword, version, and error correction level (the data block information describes the number of data codewords and the array data information of how many blocks of data codewords correspond to the error correction codeword).

[0163] The above-mentioned embodiments only represent several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the claims.

Claims

1. A method for detecting, generating and identifying a circular two-dimensional code positioning position, characterized in that: It includes encoding steps, QR code recognition steps and decoding and recognition steps; The encoding steps are as follows: S1: Provides coded text content; S2: Provides additional parameter information: character set encoding, error correction level; S3: Verify the validity of the text content; S4: Obtain a default error correction level L, and obtain the error correction level from the additional parameters to replace the default value; S5: Get the default character set encoding and replace the default value with the character set encoding obtained from the additional parameters; S6: Get the default encoding mode BYTE; S7: Define header information and append content, including: character set encoding 8 bits, data encoding mode 4 bits, data length information 16 bits, statistical string number 8 bits, version information 4 bits; S8: define data content information and attach content, the content includes: only the text content information that needs to be encoded; S9: append termination information, fill 8 bits, cyclically fill 0xEC and 0x11 data, fill the data bit space, and obtain the final data codeword information; S10: Generate error correction codeword information according to the data codeword information, interleave the data in blocks, and obtain final total data codeword information; S11: Check whether the data capacity is consistent with the current version; S12: Check whether there is currently any padding bit information. If there is any padding bit information, add a corresponding number of bits to fill the bits, and obtain the final codeword data after the padding. S13: convert the final codeword information into a 0, 1 array of the current version data capacity to generate the data content of the original drawing; S14: Start mask mapping data content; S15: Calculate version information, including: version number, error correction level, mask pattern number, BCH error correction code, a total of 20 bits; S16: Convert the version information into an array of 0 and 1 data; S17: Encapsulate the two-dimensional code object, encapsulate the current error correction level, mask pattern serial number, encoding mode, version information, data content bit information, version bit information, the version bit information includes: version number, error correction level, mask pattern serial number, BCH error correction code, a total of 20 bits of 0, 1 represented data string; S18: After the encoding is completed, the QR code object is passed to the data processing program and the image rendering program to render the QR code graphic information; The steps of QR code recognition specifically include: Steps of red extraction; Pre-detection steps; Steps for image correction; and Steps for code recognition; The steps of pre-detection include: S1: Use the Imgproc.threshold function to binarize the image, so that the image only has two types of images, black and white, with values ​​of 0 and 255 respectively; S2: Use the Imgproc.findContours function to find the contours in the image and obtain a set of contours. These contours may be nested. Filter the contours that meet the characteristics. The characteristic condition is that they have two sub-contours. According to this condition, traverse the entire contour set and store the contours that meet the conditions into another contour set that meets the conditions. S3: traverse the qualified contour set to select the contour that meets the circular feature; S4: Obtain a set of contours that meet the circular feature through the previous step; S5: Find the starting point, traverse the contour set that meets the circular feature to obtain the grandchild contour of the contour, calculate the perimeter of the grandchild contour, and finally take the longest one among these perimeters as the starting point; S6: traverse the contour set that meets the circular feature and calculate the minimum circumscribed rectangle of each contour. The function return value is taken as rect.center as the center coordinate point information of the contour, and it is saved in the locator center coordinate set; S7: After the above steps, the identification of the relevant information of the locator is completed and the following data is finally obtained: The center coordinate set of the positioning point, the starting point coordinates, and the total contour set.

2. The method for detecting, generating and identifying an annular two-dimensional code positioning position according to claim 1, characterized in that: The decoding and identification steps are as follows: S1: Get the complete int data array and identify the complete 0 and 1 data information; S2: Verify whether the data features conform to the QR code features; S3: Infer the current data version based on the features; S4: Copy the data to be parsed and split the data into two versions and one data content; S5: Compare the two parsed version information to see if they are the same. If they are the same, you only need to parse the version once. If they are different, you need to parse them separately. If parsing version 1 fails, try parsing version 2. S6: parse the original version data to obtain the version number, error correction level, and mask pattern serial number; S7: Obtain the version object, error correction level object, and mask information; S8: Obtain the total capacity of valid data of the current version; S9: Get the total capacity of time data of the current version; S10: Obtain the number of remaining bits of the current version, that is, the remaining bits that cannot fully occupy 8 bits; S11: Check whether the data length matches; S12: Eliminate the mask information to obtain unmasked data; S13: Obtain error correction block information of the current error correction level, and calculate the total number of error correction codewords, the total number of error correction codeword bits, the total number of data codewords, and the total number of data codeword bits; S14: Check data code word number + total error correction code word number + remaining number of bits = total valid data capacity; S15: Obtain data codeword data, obtain total error correction codeword data, and obtain data block object information according to the data codeword, error correction codeword, version, and error correction level.

3. The method for detecting, generating and identifying annular two-dimensional code positioning position according to claim 1, characterized in that: The step of red extraction specifically comprises: S1: Set the maximum and minimum values ​​for extracting red respectively: Maximum color range, H=180 S=255 V=177; Minimum color range, H = 0 S = 45 V = 0; S2: Use Imgproc.cvtColor to convert the image format; S3: Use Imgproc.GaussianBlur to Gaussian blur the image, which can further eliminate noise or impurities; S4: Use Core.inRange, new Scalar to extract the Gaussian blurred image according to the red range value; S5: Use Core.bitwise_not to perform a binary "not" operation on the extracted image to obtain a black and white image of the ring code.

4. The method for detecting, generating and identifying an annular two-dimensional code positioning position according to claim 1, characterized in that: The steps of graphic correction include: S1: Get the center coordinates of the graphic and calculate the center coordinates of the four points through the four coordinate information of the locator; S2: Based on the known "distance between the starting point and the midpoint", "center coordinates" and "degree of the starting point", the ideal coordinates of the other three positioning points are inferred, and the coordinates are calculated in turn using the formula for finding a point on a circle; Based on the coordinates of the starting point, the second positioning point degree is the starting point degree minus 90, the third positioning point degree is the starting point degree minus 180, and the fourth positioning point degree is the starting point degree minus 270. Apply the formula to get the ideal coordinates of the four points. S3: Sort the actual locator coordinate points, and based on the ideal coordinate points obtained in the previous step, calculate the distance between each actual coordinate point and the ideal coordinate points 1, 2, 3, and 4 in turn. If the current actual coordinate point is close to the first ideal coordinate point after calculation, then it is ranked 1, thus obtaining an ordered array of actual coordinate points; S4: Combine the two arrays of ideal coordinates and actual coordinates, perform a position difference operation on the two coordinate points that match the order, and finally accumulate these position difference values. If the difference is greater than 5, it means that the figure is irregular and needs to be corrected; S5: If there is a deviation, use the affine transformation function provided by OpenCV to correct the graphics.

5. The method for detecting, generating and identifying an annular two-dimensional code positioning position according to claim 1, characterized in that: The steps of code recognition specifically include: S1: during pre-detection, determine whether the contour is a code point contour and obtain a preliminary code point contour set; S2: Obtain the following information from the previous step: the center coordinate set of the locator, all contours, code point contours, and the center coordinates of the starting point; S3: Find the center coordinates of the image and obtain the center coordinates of the entire figure; S4: Calculate the distance from the starting point to the center, and use the formula for the length of the line segment between two points on the coordinate axis to get the value, which is named radius; S5: Calculate the distances between the four code tracks in order to further screen the code profile. Since the spacing between the code tracks is 0.12 times the radius, the spacing is equal to the radius multiplied by 0.

12. This value can be used to obtain the distances between the four tracks and the center point in turn. S6: traverse the code contour, further filter the code contour, and judge by the obtained code range; S7: traverse the filtered code points and partition the code points into four sets according to code track set 1, code track set 2, code track set 3, and code track set 4; S8: Identify the code. Go clockwise with 5 degrees as a unit scale to obtain a coordinate point, and then read the color value of the coordinate point. 0 represents data, and 255 represents no data. In this way, the coordinates of four tracks can be obtained in one clockwise movement, and the code identification can be completed in one traversal. S9: traverse the coordinates in the coordinate set one by one, and read the color value from the binary image according to these coordinates. If one of the three sampling points is equal to 0, the data is 1, otherwise it is 0. Finally, all data sets are read to complete the code recognition.

Citation Information

Patent Citations

  • Color QR code generation and identification method

    CN111046996A

  • Two-dimensional code generation method and device, and two-dimensional code recognition method and device

    CN113487001A