Two-dimensional code, decoding method and system thereof and storage medium
Through the new QR code design, combined with the center-seeking positioning graphic block and data graphics, the shortcomings of traditional QR codes in capacity, error correction capability and decoding efficiency are solved, and efficient storage and fast decoding of large amounts of data are achieved.
Patent Information
- Application Number
- CN202511214847.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-08-28
AI Technical Summary
Traditional QR codes have low capacity and space utilization, insufficient error correction capabilities, and low scanning and decoding efficiency, and cannot meet the needs of efficient storage and rapid analysis of large amounts of data.
A new QR code design is adopted, including a center-image-finding positioning graphic block and a data graphic. Through the combination of functional graphics and data graphics, the human visual recognition logic is used to quickly lock the code surface range, and the positioning accuracy is verified through the head information graphic block. It supports the design of multiple QR codes being tiled, improving space utilization and recognition rate.
It improves the data storage capacity and recognition speed of QR codes, improves space utilization, reduces positioning errors, and supports efficient storage and fast decoding of large amounts of data.
Smart Images

Figure CN120764573A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of two-dimensional codes, in particular to a two-dimensional code, a decoding method and system thereof and a computer readable storage medium. BACKGROUND
[0002] The QR code (Quick Response Code) widely used at present is a kind of two-dimensional code, which has large storage capacity, low cost, can represent Chinese characters and images and other various text information, has strong security and anti-counterfeiting performance and is very convenient to use, so it has been widely used in various industries. It has the advantages of high information storage density and fast reading speed and is applied in many fields. However, with the advent of the big data era, the demand for storage and transmission of massive data is growing, and the problems of low capacity and space utilization rate of traditional QR codes have gradually become prominent. The traditional QR code still has the following technical limitations: (1) Low capacity and space utilization rate: The traditional QR code only supports a maximum of 177x177 modules, limiting the data capacity. The QR code sets a fixed large positioning pattern in the three corners, has multiple auxiliary positioning blocks in the middle of the code, and occupies about 10%-15% of the code surface space, limiting the space utilization rate; (2) Only supports binary encoding: relies on black and white pixel points, low data density, cannot utilize color or grayscale information; (3) Insufficient error correction capability: fixed 4-level error correction code configuration, large error correction redundancy span, low space utilization rate, long character uses fixed length grouping interleaved encoding, error correction capability can only be optimal in special cases; (4) Low scanning and decoding efficiency: point-by-point scanning and serial decoding method is difficult to handle large data volume processing.
[0003] The existing technology cannot meet the efficient storage and rapid analysis needs of high-definition images, video streams, large-capacity documents and other data, and there is an urgent need for a new type of matrix two-dimensional code that breaks through the traditional architecture. SUMMARY
[0004] The main purpose of the present application is to provide a two-dimensional code, a decoding method and system thereof and a computer readable storage medium to solve the above technical problems.
[0005] To achieve the above purpose, the two-dimensional code provided by the present application has a symbol size specification of MxM, which is composed of two different brightness patterns. The two-dimensional code includes a function pattern and a data pattern. The function pattern includes a center image positioning pattern block with a size of NxN. The data pattern includes a data block around the center image positioning pattern block. Wherein, N=8x n1+1, M=N+8x n2, n1 is a positive integer, and n2 is a positive integer greater than or equal to 2. The center search positioning pattern block comprises: a center rectangular frame module with a size of 3N1*3N1, which is composed of a pattern with a size of N1*N1 and a second brightness, the center of the center rectangular frame module is consistent with the center of the two-dimensional code; a rectangular outer frame module with a size of N*N, which is composed of a pattern with a size of N1*N1 and a second brightness, is arranged concentrically around the center rectangular frame module; a rectangular corner module with a size of aN1*bN1, which is composed of a pattern with a second brightness, is arranged at one inner corner of the rectangular outer frame module; the remaining part surrounded by the rectangular outer frame module is filled with a first brightness large square composed of a pattern with a size of N1*N1 and a first brightness, wherein N1+aN1+N1≤(N-1) / 2, N1+bN1+N1≤N / 2, a and b are integers greater than or equal to 1, and a≠b; The functional pattern further comprises at least one head information pattern block, and at least one of the head information pattern blocks is arranged immediately above, below or both above and below the center search positioning pattern block; the head information pattern block comprises version information, error correction level, code size level information; The data pattern comprises a plurality of code words arranged in the area where the data pattern is located according to the arrangement order corresponding to the version information, each of the code words comprises 8*n3 bits of characters, n3 is a positive integer, and the characters are arranged in the code word according to a preset compiling order.
[0006] Preferably, the first brightness is white or transparent, the second brightness is black, N1 is one minimum size unit of the two-dimensional code, and M is 25-529.
[0007] Preferably, n1 is 2, a=3, and b=2.
[0008] Preferably, the functional pattern further comprises a clock positioning pattern block; the clock positioning pattern block is a cross positioning line, the center of the clock positioning pattern block is consistent with the center of the center search positioning pattern block; the clock positioning pattern block comprises a horizontal positioning pattern and a vertical positioning pattern respectively extended from four sides of the center search positioning pattern block; the horizontal positioning pattern is located in the horizontal center of the two-dimensional code, the vertical positioning pattern is located in the vertical center of the two-dimensional code, and the horizontal positioning pattern and the vertical positioning pattern are both formed by a pattern with a size of N1*N1 and a first brightness and a pattern with a second brightness.
[0009] Preferably, the functional pattern further comprises a correction pattern located at at least three corners of the two-dimensional code.
[0010] Preferably, the correction pattern comprises a first correction block composed of a second brightness pattern with a size of N1xN1 located at the inner corner of the two-dimensional code, a second correction block composed of a first brightness pattern with a size of N1xN1 surrounding the first correction block together with the outer side of the two-dimensional code, and a third correction block composed of a second brightness pattern with a size of N1xN1 surrounding the second correction block together with the outer side of the two-dimensional code.
[0011] Preferably, the data pattern area of the two-dimensional code is processed by XOR operation with a mask pattern.
[0012] The decoding method of the two-dimensional code as described above comprises the following steps: S1, obtaining a photographed image S, and obtaining a binary image B by reducing and performing gray scale binary conversion on the photographed image; S2, preliminarily determining the position P of the center search positioning pattern block by searching for a point with the highest first brightness in the image B; S3, intercepting a region image D of a preset size corresponding to the position P in the image S; S4, locating the center point C of the center rectangular frame module in the image D; S5, identifying the rectangular corner module and the rectangular outer frame module in the image D to identify the entire center search positioning pattern block and calculate the inclination angle A and the size Z of the center search positioning pattern block; S6, locating the position of the head information pattern block and reading the head information; S7, decoding the head information according to a corresponding preset RS error correction algorithm to determine whether the decoding is successful; if the decoding is successful, step S81 is entered; S81, positioning is correct, and the positioning and reading process of the data pattern is entered.
[0013] Preferably, the method further comprises the step of obtaining the boundary and size information R of the two-dimensional code, specifically comprising: When the two-dimensional code is a single code, the head information point of the two-dimensional code is read to obtain the size information R of the two-dimensional code, and the boundary of the two-dimensional code is located according to the inclination angle A and the size information R; When the two-dimensional code is a multi-code tiling design, the adjacent center point C is connected, and the center perpendicular line of the connection line is the boundary of the two-dimensional code.
[0014] Preferably, the function pattern further comprises a correction pattern located at at least three corners of the two-dimensional code; and the step S7 further comprises, if the decoding is not successful, entering step S9. Step S9 comprises: S91, according to the boundary, searching for the recognition of the correction pattern in a preset range of the boundary; S92, according to the correction pattern, correcting the center point site C.
[0015] Preferably, the step S92 comprises: recalculating the center point site C' of the two-dimensional code according to the correction pattern, using the center point site C' as a new center point site C, and returning to the step S5.
[0016] Preferably, the functional pattern further comprises a clock positioning pattern block; the clock positioning pattern block is a cross positioning line, the center of the clock positioning pattern block is consistent with the center of the center search positioning pattern block; the clock positioning pattern block comprises a horizontal positioning pattern and a vertical positioning pattern respectively extending from four sides of the center search positioning pattern block; the horizontal positioning pattern is located in the horizontal center of the two-dimensional code, the vertical positioning pattern is located in the vertical center of the two-dimensional code, and the horizontal positioning pattern and the vertical positioning pattern are both formed by first brightness patterns and second brightness patterns with a size of N1xN1; the step S7 further comprises: if the decoding is unsuccessful, entering the step S10; the step S10 comprises: S101, according to the center point site C and the center search positioning pattern block, positioning the cross positioning line position, and searching for a pattern formed by first brightness patterns and second brightness patterns with a size of N1xN1 alternately in a preset range around the cross positioning line position and fitting a new cross positioning line; S102, fitting a cross positioning line center intersection as a new center point site C through the new cross positioning line, and returning to the step S5.
[0017] Preferably, it further comprises a step of removing the mask pattern.
[0018] The application further provides a two-dimensional code positioning system, comprising a memory, a processor, a computer program stored in the memory and executable on the processor, and the processor executes the computer program to realize the steps of the two-dimensional code decoding method according to any one of the above.
[0019] The application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the steps of the two-dimensional code decoding method according to any one of the above.
[0020] In view of the deficiencies and improvements in the prior art, the two-dimensional code and the decoding method thereof provided by the application have at least the following advantages: (1) The center finder positioning pattern block is arranged in the center area of the two-dimensional code, and the center finder positioning pattern block is composed of a large-size second lightness square (such as a 17*17 pixel basic unit) in the periphery and a center small dot. When decoding, the human visual recognition logic "from the whole to the local" can be used to preferentially lock the code surface range through the large white block, and then the center black dot is used to accurately position the coordinates. For the multi-two-dimensional code tiling design of data storage, the positioning effect of the center finder positioning pattern block in the embodiment is better. With the multi-two-dimensional tiling design, the larger the data amount is, the more the missing positioning points can be supplemented by using the surrounding positioning points, so the larger the data amount is, the higher the space utilization rate is, and the higher the recognition rate is; the center coarse-fine combined positioning of the finder positioning pattern block reduces the space occupation and improves the positioning speed by more than 300%.
[0021] (2) The head information pattern block is arranged on the side of the finder pattern positioning block, the decoding of the head information pattern block is used to verify whether the finder pattern positioning is accurate, and only after the verification is accurate, the decoding of the data pattern of the two-dimensional code is started; the small deviation caused by positioning is avoided, the interruption and error of data scanning are avoided, and the accuracy of positioning is verified in advance.
[0022] (3) The two-dimensional code supports a larger size, and can be combined through tiling, and has no capacity limit. BRIEF DESCRIPTION OF DRAWINGS
[0023] The accompanying drawings, which are part of the present application, serve to further understand the present application, and the schematic embodiments of the present application and the descriptions thereof serve to explain the present application but do not constitute an improper limitation on the present application. Obviously, the accompanying drawings in the following description are only some embodiments, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the drawings.
[0024] Figure 1 It is a schematic diagram of the two-dimensional code in an embodiment of the present application.
[0025] Figure 2 It is a size and function pattern schematic diagram of the two-dimensional code in an embodiment of the present application.
[0026] Figure 3 It is a structure schematic diagram of the two-dimensional code with a size of 25*25 in an embodiment of the present application.
[0027] Figure 4 It is a function pattern schematic diagram of the two-dimensional code in an embodiment of the present application.
[0028] Figure 5 It is a schematic diagram of the center finder positioning pattern block in an embodiment of the present application, wherein, Figure 5 (a) is a size schematic diagram of the center finder positioning pattern block, Figure 5 (b) is a specific structure marking diagram of the center finder positioning pattern block.
[0029] Figure 6 A structure diagram of a two-dimensional code composed of multiple single-code two-dimensional codes in an embodiment of the present application.
[0030] Figure 7 A diagram of a region image D intercepted in a positioning process in an embodiment of the present application.
[0031] Figure 8 A diagram of two-dimensional code boundary positioning in a multiple-code tiling example in an embodiment of the present application, wherein, Figure 8 (a) is a diagram of positioning a two-dimensional code boundary by connecting adjacent center point sites, Figure 8 (b) is a diagram of a correction pattern for positioning four corners of a two-dimensional code.
[0032] Figure 9 A diagram of two-dimensional code tilt angle calculation and cross positioning line identification in an embodiment of the present application, wherein, Figure 9 (a) is a diagram of two-dimensional code tilt angle calculation, Figure 9 (b) is a diagram of cross positioning line identification.
[0033] Figure 10 A diagram of two-dimensional code tilt angle calculation in a single-code example in an embodiment of the present application.
[0034] Figure 11 A data structure diagram of a header information pattern block in an embodiment of the present application, wherein, Figure 11 (a) is a structure diagram of the header information pattern block located above, Figure 11 (b) is a structure diagram of the header information pattern block located below.
[0035] Figure 12 A flow diagram of a two-dimensional code decoding method in an embodiment of the present application.
[0036] Figure 13 A hardware structure diagram of a two-dimensional code decoding method in an embodiment of the present application.
[0037] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0038] The technical problems solved by the embodiments of the present application, the technical solutions adopted by the embodiments of the present application, and the technical effects achieved by the embodiments of the present application are described clearly and completely below in combination with the drawings and specific embodiments. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other equivalent or obvious modified embodiments obtained by a person of ordinary skill in the art without creative effort fall within the protection scope of the present application. The embodiments of the present application can be embodied in various different ways as defined and covered by the claims.
[0039] It should be noted that in the following description, for the convenience of understanding, many specific details are given. However, it is obvious that the implementation of the present application can be without these specific details.
[0040] It should be noted that in the absence of explicit limitations or conflicts, the various embodiments in the present application and the technical features therein can be combined with each other to form technical solutions.
[0041] The present application proposes a two-dimensional code with a central image-seeking positioning pattern block. During decoding, the code surface range can be quickly locked by the central image-seeking positioning pattern block based on the human visual "from the whole to the local" recognition logic, and then the coordinates are accurately positioned by the central point.
[0042] Please refer to Figures 1-11 The symbol size specification of the two-dimensional code 100 in the embodiment is MxM, which is composed of two different brightness patterns. The two-dimensional code 100 includes functional patterns and data patterns.
[0043] The data patterns include a plurality of code words (for example, Figure 3 The regions D1-D24 are arranged in the region where the data patterns are located according to the arrangement order corresponding to the version information. Each code word includes 8xn3 bits of characters, and n3 is a positive integer. The characters are arranged in the code word according to a preset compiling order. For example, please refer to Figure 3 In the embodiment, the code word is arranged from the upper left corner of the symbol with 2-module-wide columns, arranged from left to right, and from top to bottom, a total of 8 characters, with a highest error correction capacity of 32%.
[0044] Similar to the QR code in the prior art, the data patterns can be XOR operated by the mask patterns, the purpose of which is to balance the proportion of dark and light modules in the symbol, and to reduce the appearance of patterns affecting image fast processing. Details are not repeated here.
[0045] In the embodiment, the function pattern includes a center search positioning pattern block 10 with a size of N x N, and the data pattern 200 includes a data block surrounding the center search positioning pattern block. Wherein, N = 8 x n1 + 1, M = N + 8 x n2, n1 is a positive integer, and n2 is a positive integer greater than or equal to 2.
[0046] Specifically, in the two-dimensional code in the embodiment, in the preferred example, N = 17, and n1 is 2. For example, Figure 2 As shown, the two-dimensional code in the embodiment can support 25 x 25 to 529 x 529. For example, Figure 3 As shown, the two-dimensional code with a size of 25 x 25 in the specific example of N = 17 and M = 25.
[0047] It can be understood that the larger the size of the two-dimensional code is, the smaller the proportion of the center search positioning pattern block in the two-dimensional code is, and the lower the speed and accuracy of positioning the center search positioning pattern block in the image are. Therefore, those skilled in the art can design N and M according to the needs, so that a larger center search positioning pattern block is set as much as possible on the basis of meeting the data pattern having enough data storage bits. When n1 is 1, the supported two-dimensional code size is reduced, which is suitable for small data amount two-dimensional code; when n1 is 3, the supported two-dimensional code size can be larger (greater than 529 x 529), which can be suitable for the case of storing larger data in a single two-dimensional code. However, the larger the size of the two-dimensional code is, the larger the error in recognition and scanning is, and the probability of recognition error is significantly increased. Therefore, in the preferred embodiment, N = 17, and n1 is 2, which takes into account both the storage capacity of the data pattern and the accuracy of scanning and recognition.
[0048] Please refer to Figure 5 In the embodiment, the center search positioning pattern block 10 includes a center module 11, a center rectangular frame module 12, a rectangular outer frame module 13, a rectangular corner module 14, and a first lightness large square 15.
[0049] Specifically, the center module 11 is composed of a first lightness pattern with a size of N1 x N1, and the center of the center module 11 is consistent with the center of the two-dimensional code 100. For example, in the example, the first lightness is white, the second lightness is black, and N1 is one minimum size unit of the two-dimensional code. The first lightness and the second lightness can also use gray or color, as long as they have sufficient distinction and can be quickly identified; the identification technology of the existing black and white two-dimensional code, color two-dimensional code and gray two-dimensional code is the same, and will not be described here. N1 is one minimum size unit of the two-dimensional code, i.e. the size of 1 x 1; of course, in other embodiments, it can also be 2 x 2, 3 x 3, etc.
[0050] Specifically, the center module 11 is surrounded by a center rectangular border module 12 with a size of 3N1*3N1, which is composed of the second brightness pattern with a size of N1*N1. Since the center of the center module 11 is the center of the two-dimensional code 100, when the center module 11 needs to be located, the center rectangular border module 12 with a larger size and a strong contrast with the center module 11 can be located first to roughly locate the center, and then the center module 11 at the center of the center rectangular border module 12 is located.
[0051] Specifically, the center module 11 is surrounded by a center rectangular border module 12 with a size of 3N1*3N1, which is composed of the second brightness pattern with a size of N1*N1. Since the center of the center module 11 is the center of the two-dimensional code 100, when the center module 11 needs to be located, the center rectangular border module 12 with a larger size and a strong contrast with the center module 11 can be located first to roughly locate the center, and then the center module 11 at the center of the center rectangular border module 12 is located.
[0052] Specifically, the center module 11 is surrounded by a center rectangular border module 12 with a size of 3N1*3N1, which is composed of the second brightness pattern with a size of N1*N1. Since the center of the center module 11 is the center of the two-dimensional code 100, when the center module 11 needs to be located, the center rectangular border module 12 with a larger size and a strong contrast with the center module 11 can be located first to roughly locate the center, and then the center module 11 at the center of the center rectangular border module 12 is located.
[0053] Specifically, the center module 11 is surrounded by a center rectangular border module 12 with a size of 3N1*3N1, which is composed of the second brightness pattern with a size of N1*N1. Since the center of the center module 11 is the center of the two-dimensional code 100, when the center module 11 needs to be located, the center rectangular border module 12 with a larger size and a strong contrast with the center module 11 can be located first to roughly locate the center, and then the center module 11 at the center of the center rectangular border module 12 is located.
[0054] Wherein, N1+aN1+N1≤(N-1) / 2, N1+bN1+N1≤N / 2, a, b are integers greater than or equal to 1, and a≠b. Through the above size limitation of a and b, the rectangular corner module 14 is far enough from the center rectangular border module 12, and the space between the rectangular corner module 14 and the center rectangular border module 12 belongs to the first brightness large block 15, which is large enough.
[0055] For example, in the present embodiment, a=3, b=2. It can be understood that in other embodiments, when N=17, a and b can take values of 1-4, which can achieve the corresponding effect.
[0056] The center seeking positioning pattern block 10 has a first brightness large block 15 with a large enough size (relative to the data pattern). In a general two-dimensional code, it is very unlikely that a large size first brightness pattern will appear in the data pattern; in addition, since the data pattern is subjected to XOR operation with the mask pattern, it is impossible to have a large size first brightness pattern in the two-dimensional code. Therefore, by locating the size of the pattern with the first brightness, the center seeking positioning pattern block 10 can be quickly located.
[0057] For example, please refer to the accompanying drawings Figure 6, is a multi-block two-dimensional code combination pattern formed by splicing multiple two-dimensional codes 100, and can be recognized by Figure 6 and Figure 7 It can be seen intuitively that the white points on the image are very obvious when the image is recognized, and even the naked eye can quickly locate and recognize. By quickly scanning the image, the white points on the image can be located, so that the rough position P of the center image positioning pattern block 10 is located, and then the image near the position P is enlarged to finely recognize other modules of the center image positioning pattern block 10. The specific recognition steps will be described in detail below.
[0058] Please combine Figures 6-10 The specific center image positioning pattern block 10 image positioning principle is: after the photographed image is reduced and the gray value is converted, the point with the highest first brightness (white) in the image is found, which is preliminarily determined as the position P of the center image positioning pattern block; the area image D of the corresponding position P in the image is intercepted; the center point C is located by recognizing the center rectangular frame module 12 and the center module 11 in the image D; then the rectangular corner module and the rectangular outer frame module in the image D are recognized to recognize the entire center image positioning pattern block and calculate the inclination angle A and the size Z of the center image positioning pattern block 10, so as to position the two-dimensional code.
[0059] As Figure 7 In the recognition mode, if the center point (red cross position) is obtained by rough contour positioning, the error is relatively large; the green X point is accurately positioned by the black block (center rectangular frame module 12) and the center white point (center module 11), and the error is relatively small. In the image D, the center image positioning pattern block 10 is selected, the center position of the black block (center rectangular frame module 12) is found out by using distance transformation, the accuracy is much higher than that of contour positioning, and the anti-interference ability is stronger (only the calculation amount is larger); the center white point (center module 11) can be used for correcting the center point position, or for accurate positioning.
[0060] The size Z of the center image positioning pattern block 10 can be calculated according to the white block contour when the area image D is finely recognized.
[0061] Please combine Figures 2-4 The function pattern further includes a correction pattern 30 located at at least three corners of the two-dimensional code 100.
[0062] In this embodiment, the number of correction patterns is 4, which are located at the four corners of the two-dimensional code 100.
[0063] The correction pattern 30 includes a first correction block composed of a second brightness pattern with a size of N1xN1 located at an inner corner of the two-dimensional code, a second correction block composed of a first brightness pattern with a size of N1xN1 surrounding the first correction block together with an outer side of the two-dimensional code, and a third correction block composed of a second brightness pattern with a size of N1xN1 surrounding the second correction block together with the outer side of the two-dimensional code.
[0064] The boundary recognition mode of the two-dimensional code includes two modes of single code and multiple codes: Please combine Figure 8 If it is a tiled two-dimensional code pattern, such as Figure 8 (a), connect the adjacent center point sites, and the central perpendicular line of the connecting line is the boundary of the two-dimensional code. The intersection point (red cross) of the perpendicular line can preliminarily locate the four corners of the two-dimensional code; such as Figure 8 (b), and then find the accurate four-corner positioning block (green cross point) (correction pattern 30) near the intersection point (red cross); If it is a single independent two-dimensional code, the boundary of the two-dimensional code, the head information of the two-dimensional code is read, the size information R of the two-dimensional code is obtained, the center point site C, the inclination angle A and the size information R are used to coarsely locate the boundary and the four corners of the two-dimensional code, and then the accurate four-corner positioning block (correction pattern 30) is found near the coarsely located four corners. Finally, the four corners and the boundary of the two-dimensional code are obtained.
[0065] In addition, the four-corner positioning block (correction pattern 30) can also be used to recalculate the center point site, to check or correct the center point site C positioned by the center rectangular frame module 12 and the center module 11.
[0066] Please combine Figure 9 and Figure 10 The inclination angle A of the center image positioning pattern block 10 is identified in two modes of single code and multiple codes: If it is a tiled two-dimensional code pattern, such as Figure 9 (a), connect the adjacent center point sites, and the angle of the connecting line segment is the inclination angle A of the two-dimensional code; If it is a single independent two-dimensional code, such as Figure 10The diagonal line of the center image positioning pattern block 10 and the orientation of the rectangular corner module 14 are used to determine the rotation direction and the mirror direction of the two-dimensional code, so as to position the two-dimensional code; the specific method is to determine the rotation angles of 90°, 180° and 270° of the center image positioning pattern block 10 according to the orientation of the rectangular corner module 14; the rectangular corner module 14 is cut into two parts by the diagonal line of the center image positioning pattern block 10, and since a≠b, the sizes of the two parts are different, so it can be determined whether the image is mirrored, thereby determining whether the image needs to be mirrored.
[0067] Please combine Figures 2-4 The functional pattern further comprises a clock positioning pattern 20; the clock positioning pattern 20 is a cross positioning line, and the center of the clock positioning pattern 20 is consistent with the center of the center image positioning pattern block 10.
[0068] The clock positioning pattern 20 comprises a horizontal positioning pattern and a vertical positioning pattern respectively extending from the four sides of the center image positioning pattern block 10; the horizontal positioning pattern is located in the horizontal center of the two-dimensional code, and the vertical positioning pattern is located in the vertical center of the two-dimensional code; the horizontal positioning pattern and the vertical positioning pattern are both formed by first brightness patterns and second brightness patterns with a size of N1×N1 and are alternately formed. Preferably, the beginning and the end of the horizontal positioning pattern and the vertical positioning pattern are both dark modules (second brightness).
[0069] The clock positioning pattern 20 extends from the four sides of the center image positioning pattern block 10 respectively, does not block the center image positioning pattern block 10, and does not affect the positioning of the center image positioning pattern block 10.
[0070] The horizontal positioning pattern and the vertical positioning pattern are used to determine the density and the version of the symbol, which is the same as the prior art and will not be described here; at the same time, the horizontal positioning pattern and the vertical positioning pattern also provide a reference position for determining the coordinates of the module, which can be used for auxiliary positioning.
[0071] Please combine Figure 9The principle of the clock positioning pattern 20 assisting positioning is that the center point position positioned by the center image positioning pattern block 10 is used to position the cross positioning line position, and the pattern of the cross positioning line position is read, and it is judged whether it is the pattern formed by the first brightness pattern and the second brightness pattern with a size of N1XN1 alternately, if the identification is successful, it is judged that the two-dimensional code positioning is successful. If the identification is not successful, the center point position can be corrected by identifying the real cross positioning line. Specifically, the pattern formed by the first brightness pattern and the second brightness pattern with a size of N1XN1 alternately can be searched in a preset range around the cross positioning line position and extended in a single direction, and a new cross positioning line is fitted. The intersection point of the cross positioning line is fitted as a new center point position.
[0072] Specifically, please refer to Figure 8 If the center point position is not deviated, the clock line is the black and white alternating point value, so the center point position positioned by the center image positioning pattern block 10 is the black and white alternating point of the cross positioning line position.
[0073] If the positioning point is deviated, the center point position is corrected according to the clock line. Since the clock line is the black and white alternating point value, the extreme point of the image is searched around the originally positioned clock line: for example, the coordinates of the darkest point are searched around the black point of the clock line, and the coordinates of the brightest point with the highest gray scale are searched around the white point. According to the new coordinates and the old coordinates, the least square method is used to fit the new clock line, the intersection point (i.e. the center point) and the angle (i.e. the angle of the clock line and the rectangular coordinate system) of the two clock lines. The two clock lines correspond to the black and white alternating points on the X axis and the Y axis respectively, so when calculating, only the X coordinate fitting equation of the X axis clock line is taken, and only the Y axis coordinate equation of the Y axis clock line is taken. Specifically as follows: 1) On the basis of the originally positioned clock line, the coordinates of each point of the clock line on the X axis and the Y axis are calculated respectively; 2) The extreme point P1 is searched within a module distance around each point coordinate. For the bright point on the clock line, the coordinates of the brightest point are searched, and for the dark point on the clock line, the coordinates of the darkest point nearby are searched; 3) The least square method is used to fit a straight line for the new points on the clock line respectively, and the points with larger deviations are removed according to the distance to obtain the point set P2 with smaller errors; 4) Four unknowns, the center point coordinates (x, y), the slope k and the module point distance d, are defined, and the parameter coordinates P3 of each point on the clock line are calculated; 5) Find the coordinates of each point P2 and the parameter coordinates of P3, and use the least square method to fit according to the minimum distance between P2 and P3, and finally calculate the four unknowns in 4), wherein (x, y) is the new coordinate center point, k is the tilt angle of the clock line (i.e. the tilt angle of the two-dimensional code), and d is the average point distance of the module.
[0074] In Figure 9 (a) and Figure 9 (b), the clock line is arranged on the central green line in a regular black-white-black-white sequence.
[0075] In the embodiment, the two-dimensional code 100 further comprises at least one head information pattern block 40, which is arranged immediately above, below or both above and below the central image-finding positioning pattern block 10.
[0076] The head information pattern block comprises version information, error correction level, code size level information.
[0077] The head information pattern block comprises version information, error correction level, code size level information. Specifically, the head information pattern block comprises an information pattern and an error correction RS code pattern; the head information pattern block comprises a left head information block and a right head information block with a size of (N-1) / 2×n4 arranged in columns on the left and right, 1≤n4≤5; the left head information block and the right head information block are separated by the vertical positioning pattern of the cross positioning line.
[0078] Please refer to Figure 3 , Figure 4 and Figure 11 together, in the embodiment, N=17, n1=2; the number of the head information pattern blocks is 2, and they are arranged immediately above and below the central image-finding positioning pattern block respectively. The head information pattern block composed of two 2-row×17-column module groups (if the clock positioning pattern 20 exists at the same time, the head information pattern block is composed of a 2-row×8-column left head information block + a 2-row×8-column right head information block, and the 2-row×1-column in the middle is the position of the clock line) is placed immediately above and below the central image-finding positioning pattern block.
[0079] n4=2; the total number of code bits of the head information pattern block is 32, and the left head information block and the right head information block each comprise 16 code bits.
[0080] The left head information block of the head information pattern block located above has two bytes, i.e. 16 data bits; the first byte comprises 8 code bits, which store error correction information, including error correction level and algorithm; the second byte comprises 8 code bits, which store version information, including verification block number, mask pattern version and gray scale number; The remaining coded bits in the left and right header blocks store error correction data. The 48 coded bits are error correction bits calculated using RS (64, 16) encoding. The 48-bit error correction data is calculated using the RS error correction algorithm and added after the 16 data bits.
[0081] The following is a detailed explanation of the version and format information stored in two bytes: The first byte ( Figure 11 The data bits 0 to 7) are the contents of the symbol as error correction information: Data bits 0 to 3 are the number of error correction levels (2 to 16), 2×(N+1).
[0082] The 4th to 6th data bits, if it is global RS content, are the GF domain value of the RS algorithm, 8+N; if it is local RS content, they are the mode of the RS algorithm, 0 is variable-length RS, 1 is interleaved grouping, 2 is grouping with corner points, and 3~7 are extended reserved.
[0083] The 7th data bit is used to determine whether it is a global RS or a local RS. 1 is a variable-length global RS, and 0 is a grouped local RS.
[0084] The second byte ( Figure 11 Data bits 8 to 15) are the version information of the symbol: The 0th to 1st data bits are the remainder of the effective length of ModN (0~3) or the number of check blocks.
[0085] The content of the 2nd to 4th data bits is the mask pattern version (Mask (0~7)) for pattern selection.
[0086] The 5th to 7th data bits contain the grayscale level (0 is black and white, 2 to n levels).
[0087] Preferably, the data graphic area of the two-dimensional code is processed by an XOR operation through a mask graphic.
[0088] Please combine Figures 1-12 This embodiment also provides a method for decoding a two-dimensional code as described above, including steps S1-S5.
[0089] S1: Capture a captured image S, shrink it, and convert it to grayscale binary to obtain a binary image B. Reduce the length of image S by 5 to 20 times and convert it to a grayscale image M (scaling can speed up the time it takes to find the positioning pattern by tens or even hundreds of times). Select the midpoint between the maximum and minimum reflectance values of the image to determine the threshold. Use this threshold to convert the image into a series of dark and light pixels, obtaining a binary image B.
[0090] S2, by searching for a point with the highest first brightness in image B, preliminarily determining the position P of the central image-finding and positioning graphic block.
[0091] S3, intercepting a region image D of a preset size of a corresponding position P in the image S.
[0092] In steps S1-S3, please combine Figure 6 , the plurality of two-dimensional codes 100 are spliced to form a plurality of two-dimensional code combination patterns, which can be identified by Figure 7 It can be seen directly that the white points on the image are very obvious when the image is identified, and even the naked eye can quickly locate and identify them. By quickly scanning the pattern, the white points on the image can be located, so that the rough position P of the center image positioning pattern block 10 is located, and then the image near the position P is enlarged to finely identify other modules of the center image positioning pattern block 10.
[0093] S4, locating the center point site C in the center rectangular frame module in the image D.
[0094] Preferably, the step S4 comprises locating the center rectangular frame module in the image D, and then locating the center module in the image area of the center rectangular frame module to locate the center point site C. The center point site can be roughly located by directly locating the center rectangular frame module, and then the center module in the middle is finely located to locate the center point site C. In a specific implementation manner, the final center module is finely located, which can be checking the roughly located center point site or a supplement to the fine positioning.
[0095] Please combine Figure 7 , the principle of the center image positioning pattern block 10 is as follows: after the image is zoomed and the gray value is converted, the point with the highest first brightness (white) is found in the image, which is preliminarily determined as the position P of the center image positioning pattern block; the region image D of the corresponding position P in the image is intercepted; the center rectangular frame module 12 and the center module 11 in the image D are identified to locate the center point site C.
[0096] As Figure 7 in the identification manner, the center image positioning pattern block 10 is selected in the image D, the distance transformation is used to find the center position of the black block (the center rectangular frame module 12), the accuracy is much higher than that of the contour positioning, and the anti-interference ability is stronger (only the calculation amount is larger); the center white point (the center module 11) can be used for correcting the center point site or for fine positioning.
[0097] The size Z of the center image positioning pattern block 10 can be calculated according to the white block contour when the region image D is finely identified.
[0098] S5, identifying the rectangular corner module and the rectangular outer frame module in the image D to identify the entire center image positioning graphic block and calculate the tilt angle A and size Z of the center image positioning graphic block.
[0099] Preferably, the step S5 comprises, locating the rectangular corner module in the image D, and calculating the tilt angle A of the center image positioning graphic block according to the orientation between the rectangular corner module and the center point site C; identifying the rectangular outer frame module in the image D to identify the center image positioning graphic block and calculate the size Z of the center image positioning graphic block; According to the tilt angle A, and the orientation of the diagonal of the center image positioning graphic block and the rectangular corner module, the rotation direction and the mirror direction of the two-dimensional code are obtained, so as to perform angle positioning on the two-dimensional code.
[0100] Please combine Figure 9 and Figure 10 , the identification of the tilt angle A of the center image positioning graphic block 10 is divided into single code and multiple code two ways: If it is a tiled two-dimensional code pattern, such as Figure 9 (a), connect the adjacent center point sites, and the angle of the connecting line segment is the tilt angle A of the two-dimensional code; If it is a single independent two-dimensional code, such as Figure 10 , the diagonal of the center image positioning graphic block 10 and the orientation of the rectangular corner module 14 are obtained, so as to determine the rotation direction and the mirror direction of the two-dimensional code, thereby positioning the two-dimensional code; The specific method is to determine the rotation angles of 90°, 180° and 270° of the center image positioning graphic block 10 according to the orientation of the rectangular corner module 14; The rectangular corner module 14 is cut into left and right two parts by the diagonal of the center image positioning graphic block 10, and since a≠b, the sizes of the left and right two parts after cutting are different, so whether the image is mirrored can be identified, thereby deciding whether mirror flip is needed.
[0101] S6, positioning the position of the head information graphic block and reading the head information; S7, decoding the head information according to the corresponding preset RS error correction algorithm to determine whether the decoding is successful; if the decoding is successful, step S81 is entered; S81, positioning is correct, entering the positioning and reading process of data graphic.
[0102] By step S6 and step S7, whether the finder pattern positioning is accurate is verified by decoding the head information pattern block, and the encoding of the data pattern of the two-dimensional code is started only after the verification; if the head information reading is wrong, the positioning is necessarily inaccurate, and the head information can be decoded successfully only when the positioning is accurate. The small deviation in positioning is avoided, the interruption and error in data scanning are avoided, and the accuracy of the positioning is verified in advance.
[0103] Preferably, the decoding method of the two-dimensional code further comprises a step of acquiring the boundary and size information R of the two-dimensional code, specifically comprising: When the two-dimensional code is a single code, the head information point of the two-dimensional code is read to obtain the size information R of the two-dimensional code, and the boundary of the two-dimensional code is positioned according to the inclination angle A and the size information R. When the two-dimensional code is a multi-code tiled design, the adjacent center point sites C are connected, and the central perpendicular line of the connection line is the boundary of the two-dimensional code.
[0104] The boundary recognition mode of the two-dimensional code includes two modes of single code and multi-code: Please combine Figure 8 If the two-dimensional code pattern is tiled, such as Figure 8 (a), the adjacent center point sites are connected, the central perpendicular line of the connection line is the boundary of the two-dimensional code, and the intersection (red cross) of the perpendicular lines can preliminarily locate the four corners of the two-dimensional code; such as Figure 8 (b), then the accurate four-corner positioning block (green cross point) (correction pattern 30) is found near the intersection (red cross). If it is a single independent two-dimensional code, the boundary of the two-dimensional code is read, the size information R of the two-dimensional code is obtained, the boundary and the four corners of the two-dimensional code are roughly positioned according to the inclination angle A and the size information R, and then the accurate four-corner positioning block (correction pattern 30) is found near the position of the roughly positioned four corners.
[0105] Please combine again Figures 2-4 and Figure 8 The functional pattern further comprises a correction pattern 30 located at at least three corners of the two-dimensional code 100.
[0106] In this embodiment, the number of correction patterns is four, and the four correction patterns are located at the four corners of the two-dimensional code 100.
[0107] The correction pattern 30 comprises a first correction block composed of a second brightness pattern with a size of N1xN1 located at the inner corner of the two-dimensional code, a second correction block composed of a first brightness pattern with a size of N1xN1 surrounding the first correction block together with the outer side of the two-dimensional code, and a third correction block composed of a second brightness pattern with a size of N1xN1 surrounding the second correction block together with the outer side of the two-dimensional code.
[0108] Preferably, the functional pattern further comprises a correction pattern located at at least three corners of the two-dimensional code; and the step S7 further comprises, if the decoding is unsuccessful, entering step S9, which comprises: S91, searching for the correction pattern within a preset range of the boundary according to the boundary; S92, correcting the center point site C according to the correction pattern.
[0109] Preferably, the step S92 comprises recalculating the center point site C' of the two-dimensional code according to the correction pattern; using the center point site C' as a new center point site C, and returning to step S5.
[0110] The center point site is recalculated through the four-corner positioning block (correction pattern 30) to re-correct the center point site C positioned by the center-rectangular-frame module 12 and the center module 11; and then the center image positioning pattern block is identified and positioned again.
[0111] Preferably, the functional pattern further comprises a clock positioning pattern block; the clock positioning pattern block is a cross positioning line, the center of the clock positioning pattern block is consistent with the center of the center image positioning pattern block; the clock positioning pattern block comprises a horizontal positioning pattern and a vertical positioning pattern respectively extending from the four sides of the center image positioning pattern block; the horizontal positioning pattern is located at the horizontal center of the two-dimensional code, the vertical positioning pattern is located at the vertical center of the two-dimensional code, and the horizontal positioning pattern and the vertical positioning pattern are both formed by a first brightness pattern and a second brightness pattern with a size of N1xN1 alternately; the step S7 further comprises, if the decoding is unsuccessful, entering step S10; and the step S10 comprises: S101, positioning the cross positioning line according to the center point site C and the center image positioning pattern block, and searching for a pattern formed by a first brightness pattern and a second brightness pattern with a size of N1xN1 alternately extending in a single direction within a preset range around the cross positioning line, and fitting a new cross positioning line; S102, fitting a cross positioning line center intersection as a new center point site C through the new cross positioning line, and returning to step S5.
[0112] Please combine Figure 9 The principle of the clock positioning pattern 20 assisting positioning is that the center point position positioned by the center image positioning pattern block 10 is used to position the cross positioning line position, and the pattern at the cross positioning line position is read and judged and identified whether it is a pattern alternately formed by the first brightness pattern and the second brightness pattern with a size of N1xN1. If the identification is successful, it is judged that the two-dimensional code positioning is successful. If the identification is not successful, the center point position can be corrected by identifying the real cross positioning line. Specifically, the pattern alternately formed by the first brightness pattern and the second brightness pattern with a size of N1xN1 extending in a single direction can be searched for in a preset range around the cross positioning line position, and a new cross positioning line is fitted. The intersection point of the cross positioning line is fitted as a new center point position.
[0113] Specifically, please refer to Figure 8 If the center point position has no deviation, the clock line is a point value determined by black and white, so the center point position positioned by the center image positioning pattern block 10 is a black and white point positioned by the cross positioning line position.
[0114] If the positioning point has a deviation, the center point position is corrected according to the clock line. Since the clock line is a point value determined by black and white, the extreme points of the image are searched around the originally positioned clock line: for example, the coordinates of the darkest point are searched around the black point of the clock line, and the coordinates of the brightest point with the highest gray scale are searched around the white point. Then, according to the new coordinates and the old coordinates, a new clock line is fitted by the least square method, and the intersection point (i.e. the center point) and the angle (i.e. the angle of the clock line and the rectangular coordinate system) of the two clock lines are fitted. The two clock lines correspond to the black and white points on the X-axis and the Y-axis, respectively, so when calculating, only the X-coordinate fitting equation of the X-axis clock line is taken, and only the Y-axis coordinate equation of the Y-axis clock line is taken. The specific process is as follows: 1) On the basis of the originally positioned clock line, the coordinates of each point of the clock line on the X-axis and the Y-axis are calculated; 2) The extreme point P1 is searched within a module distance around each point coordinate. For the bright point on the clock line, the coordinates of the brightest point are searched, and for the dark point on the clock line, the coordinates of the darkest point are searched; 3) The least square method is used to fit a straight line for the new points on the clock line, and the points with larger deviations are removed according to the distance to obtain a point set P2 with smaller errors; 4) Four unknowns, the center point coordinates (x, y), the slope k and the module point distance d, are defined, and the parameter coordinates P3 of each point on the clock line are calculated; 5) find the parameter coordinate point P3 of each coordinate point P2, and fit according to the minimum distance between P2 and P3 by using the least square method, and finally calculate the four unknowns in 4), wherein (x, y) is the new coordinate center point, k is the tilt angle of the clock line (i.e. the tilt angle of the two-dimensional code), and d is the average point distance of the module.
[0115] In Figure 8 (a) and Figure 8 (b), the clock line is arranged in a regular black-white-black-white sequence next to each other on the central green line.
[0116] Compared with the traditional triangular positioning, the two-dimensional code and the decoding method thereof in the embodiment can reduce the space occupied by more than 80% of the positioning pattern, and release the code surface for data storage.
[0117] In the multiple two-dimensional code 100 tiling design, after the step S2, the point with the highest first brightness in the image B is found, and the set Ps of the positions P of the center image positioning pattern and the set Rs of the size of the two-dimensional code are preliminarily determined; then the minimum distance between the points in the set Ps is identified, and the average distance can be used to filter out the wrong positions P; at the same time, a straight line coordinate system is constructed according to the connection between the points in the set Ps, and the intersection of the straight lines is used as the corrected position P, and then the step S3 is introduced. For the multiple two-dimensional code tiling design for data storage, the positioning effect of the center image positioning pattern in the embodiment is better. By using the multiple two-dimensional tiling design, the larger the data amount is, the more the missing positioning points can be supplemented by using the surrounding positioning points, so the larger the data amount is, the higher the space utilization rate is, and the higher the recognition rate is.
[0118] Specifically, after the positioning is correct in the step S81, the positioning and reading process of the data pattern is entered. Since the version information, error correction level, code size level information and the like have been read from the header information pattern block, and it is judged that the positioning is correct, at this time, the two-dimensional code is scanned and read according to the scanning mode corresponding to the version, and then the decoding is compiled, which belongs to the content that can be directly and without doubt realized by the person skilled in the art according to the conventional technical means in the art and the content disclosed in the embodiment, and will not be described here.
[0119] Figure 13 is a hardware structure schematic diagram provided by an embodiment of the application for running the decoding method of the two-dimensional code. As Figure 13As shown, the embodiment / computer 6 includes a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60, for example, a program running a decoding method of a two-dimensional code. The processor 60 implements the steps in each of the method embodiments above when executing the computer program 62. Alternatively, the processor 60 implements the functions of each module / unit in each of the device embodiments above when executing the computer program 62.
[0120] For example, the computer program 62 can be divided into one or more modules / units stored in the memory 61 and executed by the processor 60 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program 62 in the computer 6.
[0121] The computer 6 can be a desktop computer, a notebook, a palm computer, a cloud server, and the like. The computer 6 can include, but is not limited to, the processor 60 and the memory 61. Those skilled in the art can understand that the computer 6 can include more or fewer components, or combine certain components, or different components, for example, the computer 6 can also include an input / output device, a network access device, a bus, and the like. Figure 13 The computer 6 is only an example and does not constitute a limitation on the computer 6, which can include more or fewer components than shown, or combine certain components, or different components, for example, the computer 6 can also include an input / output device, a network access device, a bus, and the like.
[0122] The processor 60 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0123] The memory 61 can be an internal storage unit of the computer 6, such as a hard disk or a memory of the computer 6. The memory 61 can also be an external storage device of the computer 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card (FC), and the like equipped on the computer 6. Further, the memory 61 can include both an internal storage unit and an external storage device of the computer 6. The memory 61 is used to store the computer program 62 and other programs and data required by the computer 6. The memory 61 can also be used to temporarily store data that has been output or is to be output.
[0124] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is exemplified, and in actual application, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit, and the integrated unit can be realized in the form of hardware or software. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the application. The specific working process of the units and modules in the system can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0125] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0126] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0127] In the embodiments of the present application, it should be understood that the disclosed apparatus / terminal device and method can be implemented in other manners. For example, the embodiments of the apparatus / terminal device described above are merely schematic, and the division of the modules or units is merely logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0128] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.
[0129] In addition, each functional unit in the various embodiments of the present application can be integrated into a processing unit, or each unit can be a physically independent unit, or two or more units can be integrated into a unit. The integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0130] The integrated module / unit, if implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. When the processor executes the computer program, the steps of each method embodiment described above can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the computer readable medium can include appropriate contents according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
[0131] The above-described embodiments are only used to illustrate the technical solutions of the present application, but not limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those ordinarily skilled in the art should understand: the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A two-dimensional code, whose symbol size is M×M, composed of two graphics of different brightness, characterized in that: The two-dimensional code includes a functional pattern and a data pattern, the functional pattern includes a central image-finding and positioning pattern block of size N×N, and the data pattern includes a data block surrounding the central image-finding and positioning pattern block, wherein N=8×n1+1, M=N+8×n2, n1 is a positive integer, and n2 is a positive integer greater than or equal to 2; The central image-finding and positioning graphic block includes: a central rectangular border module with a size of 3N1×3N1 composed of a second brightness graphic with a size of N1×N1, the center of the central rectangular border module being consistent with the center of the QR code; a rectangular outer border module with a size of N×N composed of a second brightness graphic with a size of N1×N1 arranged concentrically around the central rectangular border module; a rectangular corner module with a second brightness graphic with a size of aN1×bN1 arranged on an inner corner of the rectangular outer border module; and a large square of the first brightness filled with a first brightness graphic with a size of N1×N1 in the remaining portion surrounded by the rectangular outer border module, wherein N1+aN1+N1≤(N-1) / 2, N1+bN1+N1≤N / 2, a and b are integers greater than or equal to 1, and a≠b; The functional graphics further include at least one header information graphic block, wherein the at least one header information graphic block is located immediately above, immediately below, or immediately above and immediately below the central image search and positioning graphic block; the header information graphic block includes version information, error correction level, and code size level information; The data graph includes multiple code words arranged in the area where the data graph is located according to the arrangement order corresponding to the version information, each code word includes 8×n3-bit characters, n3 is a positive integer, and the characters are arranged in the code word according to a preset compilation order.
2. The two-dimensional code according to claim 1, characterized in that The central image-finding and positioning graphic block also includes a central module composed of a first brightness graphic with a size of N1×N1. The center of the central module is consistent with the center of the QR code and is located at the center of the central rectangular frame module.
3. The two-dimensional code according to claim 1, characterized in that The first brightness is white or transparent, the second brightness is black, N1 is a minimum size unit of the QR code, and M is 25-529.
4. The two-dimensional code according to claim 2, characterized in that The n1 is 2, a=3, b=2.
5. The two-dimensional code according to any one of claims 1 to 4, characterized in that: The functional pattern further includes correction patterns located at at least three corners of the two-dimensional code.
6. The two-dimensional code according to claim 5, characterized in that: The correction pattern includes a first correction block composed of a pattern of second brightness with a size of N1×N1 located at the inner corner of the QR code, a second correction block composed of a pattern of first brightness with a size of N1×N1 that surrounds the first correction block together with the outer edge of the QR code, and a third correction block composed of a pattern of second brightness with a size of N1×N1 that surrounds the second correction block together with the outer edge of the QR code; the first correction block, the second correction block and the third correction block together constitute a correction pattern with a size of 3N1×3N1.
7. The two-dimensional code according to any one of claims 1 to 4, characterized in that: The functional graphic also includes a clock positioning graphic block; the clock positioning graphic block is a cross positioning line, and the center of the clock positioning graphic block is consistent with the center of the central image-finding positioning graphic block; the clock positioning graphic block includes horizontal positioning graphics and vertical positioning graphics extending from the four sides of the central image-finding positioning graphic block respectively; the horizontal positioning graphic is located in the horizontal center of the two-dimensional code, and the vertical positioning graphic is located in the vertical center of the two-dimensional code, and the horizontal positioning graphic and the vertical positioning graphic are both formed by alternating graphics of the first brightness and graphics of the second brightness with a size of N1×N1.
8. The two-dimensional code according to any one of claims 1 to 4, characterized in that: The data pattern area is processed by an XOR operation through a mask pattern.
9. A two-dimensional code composed of a plurality of two-dimensional codes according to any one of claims 1 to 8 tiled together.
10. A method for decoding a two-dimensional code according to any one of claims 1 to 9, characterized in that: Including steps: S1, obtain the captured image S, shrink the captured image and convert it into grayscale binary image to obtain binary image B; S2, by searching for a point with the highest first brightness in image B, preliminarily determining the position P of the central image-finding and locating graphic block; S3, intercepting an area image D of a preset size corresponding to the position P in the image S; S4, locating a center point C of the central rectangular frame module in the image D; S5, identifying the rectangular corner modules and the rectangular outer frame modules in the image D to identify the entire central image finding and positioning pattern block and calculating the tilt angle A and size Z of the central image finding and positioning pattern block; S6, locating the position of the header information graphic block and reading the header information; S7, decoding the header information according to a corresponding preset RS error correction algorithm to determine whether the decoding is successful; If the decoding is successful, proceed to step S81; S81, positioning is correct, entering the data graphics positioning and reading process.
11. The method for decoding a two-dimensional code according to claim 10, wherein: The method further includes the step of obtaining the boundary and size information R of the QR code, specifically comprising: When the two-dimensional code is a single code, the head information point of the two-dimensional code is read to obtain the size information R of the two-dimensional code, and the boundary of the two-dimensional code is located according to the inclination angle A and the size information R; When the two-dimensional code is designed as a multi-code tile, the adjacent center point sites C are connected, and the center perpendicular line of the connecting line is the boundary of the two-dimensional code.
12. The method for decoding a two-dimensional code according to claim 11, wherein: The functional pattern also includes correction patterns located at at least three corners of the two-dimensional code; the step S7 further includes, if the decoding is unsuccessful, entering step S9; Step S9 includes: S91, searching and identifying the correction pattern within a preset range of the boundary according to the boundary; S92, calibrating the center point C according to the calibration graph.
13. The method for decoding a two-dimensional code according to claim 12, wherein: The step S92 includes: recalculating the center point C' of the two-dimensional code according to the correction pattern, using the center point C' as the new center point C, and returning to step S5.
14. The method for decoding a two-dimensional code according to any one of claims 10 to 13, characterized in that: The functional pattern also includes a clock positioning pattern block; the clock positioning pattern block is a cross positioning line, and the center of the clock positioning pattern block is consistent with the center of the central image finding positioning pattern block; the clock positioning pattern block includes horizontal positioning patterns and vertical positioning patterns extending from four sides of the central image finding positioning pattern block; the horizontal positioning pattern is located at the horizontal center of the two-dimensional code, and the vertical positioning pattern is located at the vertical center of the two-dimensional code, and the horizontal positioning pattern and the vertical positioning pattern are both formed by alternating patterns of a first brightness and a second brightness with a size of N1×N1; the step S7 also includes, if the decoding is unsuccessful, entering step S10; the step S10 includes: S101, locating a crosshair position based on the center point C and the center image-finding positioning pattern block, searching for a pattern formed by alternating patterns of a first brightness and a second brightness extending in a single direction and having a size of N1×N1 within a preset range around the crosshair position, and fitting the pattern to form a new crosshair position; S102: Using the new cross positioning line, fit the center intersection of the cross positioning line as the new center point C, and return to step S5.
15. A method and system for decoding a two-dimensional code, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the two-dimensional code decoding method according to any one of claims 10 to 14 are implemented.
16. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the two-dimensional code decoding method according to any one of claims 10 to 14 are implemented.
Citation Information
Patent Citations
Aztec Code bar code decoding chip and decoding method thereof
CN101908128A
Two-dimensional code identification method and system based on connected domain analysis, device and medium
CN109993019A
Aztec code positioning method
CN112800798A
Two-dimensional code positioning method and system
CN113705268A
Localize an optical code
US20240078398A1