CN112187284B - Coding method, coding pattern, coding pattern reading method and shooting device - Google Patents
Coding method, coding pattern, coding pattern reading method and shooting device Download PDFInfo
- Publication number
- CN112187284B CN112187284B CN201910606064.9A CN201910606064A CN112187284B CN 112187284 B CN112187284 B CN 112187284B CN 201910606064 A CN201910606064 A CN 201910606064A CN 112187284 B CN112187284 B CN 112187284B
- Authority
- CN
- China
- Prior art keywords
- positioning block
- coding
- pattern
- edge
- block
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M13/00—Coding, decoding or code conversion, for error detection or error correction; Coding theory basic assumptions; Coding bounds; Error probability evaluation methods; Channel models; Simulation or testing of codes
- H03M13/03—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words
- H03M13/05—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words using block codes, i.e. a predetermined number of check bits joined to a predetermined number of information bits
- H03M13/11—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words using block codes, i.e. a predetermined number of check bits joined to a predetermined number of information bits using multiple parity bits
- H03M13/1102—Codes on graphs and decoding on graphs, e.g. low-density parity check [LDPC] codes
- H03M13/1148—Structural properties of the code parity-check or generator matrix
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M13/00—Coding, decoding or code conversion, for error detection or error correction; Coding theory basic assumptions; Coding bounds; Error probability evaluation methods; Channel models; Simulation or testing of codes
- H03M13/03—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words
- H03M13/05—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words using block codes, i.e. a predetermined number of check bits joined to a predetermined number of information bits
- H03M13/11—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words using block codes, i.e. a predetermined number of check bits joined to a predetermined number of information bits using multiple parity bits
- H03M13/1102—Codes on graphs and decoding on graphs, e.g. low-density parity check [LDPC] codes
- H03M13/1105—Decoding
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M13/00—Coding, decoding or code conversion, for error detection or error correction; Coding theory basic assumptions; Coding bounds; Error probability evaluation methods; Channel models; Simulation or testing of codes
- H03M13/03—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words
- H03M13/05—Error detection or forward error correction by redundancy in data representation, i.e. code words containing more digits than the source words using block codes, i.e. a predetermined number of check bits joined to a predetermined number of information bits
- H03M13/13—Linear codes
- H03M13/15—Cyclic codes, i.e. cyclic shifts of codewords produce other codewords, e.g. codes defined by a generator polynomial, Bose-Chaudhuri-Hocquenghem [BCH] codes
- H03M13/151—Cyclic codes, i.e. cyclic shifts of codewords produce other codewords, e.g. codes defined by a generator polynomial, Bose-Chaudhuri-Hocquenghem [BCH] codes using error location or error correction polynomials
- H03M13/1515—Reed-Solomon codes
Landscapes
- Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Algebra (AREA)
- General Physics & Mathematics (AREA)
- Pure & Applied Mathematics (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention discloses an encoding method, an encoding graph reading method and a shooting device. In the invention, three of the four positioning blocks in the coding pattern are respectively positioned at three corners of the coding pattern, and the other positioning block is tangential with the edge of the coding pattern, so that the asymmetric distribution configuration of the four positioning blocks is formed. The method replaces the existing two-dimensional code standard, saves the authorization cost and the manufacturing cost required by adopting the existing two-dimensional code generating software, is not limited by the use limit of the existing two-dimensional code generating software, realizes the accurate and rapid positioning of the coding pattern, and is beneficial to rapidly searching the initial coding block position in the coding region. The invention can set the size of the coding pattern area and the size of the coding area according to the data size of the application scene so as to flexibly set the data information recorded by the coding pattern. The coding mode of the coding region in the invention is simple, and the efficiency of the scene with smaller coded data quantity is higher.
Description
Technical Field
The present invention relates to the field of calibration technologies, and in particular, to an encoding method, an encoding graphic reading method, and a photographing device.
Background
In industrial and machine vision applications, certain locations need to be labeled in order to determine information (e.g., coordinates) of some critical locations in a workpiece, mechanism, or scene. During processing, the relevant information of the position of the point indicated by the label can be determined by searching the position of the label in the image and analyzing the content of the label, so that the subsequent processing difficulty is reduced. The information contained in the tag is processed to facilitate the mechanism and software algorithm to automatically and efficiently complete the specific function. The method using the labels is widely applied to scenes such as mobile robot positioning, visual navigation, calibration plate auxiliary positioning, motion estimation and the like.
The two-dimensional code is a commonly used label, has the advantages of high information density, high readability and the like, and is widely applied to daily life and industrial production. The two-dimensional code can store more information than the traditional bar code, so that a certain amount of redundant information can be contained, and the noise resistance of the code is improved. According to the difference of error correction mechanisms, currently used two-dimensional codes can be divided into two types, namely, error correction codes are calculated by using data codes, and the data codes are filled in a matrix together to form a complete two-dimensional code. The good mathematical properties of error correction codes play an important role in the decoding stage, and typical representative of the error correction codes are QR codes and DM codes, which can correct 15% -30% of codeword errors.
The error correction capacities of the QR code and the DM code are fixed, and the two-dimensional code size is increased along with the improvement of the error correction performance. The QR code standard provides L, M, H, Q total 4 error correction levels, the maximum fault tolerance is about 30%, and the fault tolerance of DM codes is lower than 30%. It would not be possible if the actual usage scenario required a larger error correction capacity.
Another type of matrix code uses probability to correct errors. Such codes do not explicitly add error correction codes, but a set of code words having a code distance as large as possible is pre-selected from a large number of code words for encoding by a certain screening mechanism. Because the code word space is sparse, the probability that one code word is just received into another code word is very low, and error correction can be performed on the received code word according to the characteristic. Typical representatives of such codes are AprilTag codes and ArUco codes.
The April code and ArUco code have no independent positioning patterns, but are decoded by best matching by comparing the images with a two-dimensional code library. The disadvantage of this code is, firstly, that it requires a long time to screen from a large number of codewords in order to ensure that the distance of the allowed codewords is maximized, and inconvenient to spread, and secondly, that the decoding process employs template matching for decoding, the time consumption increases linearly with the number of templates, and that it is difficult to cover all complications with templates.
The existing two-dimensional code needs to utilize two-dimensional code generation software under the existing rule, so that the authorization cost and the manufacturing cost for using the two-dimensional code are increased.
Disclosure of Invention
In view of the above, the present invention provides an encoding method, an encoding pattern reading method, a photographing device, a non-volatile computer readable storage medium and an electronic device, so as to replace the existing two-dimensional code and save the authorization cost and the manufacturing cost of the two-dimensional code.
The technical scheme of the invention is realized as follows:
a method of encoding, comprising:
Receiving data to be encoded;
encoding the data to be encoded to generate encoded data;
recording the coded data in a coded pattern;
wherein, the coding pattern is square, includes:
A first positioning block located at a first corner region in the code pattern;
a second positioning block located at a second corner region in the code pattern, wherein the second corner region is not on the same diagonal of the code pattern as the first corner region;
A third positioning block located at a third corner region in the encoded pattern, wherein the third corner region and the second corner region are on the same diagonal of the encoded pattern;
the fourth positioning block is positioned in the coding graph;
An encoding region which is located in an area of the encoding pattern not occupied by the first positioning block, the second positioning block, the third positioning block, and the fourth positioning block, and which records the encoded data, wherein,
In a quadrangle formed by the center of the first positioning block, the center of the second positioning block, the center of the third positioning block and the center of the fourth positioning block, the inner angle of the fourth positioning block is the largest inner angle of four inner angles of the quadrangle, and the distance between the center of the fourth positioning block and the center of the third positioning block is smaller than the distance between the center of the fourth positioning block and the center of the second positioning block.
Preferably, the encoding the data to be encoded includes:
and encoding the data to be encoded by adopting a reed solomon RS error correction encoding method.
Preferably, after generating the encoded data, before recording the encoded data in the encoded pattern, the method further comprises:
And performing bit exclusive OR processing on the coded data and the data mask matrix.
Preferably, the first positioning block is tangential to both the first edge of the coding pattern and the second edge of the coding pattern;
The second positioning block is tangential to the second edge of the coding pattern and the third edge of the coding pattern at the same time;
the third positioning block is tangential to the first edge of the coding pattern and the fourth edge of the coding pattern at the same time;
The fourth positioning block is tangential to only the fourth edge of the code pattern.
Preferably, the first positioning block, the second positioning block, the third positioning block and the fourth positioning block are identical in shape and size.
Preferably, the first positioning block, the second positioning block, the third positioning block and the fourth positioning block are all in a plurality of annular shapes which are concentric and are provided with alternate colors.
Preferably, the coding region is composed of a data lattice, and coding blocks in the data lattice are square points or round points.
Preferably, the code blocks include code blocks of two colors distinguished from each other, wherein the code block of one color represents 0 and the code block of the other color represents 1.
Preferably, said recording said encoded data in an encoded pattern includes:
And taking a row of coding blocks closest to the second edge in the coding region as a starting coding row, taking a row of coding blocks closest to the fourth edge in the coding region as a final coding row, taking the coding blocks closest to the first edge in each row of coding blocks as the starting coding blocks, taking the coding blocks closest to the third edge as the final coding blocks, and recording the coded data in the coding region according to the sequence from the starting coding row to the final coding row.
Preferably, in the process of recording the encoded data in the coding region:
And skipping the fourth positioning block to form the coding blocks in the coding line when the coding line truncated by the fourth positioning block is formed.
Preferably, before the encoded data is recorded in the encoded pattern, the method further comprises:
And determining the side length of the coding graph according to the bit number of the coding data, the side length of each coding block in the coding region and the side length of the area occupied by any one positioning block.
Preferably, the side length of the coding pattern is positively correlated with the bit number of the coding data, the side length of each coding block in the coding region, and the side length of the region occupied by any one positioning block.
A code pattern, the code pattern being square, comprising:
A first positioning block located at a first corner region in the code pattern;
a second positioning block located at a second corner region in the code pattern, wherein the second corner region is not on the same diagonal of the code pattern as the first corner region;
A third positioning block located at a third corner region in the encoded pattern, wherein the third corner region and the second corner region are on the same diagonal of the encoded pattern;
the fourth positioning block is positioned in the coding graph;
An encoding region which is located in an area of the encoding pattern which is not occupied by the first positioning block, the second positioning block, the third positioning block, and the fourth positioning block, and which records information that can be read, wherein,
In a quadrangle formed by the center of the first positioning block, the center of the second positioning block, the center of the third positioning block and the center of the fourth positioning block, the inner angle of the fourth positioning block is the largest inner angle of four inner angles of the quadrangle, and the distance between the center of the fourth positioning block and the center of the third positioning block is smaller than the distance between the center of the fourth positioning block and the center of the second positioning block.
Preferably, the first positioning block is tangential to both the first edge of the coding pattern and the second edge of the coding pattern;
The second positioning block is tangential to the second edge of the coding pattern and the third edge of the coding pattern at the same time;
the third positioning block is tangential to the first edge of the coding pattern and the fourth edge of the coding pattern at the same time;
The fourth positioning block is tangential to only the fourth edge of the code pattern.
Preferably, the first positioning block, the second positioning block, the third positioning block and the fourth positioning block are identical in shape and size.
Preferably, the first positioning block, the second positioning block, the third positioning block and the fourth positioning block are all in a plurality of annular shapes which are concentric and are provided with alternate colors.
Preferably, the coding region is composed of a data lattice, and coding blocks in the data lattice are square points or round points.
Preferably, the code blocks include code blocks of two colors distinguished from each other, wherein the code block of one color represents 0 and the code block of the other color represents 1.
A method of reading a coded pattern, comprising:
acquiring an image containing a coding pattern, wherein the image is obtained by shooting the surface of an object containing the coding pattern;
identifying four positioning blocks in the coding graph in the image;
determining the mapping relation between the coding graph and the non-perspective distortion plane from the image according to the four positioning blocks, and transforming the coding graph in the image into the non-perspective distortion plane according to the mapping relation to form a coding graph front view;
In the front view of the coding pattern, the information recorded in the coding pattern is obtained by reading a coding region recorded with information which can be read;
wherein, in the image, four positioning blocks in the coding graph are identified, and the method comprises the following steps:
The positioning block at the maximum inner angle position in four inner angles of the quadrangle formed by the central coordinates of the four positioning blocks is determined to be a fourth positioning block, the positioning block closest to the fourth positioning block on two sides of the maximum inner angle is determined to be the third positioning block, the positioning block farthest from the fourth positioning block on two sides of the maximum inner angle is determined to be the second positioning block, and the rest positioning blocks are determined to be the first positioning blocks.
Preferably, the mapping relation between the coding graph and the image without perspective distortion plane is determined according to the four positioning blocks, and the mapping relation is obtained by the following method:
And determining the mapping relation of the coding graph from the image to the perspective distortion-free plane according to the center coordinates of the first positioning block, the second positioning block, the third positioning block and the fourth positioning block in the image and the center coordinates of the first positioning block, the second positioning block, the third positioning block and the fourth positioning block in the perspective distortion-free plane.
Preferably, the coding region is located in the coding pattern and is not occupied by the first positioning block, the second positioning block, the third positioning block, and the fourth positioning block.
Preferably, the following method is adopted to identify four positioning blocks in the coding graph:
In the coding graph, four graph objects with the same shape and size are determined to be the four positioning blocks.
Preferably, the method further comprises:
And determining four graphic objects which are concentric and provided in a plurality of annular shapes with alternate colors as the four positioning blocks.
Preferably, the quadrangle is constructed by the following method:
and extracting the central coordinates of the four positioning blocks, and sequentially connecting the central coordinates of the four positioning blocks to form the quadrangle.
Preferably, in the square planar area without perspective distortion:
a first positioning block is positioned in a first corner area in the square plane area;
A second locating block is positioned at a second corner area which is positioned at the square plane area and is not positioned on the same diagonal line with the first corner area;
a third positioning block is positioned in a third corner region which is positioned on the same diagonal line with the second corner region in the square plane region;
the position of the fourth positioning block is one of a position set of the fourth positioning block which meets the following conditions:
The fourth positioning block is located in the square plane area, and in a target quadrangle formed by the center of the first positioning block, the center of the second positioning block, the center of the third positioning block and the center of the fourth positioning block, the inner angle of the fourth positioning block is the largest inner angle of four inner angles of the target quadrangle, and the distance between the center of the fourth positioning block and the center of the third positioning block is smaller than the distance between the center of the fourth positioning block and the center of the second positioning block.
Preferably, the determining the mapping relationship of the coding pattern from the image to the non-perspective distortion plane according to the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block and the center coordinates of the fourth positioning block in the image, and the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block and the center coordinates of the fourth positioning block in the non-perspective distortion plane includes:
Acquiring a homography matrix corresponding to the mapping relation according to the central coordinates of the first positioning block, the central coordinates of the second positioning block, the central coordinates of the third positioning block and the central coordinates of the fourth positioning block in the image, and the central coordinates of the first positioning block, the central coordinates of the second positioning block, the central coordinates of the third positioning block and the central coordinates of the fourth positioning block in a perspective-free distortion plane;
said transforming said encoded graphic in said image into said perspective distortion free plane according to said mapping relationship to form an encoded graphic elevation view comprising:
and utilizing the homography matrix to projectively transform all pixel points of the coding graph in the image to the non-perspective distortion plane to form the front view of the coding graph.
Preferably, in the front view of the coding pattern, the method for obtaining the information recorded in the coding pattern by reading the coding region recorded with the information which can be read comprises the steps of:
Of the four edges of the code pattern in the code pattern front view, an edge tangential to the first positioning block and the third positioning block at the same time is set as a first edge, an edge tangential to the first positioning block and the second positioning block at the same time is set as a second edge, an edge tangential to only the second positioning block is set as a third edge, and an edge tangential to the third positioning block and the fourth positioning block at the same time is set as a fourth edge;
And taking a row of the coding blocks closest to the second edge in the coding region as a starting coding row, taking a row of the coding blocks closest to the fourth edge in the coding region as a final coding row, taking the coding blocks closest to the first edge in each row of the coding blocks as the starting coding blocks, taking the coding blocks closest to the third edge as the final coding blocks, and reading information of each coding block from the starting coding block to the final coding block in each coding row in sequence from the starting coding row to the final coding row so as to obtain the information recorded by the coding graph.
Preferably, when the code line truncated by the fourth positioning block is read, the fourth positioning block is skipped to read the code blocks in the code line.
Preferably, after reading the coding region, the information recorded in the coding pattern is obtained by the following method:
Performing error correction decoding on the coding information obtained by reading the coding region to obtain error-corrected code words and error quantity;
and if the number of errors does not exceed the error correction capacity, outputting the error-corrected code word.
Preferably, before performing the error correction coding, the method further comprises:
And performing bit exclusive OR processing on the coded information and the data mask matrix.
A photographing apparatus including a photographing unit and a processor;
the shooting unit is used for shooting the surface of an object containing the coding pattern to obtain an image containing the coding pattern;
The processor is configured to:
identifying four positioning blocks in the coding graph in the image;
determining the mapping relation between the coding graph and the non-perspective distortion plane from the image according to the four positioning blocks, and transforming the coding graph in the image into the non-perspective distortion plane according to the mapping relation to form a coding graph front view;
In the front view of the code pattern, the information recorded in the code pattern is obtained by reading the code region in which the recorded information can be read.
A non-transitory computer readable storage medium storing instructions which, when executed by a processor, cause the processor to perform the steps in the encoding method of any of the above claims.
A non-transitory computer readable storage medium storing instructions which, when executed by a processor, cause the processor to perform the steps in the encoded pattern reading method of any of the preceding claims.
An electronic device, comprising:
At least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor to cause the at least one processor to perform steps in the encoding method of encoding a graphic as claimed in any one of the preceding claims.
An electronic device, comprising:
At least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor to cause the at least one processor to perform steps in the encoded graphics reading method as claimed in any preceding claim.
According to the scheme, the encoding method, the encoding graph reading method, the shooting device, the nonvolatile computer readable storage medium and the electronic equipment replace the existing two-dimensional code standard, the authorization cost and the manufacturing cost required by adopting the existing two-dimensional code generating software are saved, and the method and the device are not limited by the use limit of the existing two-dimensional code generating software. In addition, in the invention, three of the four positioning blocks are respectively positioned at three corners of the coding pattern, and the other positioning block is tangent to the edge of the coding pattern, so that the asymmetric distribution configuration of the four positioning blocks is formed, thereby realizing the accurate and rapid positioning of the coding pattern by utilizing the asymmetric distribution configuration of the four positioning blocks, ensuring the accurate reading of the coding region, simultaneously setting the direction of the coding pattern by utilizing the four positioning blocks of the asymmetric distribution configuration, being beneficial to rapidly searching the initial coding block position in the coding region, and realizing the rapid reading of the information recorded in the coding region by reading each row of coding blocks from top to bottom and from left to right. In addition, the asymmetric arrangement structure of the four positioning blocks is provided with direction information, the direction of the coding pattern can be determined by utilizing the four positioning blocks which are arranged asymmetrically, the problem that the direction of the coding pattern cannot be determined due to the mirror image problem caused by symmetric arrangement can be solved, and furthermore, when the data of the coding pattern in the positive and negative directions are read, the direction of the coding pattern can be identified, so that the purpose of data reading of the same coding pattern in the positive and negative directions can be realized, and the application range of the coding pattern is increased. The invention can set the size of the coding pattern area and the size of the coding area according to the data size of the application scene so as to flexibly set the data information recorded by the coding pattern. The invention uses the Reed-Solomon error correction mechanism to make the coding region have error prevention performance, and can correct the error code which does not exceed the error correction capacity. The coding mode of the coding region in the invention is simple, and the efficiency of the scene with smaller coded data quantity is higher.
Drawings
FIG. 1A is a diagram of a coding scheme according to an embodiment of the present invention;
FIG. 1B is a diagram of an embodiment of the present invention;
FIG. 2 is a flowchart of an encoding method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram showing an arrangement of data codes and error correction codes in an encoding region of an encoding pattern according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for reading a code pattern according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating an overall process from initial determination of data to be encoded to final completion of encoding according to an embodiment of the present invention;
FIG. 6 is a flow chart illustrating the overall process from determining the code pattern specification to finally completing decoding according to an embodiment of the present invention;
Fig. 7 is a schematic diagram of a photographing device according to an embodiment of the invention.
Fig. 8 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail below by referring to the accompanying drawings and examples.
As shown in fig. 1A and 1B, the coding pattern 1 is a square and includes a first positioning block 11, a second positioning block 12, a third positioning block 13 and a fourth positioning block 14, where the first positioning block 11, the second positioning block 12 and the third positioning block 13 are respectively located in a first corner area, a second corner area and a third corner area of the coding pattern 1, where the second corner area and the first corner area are not located on the same diagonal line of the coding pattern 1, and the third corner area and the second corner area are located on the same diagonal line of the coding pattern 1, i.e. the second corner area and the third corner area are two corner areas on the same diagonal line of the coding pattern 1, and in the embodiment shown in fig. 1A and 1B, the first corner area is an upper left corner area, the second corner area is an upper right corner area, and the third corner area is a lower left corner area, where the upper right corner area and the lower left corner area are two corner areas from the upper right corner to the lower left corner of the coding pattern 1. The fourth positioning block 14 is located in the code pattern 1.
As shown in fig. 1A and 1B, the coding pattern 1 further includes a coding region 15, where the coding region 15 is located in a region of the coding pattern 1 not occupied by the first positioning block 11, the second positioning block 12, the third positioning block 13, and the fourth positioning block 14, and the coding region 15 records information that can be read.
As shown in fig. 1A and 1B, in the quadrangle formed by the center of the first positioning block 11, the center of the second positioning block 12, the center of the third positioning block 13, and the center of the fourth positioning block 14, the inner angle at which the fourth positioning block 14 is located is the largest inner angle among four inner angles of the quadrangle, and the distance between the center of the fourth positioning block 14 and the center of the third positioning block 13 is smaller than the distance between the center of the fourth positioning block 14 and the center of the second positioning block 12. That is, the center of the fourth positioning block 14 is connected to the center of the third positioning block 13, and is named as a first connection line, the center of the fourth positioning block 14 is connected to the center of the second positioning block 12, and is named as a second connection line, so that the included angle between the first connection line and the second connection line is the largest internal angle in the quadrangle, the distance between the center of the fourth positioning block 14 and the center of the third positioning block 13 is named as a first distance, and the distance between the center of the fourth positioning block 14 and the center of the second positioning block 12 is named as a second distance, so that the first distance is smaller than the second distance.
More specifically, as shown in fig. 1A and 1B, in the embodiment of the present invention, the code pattern 1 has a first edge 16, a second edge 17, a third edge 18, and a fourth edge 19, and the first edge 16 perpendicularly intersects the second edge 17, the second edge 17 perpendicularly intersects the third edge 18, the third edge 18 perpendicularly intersects the fourth edge 19, the fourth edge 19 perpendicularly intersects the first edge 16, as shown in fig. 1A and 1B, the first edge 16 is a left edge of the code pattern 1, the second edge 17 is an upper edge of the code pattern 1, the third edge 18 is a right edge of the code pattern 1, and the fourth edge 19 is a lower edge of the code pattern 1.
The edges of the first positioning block 11 are tangential to both the first edge 16 and the second edge 17, the edges of the second positioning block 12 are tangential to both the second edge 17 and the third edge 18, the edges of the third positioning block 13 are tangential to both the first edge 16 and the fourth edge 19, and the edges of the fourth positioning block 14 are tangential to only said fourth edge 19.
In an alternative embodiment, the first positioning block 11, the second positioning block 12, the third positioning block 13 and the fourth positioning block 14 are the same in shape and size. In an alternative embodiment, the first positioning block 11, the second positioning block 12, the third positioning block 13 and the fourth positioning block 14 are all in a plurality of annular shapes which are concentric and alternate in color, for example, a plurality of annular shapes which alternate in black and white as shown in fig. 1A and 1B. In other alternative embodiments, the first positioning block 11, the second positioning block 12, the third positioning block 13 and the fourth positioning block 14 may also be regular triangles, squares or other various regular polygon rings. In other alternative embodiments, the first positioning block 11, the second positioning block 12, the third positioning block 13 and the fourth positioning block 14 may also be solid positioning blocks, such as circular blocks, square blocks or polygonal blocks.
In an alternative embodiment, the direction of the code pattern 1 may be determined by setting the direction of the second edge 17 side up, the direction of the first edge 16 side left, the direction of the third edge 18 side right, and the direction of the fourth edge 19 side down, and the direction of the code pattern 1 may be determined according to the four positioning blocks.
As shown in fig. 1A and 1B, the coding region 15 is composed of a data lattice. The coding blocks in the data lattice are square points (shown in fig. 1A) or circular points (shown in fig. 1B).
In an alternative embodiment, the code blocks comprise code blocks of two colors that are distinguished from each other, wherein the code blocks of one color represent 0 and the code blocks of the other color represent 1. For example, in the encoding blocks of two colors, i.e., black and white, as shown in fig. 1A and 1B, in other embodiments, encoding blocks of different color combinations other than the combination of black and white, e.g., red and white, black and yellow, blue and yellow, etc., may be used, and the color of the encoding block is selected with priority on the ease of reading the encoding region 15, so as to avoid misreading caused by too close color values between the two colors. In the embodiment shown in fig. 1A and 1B, a black code block may be represented as 1, a white code block may be represented as 0, or a black code block may be represented as 0, and a white code block may be represented as 1.
In an alternative embodiment, the information in the coding area 15 in the embodiment shown in fig. 1A and 1B is recorded in the order from the first row (the first row in fig. 1A and 1B) adjacent to the second edge 17 in the data matrix, along the order from the side (the left side in fig. 1A and 1B) near the first edge 16 to the side (the right side in fig. 1A and 1B) near the third edge 18, i.e. the information is recorded in the order from left to right in the respective coding blocks of the first row in the data matrix, then in the order from left to right in the respective coding blocks of the second row in the data matrix, and so on, and finally in the order from left to right in the respective coding blocks of the last row in the data matrix. As shown in fig. 1A and 1B, since the fourth positioning block 14 divides the last several rows of encoded blocks into left and right two parts, the information is recorded in each of the several rows of encoded blocks in the order of first recording the encoded blocks in the left part of the row located at the left side of the fourth positioning block 14 from left to right, and then skipping the fourth positioning block 14 and recording the encoded blocks in the right part of the row located at the right side of the fourth positioning block 34 from left to right.
The embodiment of the invention also provides a coding method, as shown in fig. 2, which comprises the following steps:
Step 11, receiving data to be encoded;
step 12, encoding the data to be encoded to generate encoded data;
and step 13, recording the coded data in the coded pattern.
The coding pattern is the coding pattern 1 described in the above embodiments, and the structure thereof is shown in fig. 1A and fig. 1B, and specifically, the description of the above embodiments is omitted herein.
In an alternative embodiment, step 13 of recording the encoded data in the encoded pattern includes:
and taking a row of the coding blocks closest to the second edge in the coding region as a starting coding row, taking a row of the coding blocks closest to the fourth edge in the coding region as a final coding row, taking the coding blocks closest to the first edge as the starting coding blocks in each row of the coding blocks, taking the coding blocks closest to the third edge as the final coding blocks, and recording coded data in the coding region in the sequence from the starting coding row to the final coding row.
Further, in an alternative embodiment, during the recording of the encoded data in the encoding region:
And skipping the fourth positioning block to form the coding blocks in the coding line when the coding line truncated by the fourth positioning block is formed.
In an alternative embodiment, before the encoded data is recorded in the encoded graphic in step 13, the encoding method according to the embodiment of the present invention further includes:
And determining the side length of the coding pattern according to the bit number of the coding data, the side length of each coding block in the coding region and the side length of the region occupied by any one positioning block.
In an alternative embodiment, the side length of the coding pattern is positively correlated with the number of bits of the coded data, the side length of each coding block in the coding region, and the side length of the area occupied by any one of the positioning blocks.
Specifically, in an alternative embodiment, the relation between the side length of the coding pattern and the number of bits of the coded data, the side length of each coding block in the coding region and the side length of the area occupied by any one of the positioning blocks is expressed by a formula, the side length of the area occupied by any one of the positioning blocks is denoted as m, the width of the number of bits of the data to be coded is denoted as k, and the preset width of the number of bits of the error correction capacity is denoted as 2t, and then:
Wherein a is the length of the coding area or the coding pattern.
If the width of the surrounding dead zone of the coding pattern is calculated, there are
Wherein a' is the total side length of the coding area or the coding pattern plus the surrounding dead zone, and q is the width of the dead zone.
In an alternative embodiment, the encoding of the data to be encoded in step 12 comprises:
And encoding the data to be encoded by adopting an RS (Reed-Solomon) error correction encoding method.
In an alternative embodiment, after generating the encoded data in step 12 and before recording the encoded data in the encoded graphics in step 13, the encoding method according to the embodiment of the present invention further includes:
And performing bit exclusive OR processing on the coded data and the data mask matrix.
Details of the RS error correction coding method and the bit-difference processing using the data mask matrix will be described later.
Taking one embodiment as an example, the recording of the data to be encoded in the encoding region may include the following steps.
And a1, inputting data to be encoded.
Step a2, calculating a Galois field generator polynomial, wherein the Galois field base is 2. The generator polynomial is expressed as the product of 2t first order polynomials.
And a3, performing Reed-Solomon error correction coding.
Let the data code polynomial be:
The error correction code polynomial is the remainder of x 2t d (x) divided by the polynomial g (x).
After the error correction code is arranged in the data code, error correction coding is completed as shown in fig. 3. Or the error correction code may be placed before the data code.
Step a4, converting the data code and the error correction code into a bit stream, wherein each bit in the bit stream corresponds to each coding block in the coding region. Different information of the bitstream is represented according to different colors of the encoded block, wherein black represents 0 and white represents 1. Or 0 by white and 1 by black.
And a5, applying a data mask matrix to obtain a final coding result, namely the color of each coding block. To prevent the occurrence of the same-color coded block aggregation in the coding region, a data mask matrix of 0, 1 phase-to-phase is applied to the coding region. The data mask matrix formula is:
mask=(row+col)%2
where row is the row number of the code block, col is the column number of the code block, and mask is the mask value. And solving the exclusive OR of the mask and the coding block value at the corresponding position to obtain a final coding result. The data mask matrix is adopted to carry out bit exclusive OR operation, so that when the coding area is relatively large, the condition that black and white blocks are gathered is reduced, and the decoding time division efficiency is improved.
And a6, filling the coding blocks into the coding region in sequence.
As shown in fig. 4, and in combination with the code patterns shown in fig. 1A and 1B, the code pattern reading method according to the embodiment of the present invention mainly includes:
step 21, obtaining an image containing the coding pattern, wherein the image is obtained by shooting the surface of an object containing the coding pattern;
Step 22, identifying four positioning blocks in the coding graph in the image;
Step 23, determining a mapping relation between the coding pattern and the non-perspective distortion plane according to the four positioning blocks, and transforming the coding pattern in the image into the non-perspective distortion plane according to the mapping relation to form a front view of the coding pattern;
In step 24, in the front view of the code pattern, the information recorded in the code pattern is obtained by reading the code area recorded with the information which can be read.
In an alternative embodiment, in the image in step 22, four positioning blocks in the coding pattern are identified, and the method further includes:
The positioning block at the maximum inner angle position in four inner angles of the quadrangle formed by the central coordinates of the four positioning blocks is determined as a fourth positioning block, the positioning block closest to the fourth positioning block on two sides of the maximum inner angle is determined as a third positioning block, the positioning block farthest from the fourth positioning block on two sides of the maximum inner angle is determined as a second positioning block, and the rest positioning blocks are determined as first positioning blocks.
In an alternative embodiment, in step 22, four positioning blocks in the encoded pattern are identified as follows:
in the encoding graph, four graph objects with the same shape and size are determined as the four positioning blocks.
As shown in fig. 1A and 1B, the first positioning block 11, the second positioning block 12, the third positioning block 13 and the fourth positioning block 14 have the same size and shape, so that the identification of each positioning block is facilitated, and in step 22, the identification of the four positioning blocks is completed by adopting the same means (method).
In an alternative embodiment, in step 22, the above method for identifying four positioning blocks in the encoded graphic further includes:
Four graphic objects which are concentric and have a plurality of annular shapes with alternate colors are determined as four positioning blocks.
As shown in fig. 1A or 1B, the first positioning block 11, the second positioning block 12, the third positioning block 13, and the fourth positioning block 14 are each in the shape of a plurality of circles concentric and alternate in color. The concentric and alternate color ring shapes can be distinguished from the surrounding environment (such as the coding region) features, and can improve the recognition success rate.
In an alternative embodiment, in step 22, the quadrilateral is constructed by:
And extracting the central coordinates of the four positioning blocks, and sequentially connecting the central coordinates of the four positioning blocks to form a quadrilateral.
Referring to fig. 1A or 1B, in step 22, it is not known which is the first positioning block 11, which is the second positioning block 12, which is the third positioning block 13, which is the fourth positioning block 14 immediately after four positioning blocks in the code pattern are identified, so that the direction of the code pattern cannot yet be determined, in the subsequent process of step 22, the fourth positioning block 14 (the inner angle of the square where the fourth positioning block 14 is located is the largest inner angle of the square) is determined first by determining the inner angle of the square constructed by connecting the center coordinates of the four positioning blocks, and then the third positioning block 13 and the second positioning block 12 (the third positioning block 13 is closer to the fourth positioning block 14 than the second positioning block 12) are determined by determining the distance between two positioning blocks adjacent to the fourth positioning block 14 in the square and the fourth positioning block 14, and finally, the positioning block opposite to the fourth positioning block 14 in the remaining square is determined as the first positioning block 11. Further, the order of reading the encoded blocks in the encoded region may be determined, for example, the first positioning block 11 and the second positioning block 12 may be positioned on the side on which the first positioning block 11 and the third positioning block 13 are positioned on the left, and when the encoded region is read, the data blocks of each row are read in the order from top to bottom, and in each row, the data blocks of each row are read in the order from left to right. Therefore, the embodiment of the invention realizes the determination of the direction of the coding pattern and the determination of the reading sequence of the coding region by utilizing the asymmetrically distributed characteristics of the four positioning blocks.
The layout of the four positioning blocks in the embodiment of the present invention adopts an asymmetric design, and after the step 22, the relative position relationship of the four positioning blocks is determined, that is, who is the first positioning block 11, who is the second positioning block 12, who is the third positioning block 13, and who is the fourth positioning block 14, so that the relative position relationship of the first positioning block 11, the second positioning block 12, the third positioning block 13, and the fourth positioning block 14 is used to determine the direction of the coding pattern, and in the subsequent step, the determination of the reading sequence of each coding block in the coding region can be realized by using the direction of the coding pattern. Therefore, in the embodiment of the invention, the asymmetric arrangement structure of the four positioning blocks carries direction information, and the direction of the coding pattern can be determined by using the four positioning blocks which are arranged asymmetrically, so that the problem that the direction of the coding pattern cannot be determined due to the mirror image problem caused by symmetric arrangement can be solved, and the embodiment of the invention does not need to adopt an additional mirror image detection step to determine the direction of the coding pattern.
In an alternative embodiment, the mapping relationship between the coding pattern and the plane without perspective distortion is determined according to the four positioning blocks in step 23, and the mapping relationship is obtained by the following method:
And determining the mapping relation of the coding graph from the image to the zero-perspective distortion plane according to the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block and the center coordinates of the fourth positioning block in the image, and the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block and the center coordinates of the fourth positioning block in the zero-perspective distortion plane.
In an alternative embodiment, in a square planar area without perspective distortion:
The first positioning block is positioned in a first corner area in the square plane area;
The second positioning block is positioned in a second corner area which is positioned in the square plane area and is not positioned on the same diagonal line with the first corner area;
a third positioning block is positioned in a third corner region which is positioned on the same diagonal line with the second corner region in the square plane region;
the position of the fourth positioning block is one of a position set of the fourth positioning block which meets the following conditions:
The fourth positioning block is located in the square plane area, and in a target quadrangle formed by the center of the first positioning block, the center of the second positioning block, the center of the third positioning block and the center of the fourth positioning block, the inner angle at which the fourth positioning block is located is the largest inner angle of the four inner angles of the target quadrangle, and the distance between the center of the fourth positioning block and the center of the third positioning block is smaller than the distance between the center of the fourth positioning block and the center of the second positioning block.
Wherein the coordinates of the fourth positioning block satisfying that the distance between the center of the fourth positioning block and the center of the third positioning block is smaller than the distance between the center of the fourth positioning block and the center of the second positioning block are one set. Preferably, the positional relationship between the four positioning blocks in the square plane area without perspective distortion should be consistent with the positional relationship between the four positioning blocks in the above-described encoding pattern embodiment of the present invention, and preferably, the quadrangle formed by the four positioning blocks in the square plane area without perspective distortion is similar to or congruent with the quadrangle formed by the four positioning blocks in the above-described encoding pattern embodiment of the present invention.
In an alternative embodiment, for the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block, and the center coordinates of the fourth positioning block in the perspective-free distortion plane in step 23, the setting is performed by the following method:
step b1, setting a first target block in a first corner area in a square plane area without perspective distortion;
step b2, setting a second target block in a second corner area in the square plane area;
Step b3, setting a third target block in a third corner region which is positioned on the same diagonal line with the second corner region in the square plane region;
B4, arranging a fourth target block in the square plane area, so that the inner angle of the position of the fourth target block is the largest inner angle of four inner angles of the target quadrangle in the target quadrangle formed by the center of the first target block, the center of the second target block, the center of the third target block and the center of the fourth target block, and the distance between the center of the fourth target block and the center of the third target block is smaller than the distance between the center of the fourth target block and the center of the second target block;
Step b5, setting the center coordinates of the first target block as the center coordinates of the first positioning block in the non-perspective distortion plane, setting the center coordinates of the second target block as the center coordinates of the second positioning block in the non-perspective distortion plane, setting the center coordinates of the third target block as the center coordinates of the third positioning block in the non-perspective distortion plane, and setting the center coordinates of the fourth target block as the center coordinates of the fourth positioning block in the non-perspective distortion plane.
In the embodiment of the invention, the reading of the information recorded in the coding region is finally performed in the front view of the coding pattern without perspective distortion. Therefore, it is necessary to perform a transformation of the photographed code pattern from the photographed image to a front view of the code pattern without perspective distortion. In the present embodiment, after the steps b1 to b5, the target coordinates of the four positioning blocks for transformation are determined in the square plane area, so that, no matter what angle the encoded pattern is photographed, the mapping relationship of the encoded pattern from the image to the encoded pattern can be determined and the image transformation can be performed immediately by using the target coordinates of the centers of the positioning blocks obtained after the steps b1 to b5 and pre-stored in front view in the encoded pattern front view without perspective, as long as the first positioning block 11, the second positioning block 12, the third positioning block 13, and the fourth positioning block 14 can be recognized and determined.
In an alternative embodiment, the mapping relationship between the coding pattern and the non-perspective distortion plane is determined according to the four positioning blocks in the step 23, and the mapping relationship is obtained through the following steps:
And 231, determining the mapping relation of the coding graph from the image to the zero-perspective distortion plane according to the center coordinates of the first positioning block, the second positioning block, the third positioning block and the fourth positioning block in the image, and the center coordinates of the first positioning block, the second positioning block, the third positioning block and the fourth positioning block in the zero-perspective distortion plane.
In an alternative embodiment, determining the mapping relationship of the coding pattern from the image to the perspective-free distortion plane according to the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block, and the center coordinates of the fourth positioning block in the image in step 231, and the center coordinates of the first positioning block, the center coordinates of the second positioning block, the center coordinates of the third positioning block, and the center coordinates of the fourth positioning block in the perspective-free distortion plane includes:
And acquiring a homography matrix corresponding to the mapping relation according to the central coordinates of the first positioning block, the central coordinates of the second positioning block, the central coordinates of the third positioning block and the central coordinates of the fourth positioning block in the image, and the central coordinates of the first positioning block, the central coordinates of the second positioning block, the central coordinates of the third positioning block and the central coordinates of the fourth positioning block in the perspective distortion-free plane.
In an alternative embodiment, transforming the encoded graphic in the image into a perspective distortion free plane according to the mapping relationship in step 23 forms an encoded graphic elevation view, comprising:
And 232, utilizing a homography matrix to projectively transform all pixel points of the coding pattern in the image into a plane without perspective distortion to form a front view of the coding pattern.
In an alternative embodiment, in step 24, the code region is located in the code pattern and is not occupied by the first, second, third, and fourth positioning blocks.
In an alternative embodiment, in step 24, in a front view of the encoded pattern, the information recorded in the encoded pattern is obtained by reading the encoded region recorded with the information that can be read, including:
Step 241, setting the edge tangent to the first positioning block and the third positioning block at the same time as a first edge, setting the edge tangent to the first positioning block and the second positioning block at the same time as a second edge, setting the edge tangent to the second positioning block only as a third edge, and setting the edge tangent to the third positioning block and the fourth positioning block at the same time as a fourth edge, among the four edges of the coding pattern in the front view of the coding pattern;
in step 242, a row of the code blocks closest to the second edge in the code region is used as a start code row, a row of the code blocks closest to the fourth edge in the code region is used as a last code row, in each row of the code blocks, the code blocks closest to the first edge are used as start code blocks, the code blocks closest to the third edge are used as last code blocks, and information of each code block is read from the start code block to the last code block in each code row in sequence from the start code row to the last code row, so as to obtain information recorded by a code pattern.
Referring to fig. 1A and 1B, in an alternative embodiment, each row of code blocks is sequentially read from the top row of code blocks shown in fig. 1A and 1B until the bottom row of code blocks is completely read, and each code block is sequentially read from left to right in each row of code blocks.
In an alternative embodiment, in step 242, the fourth locating block is skipped from reading the encoded blocks in the encoded rows while the encoded rows truncated by the fourth locating block are read.
In an alternative embodiment, after reading the coding region in step 24, the information recorded in the coding pattern is further obtained by the following method:
step 243, performing error correction decoding on the coding information obtained by reading the coding region to obtain error-corrected code words and error quantity;
step 244, outputting the error corrected codeword if the number of errors does not exceed the error correction capacity.
In an alternative embodiment, the error correction decoding employed in step 243 is RS (reed solomon) error correction decoding.
In an alternative embodiment, step 24 further includes, before performing the error correction decoding of step 243 and after obtaining the information described by the encoded pattern of step 242:
And performing bit exclusive OR processing on the coded information and the data mask matrix.
The bit exclusive or processing in the embodiment of the present invention is described in the following.
In the encoding process, the real data to be recorded in the encoding region and the data mask matrix are subjected to bit exclusive-or processing to obtain an encoding region graph avoiding black and white aggregation, in the decoding process, the encoding region graph is subjected to bit exclusive-or processing with the data mask matrix, and the data mask matrix adopted in encoding and the data mask matrix adopted in decoding are the same, because the exclusive-or follows the following combination law:
a⊕(a⊕b)=(a⊕a)⊕b
Therefore, if a is defined as the data mask matrix and b is defined as the real data to be recorded in the coding region at the time of coding, the expression "a #" b "in the left side of the above equation indicates that the real data and the data mask matrix are bit exclusive-ored at the time of coding, and if the result of" a # "b) is defined as c, the expression" c "indicates the coding region pattern avoiding black and white aggregation, and the expression" left "indicates that
a⊕(a⊕b)=a⊕c
And a to the right of the above formula, a, c, represents the bit exclusive or processing of the coding region pattern with the data mask matrix at the time of decoding.
From the two formulas, it can be seen that
a⊕c=a⊕(a⊕b)=(a⊕a)⊕b
As is known to those skilled in the art, the exclusive OR of the same values is 0, i.e., a in the above formula, a=0, there are
a⊕c=a⊕(a⊕b)=(a⊕a)⊕b=0⊕b
And those skilled in the art know that 0 exclusive-or equals the non-zero number, if b is a non-zero number, then there is
a⊕c=a⊕(a⊕b)=(a⊕a)⊕b=0⊕b=b
Since b is defined as the data to be recorded in the coding region during coding, it can be seen from the above equation that the original coded real data can be obtained by performing bit exclusive or processing on the coding region pattern and the data mask matrix (same as the data mask matrix used during coding) during decoding.
Therefore, in the preferred embodiment, the same data mask matrix is used in the encoding process and the decoding process to respectively perform bit exclusive-or processing on the real data to be recorded in the encoding region and the encoding region, so that the original encoded information recorded in the encoding region can be obtained in decoding.
Fig. 5 shows the whole process flow from initial determination of data to be encoded to final completion of encoding using the encoding method of the embodiment of the present invention. As shown in fig. 5, the process includes:
and c1, determining the maximum bit number of the data to be encoded according to application requirements.
In industrial applications, different application scenarios have different requirements for data capacity in the encoded graphics. In an alternative embodiment, for a code pattern formed by the code pattern coding method of the embodiment of the invention with an auxiliary positioning function, the stored data is typically a set of decimal numbers representing position coordinates. The position coordinates may be represented by a combination of a row and column index and a unit distance, or may be represented by only actual physical coordinates. The minimum decimal number needed to explicitly represent the scene coordinates is first required before the encoded pattern is produced.
And c2, selecting proper error correction capacity and determining the size of the coding pattern.
The error correction capacity here is the same as that of the conventional two-dimensional code, and means the number of erroneous codewords that the decoder can correct when the code word (the encoded block in the encoded region) is changed due to the influence of illumination, distortion, image noise, etc. of the encoded pattern (the two-dimensional code). The error correction capacity reflects the anti-noise performance of the encoded pattern. In industrial applications, the error correction capacity requirements of the encoded graphics are different for different scenes. In some scenes, the imaging environment can be well controlled, the error probability of the coding pattern is low, the requirement on the error correction capacity is low, in other scenes, the imaging environment is complex and changeable, the error probability of the coding pattern is high, the requirement on the error correction capacity is high, and more error correction codes are needed to ensure the decoding performance. Before coding the code pattern, the required error correction capacity t needs to be evaluated according to the characteristics of the use environment of the code pattern. From the determined number of data codes k and number of error correction codes 2t, the side length a of the encoded pattern can be calculated:
in the coding graphs of the embodiment shown in fig. 1A and 1B, m represents the diameter of the outermost ring of the positioning ring, and ceil (x) represents the minimum integer not smaller than x.
If the width q of the surrounding dead zone of the code pattern is taken into account, there is
And c3, inputting data to be encoded.
Step c4, calculating a Galois field generating polynomial, wherein the Galois field base is 2. The generator polynomial is expressed as the product of 2t first order polynomials.
And c5, performing Reed-Solomon error correction coding.
Let the data code polynomial be:
the error correction codeword polynomial is the remainder of x 2t d (x) divided by the polynomial g (x). After the error correction code is arranged in the data code, error correction coding is completed as shown in fig. 3. Or the error correction code may be placed before the data code.
Step c6, converting the data code and the error correction code into bit streams. The smallest unit in the coding region is a coding block, and different information is represented according to different colors of the coding block, wherein black represents 0 and white represents 1. Or 0 by white and 1 by black. Encoding is achieved by converting decimal codewords into binary bit streams. When in conversion, every two decimal digits are used as a group for conversion, and after all code words are converted, the code words are spliced together according to the relative sequence to form an encoded bit stream.
And c7, performing bit exclusive OR processing by applying the data mask matrix to obtain a final coding result. To prevent the occurrence of the same-color coded block aggregation in the coding region, a data mask matrix of 0,1 phase-to-phase is applied to the coding region. The data mask matrix formula is:
mask=(row+col)%2
Where row is the row number of the code block, col is the column number of the code block, and mask is the mask value. And solving the exclusive OR of the mask and the coding block value at the corresponding position to obtain a final coding result.
And c8, filling the coding blocks into the coding region in sequence. As shown in fig. 1A and 1B, when the coding blocks are filled, the coding blocks are sequentially filled in the order from left to right from the position of the first coding block (i.e., the coding block adjacent to the first positioning block 11 and the second edge 17) in the upper left corner of the coding region. When filling the last rows of each row of the code blocks isolated by the fourth positioning block 14, the code blocks of the row positioned at the left side part of the fourth positioning block 14 are sequentially filled from left to right, then the fourth positioning block 14 is skipped, and the code blocks of the row positioned at the right side part of the fourth positioning block 14 are sequentially filled from left to right until all the code blocks are filled.
And c9, drawing the positioning block.
In an alternative embodiment, the positioning block adopts the shape of a positioning ring shown in fig. 1A and 1B, wherein the width of the concentric black-white ribbon is the same in the positioning ring, the outermost side is a black ring, and the innermost side is a white ring. In alternative embodiments, the radius of the inner white circle is 3/8 of the radius of the outer black circle, and other radius ratios may be used in other embodiments.
And c10, finishing encoding, and outputting the pattern of the final encoded pattern.
Fig. 6 shows the overall process flow from determining the code pattern specification to finally completing decoding using the code pattern reading method of the embodiment of the present invention. As shown in fig. 6, the process includes:
And d1, determining the specification of the coding pattern. The decoding is carried out according to the code pattern in the encoding process, and the code pattern mainly comprises the number of data codes, the number of error correcting codes, the size of a positioning block and the like.
And d2, extracting the center coordinates of four positioning blocks of the coding pattern from the image containing the coding pattern.
For the four positioning blocks in the embodiment shown in fig. 1A and 1B, in an alternative embodiment, a Hough transformation method is used to find the four annular positioning blocks in the embodiment shown in fig. 1A and 1B, and screening is performed by using the number of concentric circles and the radius relationship in each positioning block, so as to determine the center coordinate of each positioning block in the image containing the coding pattern. The Hough transformation method is an existing method, and the determination of the barycentric coordinates of the concentric circles by utilizing the screening mode of the number and the radius relation of the concentric circles in each positioning block can be realized by adopting the prior art, and the description is omitted here.
And d3, determining the sequence of the four positioning blocks.
In this step, the order of determining the four positioning blocks is to determine a first positioning block, a second positioning block, a third positioning block and a fourth positioning block of the four positioning blocks.
In the step, the asymmetry of the positions of the four positioning blocks is utilized to determine a first positioning block, a second positioning block, a third positioning block and a fourth positioning block. In the embodiment shown in fig. 1A and 1B, in the quadrangle formed by four positioning blocks, the included angle formed by two adjacent sides of the positioning block at the lower right corner is the largest inside angle of four inside angles of the quadrangle, so that the inside angle of the quadrangle corresponding to the four positioning blocks is calculated, the positioning block at the position of the largest inside angle (the lower right corner of the quadrangle) is determined as the fourth positioning block, further, the positioning block closest to the fourth positioning block at the two sides of the largest inside angle is determined as the third positioning block (the positioning block at the lower left corner of the quadrangle), the positioning block farthest from the fourth positioning block at the two sides of the largest inside angle is determined as the second positioning block (the positioning block at the upper right corner of the quadrangle), and the rest positioning blocks are determined as the first positioning blocks (the positioning blocks at the upper left corner of the quadrangle).
And d4, solving a homography matrix according to the central coordinates of the four positioning blocks in the image and the corresponding coordinates of the four positioning blocks in the non-perspective distortion plane. And projecting all pixel points in the coding pattern area to a plane without perspective distortion by utilizing a homography matrix to obtain a coding pattern image without perspective distortion, namely a coding pattern front view.
And d5, obtaining a binary image of the coding pattern by a thresholding method in the coding pattern area in the front view of the coding pattern.
And d6, calculating the length of the coding block in the coding region according to the side length of the positioning block and the side length of the coding region. And dividing grids by taking the length of the coding block as a step length, and reading the bit value of each grid. The decision threshold T can be set according to the actual requirement, when the number of white pixels in the grid exceeds T, the white module is decided, otherwise, the black module is decided. As shown in fig. 1A and 1B, starting from the coding blocks adjacent to the first positioning block 11 and the second edge 17, the code words of each coding block are sequentially read according to the sequence of coding (that is, each row is sequentially read from left to right and from top to bottom), until all the code words are read.
And d7, performing bit exclusive OR processing on the code words of each coding block by using a mask to obtain information before the mask.
And d8, performing Reed-Solomon error correction decoding to obtain an error correction result.
The error correction result includes the error corrected codeword and the number of errors.
And d9, judging whether decoding is successful or not according to the error number calculated in the step d 8. If the number of errors exceeds the error correction capacity t, the error correction decoding cannot be completed, step d10 is executed, otherwise, the decoding is successful, and step d11 is executed.
And d10, outputting a decoding failure result because the number of errors is larger than the error correction capacity.
Step d11, decoding is successful, and outputting the error-corrected code word.
The coding pattern in the embodiment of the invention can be formed on the calibration plate to assist in positioning the calibration plate in the camera calibration process, wherein the coding region in the coding pattern can record the coordinates (index coordinates or physical coordinates) of the marking points of the coding pattern and/or the related information (such as the physical distance between the characteristic points in the calibration plate) of the calibration plate.
The embodiment of the invention also provides a shooting device, as shown in fig. 7, which comprises a shooting unit 31 and a processor 32. Wherein the photographing unit 31 is used for photographing the surface of the object containing the coding pattern, and obtaining the image containing the coding pattern. The processor 32 is configured to identify four positioning blocks in the code pattern in the image containing the code pattern, determine a mapping relation between the code pattern from the image to the non-perspective distortion plane based on the four positioning blocks, transform the code pattern in the image into the non-perspective distortion plane based on the mapping relation to form a front view of the code pattern, and obtain information recorded in the code pattern by reading the code region recorded with information that can be read in the front view of the code pattern.
Embodiments of the present invention also provide a non-transitory computer-readable storage medium storing instructions that, when executed by a processor, cause the processor to perform the steps in the encoding method of encoding a graphic as described in the embodiments above.
Embodiments of the present invention also provide a non-transitory computer readable storage medium storing instructions that, when executed by a processor, cause the processor to perform the steps in the encoded pattern reading method as described in the embodiments above.
An embodiment of the present invention further provides an electronic device, where the structure may be shown in fig. 8, and the electronic device includes at least one processor 41, and a memory 42 communicatively connected to the at least one processor 41, where the memory 42 stores instructions executable by the at least one processor 41, and the instructions are executed by the at least one processor 41, so that the at least one processor 41 performs the steps in the coding method of the coding pattern according to any one of the embodiments above.
An embodiment of the present invention further provides an electronic device, where the structure may also be seen in fig. 8, and the electronic device includes at least one processor 41, and a memory 42 communicatively connected to the at least one processor 41, where the memory 42 stores instructions executable by the at least one processor 41, and the instructions are executed by the at least one processor 41 to cause the at least one processor 41 to perform the steps in the method for reading an encoded pattern according to any one of the embodiments above.
In the embodiment of the encoding method, the encoding graph reading method, the shooting device, the nonvolatile computer readable storage medium and the electronic equipment, the encoding method, the encoding graph reading method, the shooting device and the nonvolatile computer readable storage medium replace the existing two-dimensional code standard, the authorization cost and the manufacturing cost required by adopting the existing two-dimensional code generating software are saved, and the encoding method, the encoding graph reading method, the shooting device, the nonvolatile computer readable storage medium and the electronic equipment are not limited by the use limitation of the existing two-dimensional code generating software. In addition, in the embodiment of the invention, three of the four positioning blocks are respectively positioned at three corners of the coding pattern, and the other positioning block is tangent to the edge of the coding pattern only, so that the asymmetric distribution configuration of the four positioning blocks is formed, thereby realizing accurate and rapid positioning of the coding pattern and ensuring accurate reading of the coding region by utilizing the asymmetric distribution configuration of the four positioning blocks. In addition, in the embodiment of the invention, the asymmetric arrangement structure of the four positioning blocks is provided with direction information, and the direction of the coding pattern can be determined by utilizing the four positioning blocks which are arranged asymmetrically, so that the problem that the direction of the coding pattern cannot be determined due to the mirror image problem caused by symmetric arrangement can be solved, and further, when the data of the coding pattern in the positive and negative directions are read, the direction of the coding pattern can be identified, thereby realizing the purpose of carrying out data reading on the same coding pattern in the positive and negative directions and increasing the application range of the coding pattern. The embodiment of the invention can set the size of the coding pattern area and the size of the coding area according to the data size of the application scene so as to flexibly set the data information recorded by the coding pattern. In the embodiment of the invention, the coding region has error-proofing performance by using a Reed-Solomon error correction mechanism, and error codes which do not exceed the error correction capacity can be corrected. The coding mode of the coding region in the embodiment of the invention is simple, and the efficiency of the scene with smaller coded data volume is higher.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather to enable any modification, equivalent replacement, improvement or the like to be made within the spirit and principles of the invention.
Claims (34)
Priority Applications (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910606064.9A CN112187284B (en) | 2019-07-05 | 2019-07-05 | Coding method, coding pattern, coding pattern reading method and shooting device |
EP20837644.2A EP3996283B1 (en) | 2019-07-05 | 2020-07-04 | Coding pattern, coding and reading methods for same, calibration board, and calibration method |
US17/624,953 US11843395B2 (en) | 2019-07-05 | 2020-07-04 | Coding pattern, coding and reading methods for same, calibration board, and calibration method |
PCT/CN2020/100304 WO2021004414A1 (en) | 2019-07-05 | 2020-07-04 | Coding pattern, coding and reading methods for same, calibration board, and calibration method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910606064.9A CN112187284B (en) | 2019-07-05 | 2019-07-05 | Coding method, coding pattern, coding pattern reading method and shooting device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112187284A CN112187284A (en) | 2021-01-05 |
CN112187284B true CN112187284B (en) | 2025-04-04 |
Family
ID=73918756
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910606064.9A Active CN112187284B (en) | 2019-07-05 | 2019-07-05 | Coding method, coding pattern, coding pattern reading method and shooting device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112187284B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114027351A (en) * | 2021-10-29 | 2022-02-11 | 智锐达仪器科技南通有限公司 | Marking system and decoding system for livestock carcasses |
CN115936037B (en) * | 2023-02-22 | 2023-05-30 | 青岛创新奇智科技集团股份有限公司 | Decoding method and device for two-dimensional code |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102999772A (en) * | 2012-11-14 | 2013-03-27 | 韩偲铭 | Novel array-type two-dimension code encoding and decoding methods |
WO2018177127A1 (en) * | 2017-03-31 | 2018-10-04 | 腾讯科技(深圳)有限公司 | Information processing method and apparatus, and storage medium |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR101052403B1 (en) * | 2004-03-15 | 2011-07-28 | 셴젠 시스칸 테크놀러지 코오퍼레이션 리미티드 | 2D barcodes and their coding / decoding methods |
CN101093553A (en) * | 2007-07-19 | 2007-12-26 | 成都博古天博科技有限公司 | 2D code system, and identification method |
CN102243704B (en) * | 2011-07-21 | 2014-04-02 | 我查查信息技术(上海)有限公司 | Positioning system for two-dimension bar code and two-dimension bar code identification method and equipment |
CN109754046B (en) * | 2019-01-31 | 2022-09-27 | 北京迈格威科技有限公司 | Two-dimensional code, two-dimensional code encoding method, decoding method, device and equipment |
-
2019
- 2019-07-05 CN CN201910606064.9A patent/CN112187284B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102999772A (en) * | 2012-11-14 | 2013-03-27 | 韩偲铭 | Novel array-type two-dimension code encoding and decoding methods |
WO2018177127A1 (en) * | 2017-03-31 | 2018-10-04 | 腾讯科技(深圳)有限公司 | Information processing method and apparatus, and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112187284A (en) | 2021-01-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11843395B2 (en) | Coding pattern, coding and reading methods for same, calibration board, and calibration method | |
US7264174B2 (en) | 2D coding and decoding barcode and its method thereof | |
TWI746882B (en) | Two-dimensional barcode, printed publication, generating device, and information processing method | |
CN111046996B (en) | Color QR code generation and identification method | |
US8459565B2 (en) | Two-dimensional code generating apparatus, image forming system, two-dimensional code reading apparatus, and computer readable medium | |
CN112184826B (en) | Calibration plate and calibration method | |
US9892300B2 (en) | Two-dimensional code | |
US10679175B2 (en) | Two-dimensional code, system for creation of two-dimensional code, and analysis program | |
CN112926715B (en) | Two-dimensional code generation and decoding method, device and equipment | |
JP2006012162A (en) | System and method for encoding high density geometric symbol set | |
JP2007317184A (en) | Two-dimensional bar code, and encoding and decoding method thereof | |
CN104636780B (en) | Matrix two-dimensional code and its coding method and interpretation method | |
JP4410231B2 (en) | Image code generating apparatus and method, and image code decoding apparatus and method | |
CN105989317A (en) | Identification method of two-dimensional code and apparatus thereof | |
CN111275152A (en) | Two-dimensional code, encoding method and decoding method of two-dimensional code, decoding device of two-dimensional code and electronic system | |
CN112187284B (en) | Coding method, coding pattern, coding pattern reading method and shooting device | |
CN107247985A (en) | Coding, positioning and the recognition methods of New Two Dimensional code | |
CN107563477A (en) | Quick Response Code and its generation method and device | |
JP6856956B2 (en) | How to detect and recognize long-range high-density visual markers | |
CN112183695B (en) | Coding method, coding pattern reading method, and photographing apparatus | |
CN112184803A (en) | Calibration plate and calibration method | |
CN109635613B (en) | Two-dimensional code generation method, system and device for sphere surface | |
CN111191759A (en) | Two-dimensional code generation method and positioning and decoding method based on GPU | |
CN120146083A (en) | Dual dynamic three-dimensional code based on random color textures and generating, encoding, identifying and decoding methods and generating devices thereof | |
HK1115004A (en) | A two-dimensional barcode and its coding and decoding method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 310051 room 304, B / F, building 2, 399 Danfeng Road, Binjiang District, Hangzhou City, Zhejiang Province Applicant after: Hangzhou Hikvision Robot Co.,Ltd. Address before: 310052 5 / F, building 1, building 2, no.700 Dongliu Road, Binjiang District, Hangzhou City, Zhejiang Province Applicant before: HANGZHOU HIKROBOT TECHNOLOGY Co.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TG01 | Patent term adjustment | ||
TG01 | Patent term adjustment |