CN107247985B - Coding, positioning and identifying method of two-dimensional code - Google Patents
Coding, positioning and identifying method of two-dimensional code Download PDFInfo
- Publication number
- CN107247985B CN107247985B CN201710393558.4A CN201710393558A CN107247985B CN 107247985 B CN107247985 B CN 107247985B CN 201710393558 A CN201710393558 A CN 201710393558A CN 107247985 B CN107247985 B CN 107247985B
- Authority
- CN
- China
- Prior art keywords
- matrix
- dimensional code
- value
- code
- positioning
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06037—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
-
- B—PERFORMING OPERATIONS; TRANSPORTING
- B33—ADDITIVE MANUFACTURING TECHNOLOGY
- B33Y—ADDITIVE MANUFACTURING, i.e. MANUFACTURING OF THREE-DIMENSIONAL [3-D] OBJECTS BY ADDITIVE DEPOSITION, ADDITIVE AGGLOMERATION OR ADDITIVE LAYERING, e.g. BY 3-D PRINTING, STEREOLITHOGRAPHY OR SELECTIVE LASER SINTERING
- B33Y80/00—Products made by additive manufacturing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06046—Constructional details
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Chemical & Material Sciences (AREA)
- Manufacturing & Machinery (AREA)
- Materials Engineering (AREA)
- Image Processing (AREA)
- Error Detection And Correction (AREA)
Abstract
The invention discloses a novel two-dimensional code coding, positioning and identifying method, wherein a mark post is added in the middle of a two-dimensional matrix to fix coding information, a row of all-0 or all-1 values are added on the left side of each row of the matrix on the basis of a two-dimensional code symbol of an n x n matrix, and the n x n matrix is converted into an n x 2n matrix for coding, so that the phenomenon that printing cannot be performed when the two-dimensional code is not coherent during hollow printing is prevented, and the two-dimensional code is subsequently positioned and identified and then converted into the n x n matrix, so that the identification of the two-dimensional code is facilitated, and meanwhile, the problem that the incoherent phenomenon occurs during hollow printing and the whole two-dimensional code region cannot be completely represented is solved. The invention is suitable for printing and identifying the hollow printed two-dimensional code.
Description
Technical Field
The invention belongs to the field of information storage and 3D printing, and relates to a coding, positioning and identifying method of a two-dimensional code.
Background
The DataMatrix is a two-dimensional code widely used in the international manufacturing field, is invented by the international data corporation of the united states in 1989, is widely used for anti-counterfeiting and overall marking of commodities, is a code which can be directly marked on the surface of a solid body, can be automatically read by a corresponding scanning device like a common bar code, and is popular in the manufacturing industry. At present, Data Matrix is widely used in systems of product identification, anti-counterfeiting, quality tracking, automatic warehousing, logistics management and control and the like. The Data Matrix adopts a complex error correcting code technology, so that the code has super pollution resistance. Even if the code part is damaged, the whole information can not be read out. The printing characteristics of Data Matrix make it the only support at present for directly marking (printing, engraving, photolithography, etching, stamping, etc.) the surface of the product or component. Its high-efficiency fault-tolerant performance makes it possible to bear the pollution of surface mark of component in the course of manufacture or circulation, so that it is very popular in manufacturing industry. Various forms of Data Matrix symbology standards have been promulgated internationally for a variety of different applications. The minimum size of Data Matrix is the smallest of all barcodes at present, and is particularly suitable for the identification of small parts and the direct printing on a solid body.
The DataMatrix code is a matrix type two-dimensional bar code and has the greatest characteristicIs high density and its smallest size is the smallest code among all barcodes at present. The DM code can be only 25mm2Encode 30 numbers on the area. The DM adopts a complex error correcting code technology, so that the code has super-strong anti-pollution capability. The Data Matrix provides a very small and high-density label and can still store reasonable Data content, so the Data Matrix is particularly suitable for small part identification, commodity anti-counterfeiting, circuit identification and the like. Due to its excellent error correction capability, the DM code has become the mainstream technology of the korean mobile phone two-dimensional barcode. Compared with QR, the DM code is simple in application due to small difference of information capacity, is called as a 'simple code' in the industry, has low requirement on a terminal, can be identified by a mobile phone with 30 ten thousand pixels, and is more added value based on WAP. The two-dimensional code brings a new entrance to the internet of the mobile phone, and a user can quickly enter a WAP website to quickly browse through scanning various bar codes. The Data Matrix symbol looks like a chessboard consisting of two colors of light and dark, each of which is a black or white square of the same size called a Data unit, and consists of many such Data units. And a dead zone with the width of one data unit is arranged outside the edge searching zone. The border-seeking area is the boundary of the chessboard and is only used for positioning and defining the size of a data unit, and does not contain any coding information. The data area surrounded by the seek edge area contains the encoded information.
The dot matrix type two-dimensional code mainly comprises a mark area, a blank area, a detection area, a data area and a filling area, wherein the data area is located in the middle of a two-dimensional code graph, the detection area is located around the data area and is formed by two solid lines and two dotted lines, the blank area is located around the periphery of the detection area, the filling area of part of the two-dimensional code graph is located at the lower right corner of the data area, and the mark area is used for separating two-dimensional matrix data. Dot matrix two-dimensional code is applicable to the printout of 3D printer in the industrial production line, and the problem of printing discontinuity because the many connected regions of two-dimensional matrix formation cause when solving the uneven, various, the low and easy stained problem of shooting angle of illumination among the two-dimensional code discernment and two-dimensional code 3D printout.
The dot matrix type two-dimensional code mainly comprises a mark area, a blank area, a detection area, a data area and a filling area, wherein the blank area is positioned at the periphery of a two-dimensional code graph and is mainly used for separating symbols of the two-dimensional code from a background, the detection area can represent the width of a module and is the boundary of the data area, the detection area is composed of two parts, one part is an L-type solid line edge formed by a left boundary and a lower boundary, the other part is a L-type dotted line edge formed by an upper boundary and a right boundary and is mainly used for limiting the unit structure of the symbols and also can be used for determining the problems of physical size and symbol distortion, the data area is a square area formed by reserved points and hollowed-out points, the storage mode of the inside information is different arrangement combinations of the reserved points and the hollowed-out points, binary coding is adopted, the code word information and error correction information are included in the data area, the data area with partial size cannot be completely filled in the data area due to the code word information and the error correction information, the data area can cause that the blank area exists in the blank area, the blank area is positioned at the right side of the data area, the two-dimensional code area is generally in the alternate arrangement mode of the reserved points, the two-dimensional code area, the blank area can be printed as a dot matrix, if the printed as a ' 0 ', the whole printed ' dot matrix, and the two-dimensional code can be printed ' 1 ' or the.
Therefore, the method for fixing the coded information by adding the marker post in the middle of the two-dimensional matrix has important significance.
Disclosure of Invention
The invention aims to solve the technical problem of providing a coding, positioning and identifying method of a two-dimensional code, wherein a mark post is added in the middle of a two-dimensional matrix to fix coding information, a row of all-0 or all-1 values is added on the left side of each row of the matrix on the basis of a two-dimensional code symbol of an n x n matrix, and the n x n matrix is converted into an n x 2n matrix for coding by adopting a method, so that the phenomenon that printing cannot be performed when the two-dimensional code is subjected to hollow printing is prevented, and the phenomenon that the two-dimensional code cannot be printed when the two-dimensional code is subsequently positioned and identified is converted into the n x n matrix, so that the two-dimensional code can be conveniently identified, and the problem that the whole two-dimensional code area cannot be completely represented due to the non-consistent phenomenon during hollow printing is solved.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a coding, positioning and identifying method of a two-dimensional code is carried out according to the following steps:
a) coding method
1) Converting the data information into data code words;
2) generating error correction code words according to a Reed-Solomon algorithm and error correction requirements;
3) placing error correction code words into the matrix according to a standard template to generate two-dimensional code symbols of the n x n matrix;
4) on the basis of the two-dimensional code symbol of the n x n matrix, adding a column of all 0 or all 1 values on the left side of each column of the matrix, and converting the n x n matrix into an n x 2n matrix;
two) two-dimension code area positioning method
1) Determining the position of the corner by using a Harris corner detection algorithm;
2) extracting a straight line from the corner by a Hough transformation method;
three) two-dimensional code area identification method
1) Using a two-dimensional Gaussian convolution operator for image I (x, y) by block sizePerforming convolution;
2) performing binarization calculation on the convolved image by using an OTSU algorithm to obtain a binarization matrix;
3) and taking out the second column of the obtained binary matrix from the initial column, then taking out the value of the next column at intervals, sequentially placing the taken-out columns in a new matrix column, converting the n x 2n matrix to obtain the n x n new matrix which is the two-dimensional code matrix, and decoding the two-dimensional code matrix by using a decoding algorithm to obtain code word information.
As a limitation of the present invention, in step one), the data information is converted into the data codeword according to the ASCII basic encoding rule.
As a further limitation of the above definition, the ASCII basic encoding rule is:
1) basic ASCII characters, namely characters with ASCII values of 0-127, adding 1 to the original value when encoding data, and the encoded code word value is 1-128;
2) the extended ASCII characters, i.e., the characters with ASCII value 128-255, are encoded into two values using the control character 235, the first is to add the switching codeword 235 to the codeword stream, and the second is to subtract 128 from the original ASCII value and add 1 to obtain the result;
3) two digits 00-99, or more than two digits connected, using 130-299 coding, i.e. adding 130 to the actual value of two digits, the coded codeword value is 130-229;
4) in the actual encoding process, when the encoded code words cannot completely occupy the number of the code words, padding characters are added after the code words are encoded; the code word after the first pad character is encoded is 129, and the encoding result of the following pad character is that a pseudo-random number is added on the basis of 129, and the algorithm is 253 state random algorithm.
As another limitation of the present invention, the error correction requirement of 2) in step one) is:
i) establishing a codeword polynomial C (X)
C(X)=Cn-1Xn-1+k+Cn-2Xn-2+k+…+C1X1+k+C0Xk;
Wherein, Cn-1,Cn-2,…,C1,C0Is a data codeword, Cn-1Is the first data codeword, C0Is the last data codeword, k is the number of error correction codewords;
ii) establishing an error correction codeword generator polynomial G (x)
G(X)=Xk+Gk-1Xk-1+…+G1X+G0
All operations in the above formula are based on Galois fields;
iii) using C (X) and G (x) to obtain error correction code polynomial E (X)
E(X)=Ek-1Xk-1+Ek-2Xk-2+…+E1X+E0
Ek-1,Ek-2,…,E1,E0For error correcting code words, Ek-1Is the first error correction codeword, E0Is the last error correction codeword; the calculation method of E (X) is also based on Galois field.
As a third limitation of the present invention, the method of 3) in the step one) is:
the final generated code word stream is Cn-1,Cn-2,...,C1,C0,Ek-1,Ek-1,...,E1,E0The code word symbols are placed according to a standard template.
As a fourth limitation of the present invention, the method of step 1) in step two) is:
i) setting the function of an image as I (x, y), and expanding each pixel point of the image by using Taylor to approximate any direction of the neighborhood, so that the energy of each pixel point and the neighborhood thereof is as follows:
and performing linear transformation expansion and arrangement on the function to obtain:
the final result after unfolding is:
in the formula, lx is the difference in the x direction, ly is the difference in the y direction, and w (x, y) is a Gaussian function;
ii) two eigenvectors l due to the matrix M1And l2Proportional to the principal curvature of the matrix M; wherein l1And l2Is a matrixProjecting base vectors of different dimensions in space; by means of1,l2To characterize the two directions of fastest and slowest change; if the two are large, the two are angular points, one is large and the other is small, the two are small, and the two are in image areas with slow change; however, the solution of the eigenvector needs more calculation amount, and the product of the two eigenvalues is equal to the determinant of the matrix M as the sum of the two eigenvalues is equal to the trace of the matrix M;
the energy at the corner point is determined by the following equation:
R=detM-k(traceM)2(ii) a Wherein k is 0.04-0.06.
Iii) for the resulting energy matrix R, inTraverse matrix R, findAnd if the energy response of the maximum value point in the region is greater than the threshold value t, the maximum value point is regarded as a needed corner point.
As a fifth limitation of the present invention, the method of step 2) in the second step) is:
extracting straight lines from the detected corner points by using a Hough transformation method to obtain positioning information of the two-dimensional code area;
the linear equation of a straight line in the rectangular coordinate system is:
y=k*x+b
since the straight line in the rectangular coordinate system becomes a sine curve in the polar coordinate system, the equation for converting the straight line into the polar coordinate system is as follows:
p=x*cos(a)+y*sin(a)
in the above formula, a is an included angle between a ray led out from an origin and the positive direction of an x axis under a polar coordinate system, and p is the length of a perpendicular line led out from the origin; after detecting angular points in the image, a sinusoidal curve of the angular point has a common intersection point in a polar coordinate through Hough transformation; the calculation process of the Hough transformation algorithm is as follows:
(1) mapping each point of the image space to a group of accumulators in the Hough space according to an equation of a rectangular coordinate system;
(2) each common intersection that satisfies the above equation will add 1 to the value in the corresponding accumulator;
(3) detecting a local maximum in the accumulator;
if the image contains a straight line, a corresponding accumulator can generate a local maximum value, a pair of parameters corresponding to the straight line can be determined by detecting the local maximum value in the Hough space, and the straight line extracted from the public parameters is the edge position in the two-dimensional code region, so that the two-dimensional code region is extracted by performing straight line detection on the detected corner through Hough transformation.
As a sixth limitation of the present invention, the method of step three) 1) is:
using a two-dimensional Gaussian convolution operator for image I (x, y) by block sizePerforming convolution by the process of being in a regionCarrying out weighted summation on the regions corresponding to the internal Gaussian operators and the image, and outputting a resultA matrix of (a), the value of each pixel in the matrix representing a gaussian weighting value for each block;
wherein the gaussian operator is:
assuming that the convolved image is G (x, y), then:
In yet another limitation of the present invention, the method of step three) 2) is:
if the value range of the pixels in the region is (min-max), the total number of the pixels in the region is N, and the optimal threshold for binarizing the region is T, T ∈ (min-max), then when the threshold is Ti:
1) if the number of pixels with the gray scale value larger than Ti in the region is sum1, and the sum of the pixels is max1, the average gray scale value is:the weight is:
2) the number of pixels with the gray scale value smaller than Ti in the region is sum2, the sum of the pixels is max2, and the average value of the gray scales is:the weight is:
3) the overall gray level mean value of the region is obtained as follows: avg3 ═ w1 ═ avg1+ w2 ═ avg 2;
thus, the two-part sum of variance is obtained as: plus ═ w1 ═ w (avg1-avg3) ^2) + w2 ^ w ((avg2-avg3) ^ 2);
4) and traversing all Ti, and taking the threshold value of the maximum variance value as a threshold value for binarizing the area.
Due to the adoption of the technical scheme, compared with the prior art, the invention has the technical progress that:
the invention adds a mark post in the middle of the two-dimensional matrix to fix the coding information, and adopts a method of adding a row of all 0 or all 1 values on the left side of each row of the matrix on the basis of the two-dimensional code symbol of the n x n matrix to code the matrix of the n x n into the matrix of the n x 2n, thereby preventing the phenomenon that the two-dimensional code cannot be printed when the two-dimensional code is not coherent during hollow printing, and converting the two-dimensional code into the matrix of the n x n when the two-dimensional code is positioned and identified subsequently, which can not only facilitate the identification of the two-dimensional code, but also solve the problem that the whole two-dimensional code area cannot be completely represented because the phenomenon of discontinuity occurs during hollow printing. The dot matrix type DM code is a matrix type two-dimensional code and is formed by arranging reserved points and hollow points according to a format of a two-dimensional matrix; by adopting the method, the problem of discontinuous printing caused by the fact that the two-dimensional matrix forms a multi-communication area can be solved, all 0 or all 1 columns are used as fixed supports during printing to realize hollow printing of the two-dimensional code, and the two-dimensional code with n x n square matrixes with 0 and 1 values is regenerated during subsequent two-dimensional code identification, so that the typesetting mode of the symbol to be changed is convenient to print.
The invention is suitable for printing and identifying the hollow printed two-dimensional code.
The invention will be described in further detail below with reference to the drawings and specific examples.
Drawings
Fig. 1 is a schematic diagram of the generation of the code in step one) in embodiment 1 of the present invention;
fig. 2 is a schematic diagram of corner determination in step 1) in step two) in embodiment 1 of the present invention;
FIG. 3 is a schematic diagram of the extraction line of step 2) in step two) in example 1 of the present invention;
fig. 4 is a schematic diagram of the two-dimensional code identification in step 3) in step three) in embodiment 1 of the present invention.
Detailed Description
Embodiment 1 two-dimensional code encoding, positioning and identifying method
A coding, positioning and identifying method of a two-dimensional code is carried out according to the following steps:
a) coding method
1) Converting the data information into data code words;
converting the data information into data code words according to an ASCII basic coding rule; the ASCII basic encoding rule is as follows:
1) basic ASCII characters, namely characters with ASCII values of 0-127, adding 1 to the original value when encoding data, and the encoded code word value is 1-128;
2) the extended ASCII characters, i.e., the characters with ASCII value 128-255, are encoded into two values using the control character 235, the first is to add the switching codeword 235 to the codeword stream, and the second is to subtract 128 from the original ASCII value and add 1 to obtain the result;
3) two digits 00-99, or more than two digits connected, using 130-299 coding, i.e. adding 130 to the actual value of two digits, the coded codeword value is 130-229;
4) in the actual encoding process, when the encoded code words cannot completely occupy the number of the code words, padding characters are added after the code words are encoded; the code word after the first pad character is encoded is 129, and the encoding result of the following pad character is that a pseudo-random number is added on the basis of 129, and the algorithm is 253 state random algorithm.
2) Generating error correction code words according to a Reed-Solomon algorithm and error correction requirements;
the specific method comprises the following steps: i) establishing a codeword polynomial C (X)
C(X)=Cn-1Xn-1+k+Cn-2Xn-2+k+…+C1X1+k+C0Xk;
Wherein, Cn-1,Cn-2,…,C1,C0Is a data codeword, Cn-1Is the first data codeword, C0Is the last data codeword, k is the number of error correction codewords;
ii) establishing an error correction codeword generator polynomial G (x)
G(X)=Xk+Gk-1Xk-1+…+G1X+G0
All operations in the above formula are based on Galois fields;
iii) using C (X) and G (x) to obtain error correction code polynomial E (X)
E(X)=Ek-1Xk-1+Ek-2Xk-2+…+E1X+E0
Ek-1,Ek-2,...,E1,E0For error correcting code words, Ek-1Is the first error correction codeword, E0Is the last error correction codeword; the calculation method of E (X) is also based on Galois field.
The method 3) in the step one) comprises the following steps:
the final generated code word stream is Cn-1,Cn-2,...,C1,C0,Ek-1,Ek-1,...,E1,E0The code word symbols are placed according to a standard template.
3) Placing error correction code words into the matrix according to a standard template to generate two-dimensional code symbols of the n x n matrix;
4) on the basis of the two-dimensional code symbol of the n x n matrix, adding a column of all 0 or all 1 values on the left side of each column of the matrix, converting the n x n matrix into an n x 2n matrix, and generating a code as shown in fig. 1;
two) two-dimension code area positioning method
1) A Harris corner detection algorithm, which determines the positions of the corners, as shown in fig. 2;
the specific method comprises the following steps:
i) setting the function of an image as I (x, y), and expanding each pixel point of the image by using Taylor to approximate any direction of the neighborhood, so that the energy of each pixel point and the neighborhood thereof is as follows:
and performing linear transformation expansion and arrangement on the function to obtain:
the final result after unfolding is:
in the formula, lx is the difference in the x direction, ly is the difference in the y direction, and w (x, y) is a Gaussian function;
ii) two eigenvectors l due to the matrix M1And l2Proportional to the principal curvature of the matrix M; wherein l1And l2Is a matrixProjecting base vectors of different dimensions in space; by means of1,l2To characterize the two directions of fastest and slowest change; if the two are large, the two are angular points, one is large and the other is small, the two are small, and the two are in image areas with slow change; however, the solution of the eigenvector needs more calculation amount, and the product of the two eigenvalues is equal to the determinant of the matrix M as the sum of the two eigenvalues is equal to the trace of the matrix M;
the energy at the corner point is determined by the following equation:
R=detM-k(traceM)2(ii) a Wherein k is 0.04-0.06.
Iii) for the resulting energy matrix R, inTraverse matrix R, findAnd if the energy response of the maximum value point in the region is greater than the threshold value t, the maximum value point is regarded as a needed corner point.
2) The Hough transform method extracts straight lines from the corner points, as shown in fig. 3;
the specific method comprises the following steps: extracting straight lines from the detected corner points by using a Hough transformation method to obtain positioning information of the two-dimensional code area;
the linear equation of a straight line in the rectangular coordinate system is:
y=k*x+b
since the straight line in the rectangular coordinate system becomes a sine curve in the polar coordinate system, the equation for converting the straight line into the polar coordinate system is as follows:
p=x*cos(a)+y*sin(a)
in the above formula, a is an included angle between a ray led out from an origin and the positive direction of an x axis under a polar coordinate system, and p is the length of a perpendicular line led out from the origin; after detecting angular points in the image, a sinusoidal curve of the angular point has a common intersection point in a polar coordinate through Hough transformation; the calculation process of the Hough transformation algorithm is as follows:
(1) mapping each point of the image space to a group of accumulators in the Hough space according to an equation of a rectangular coordinate system;
(2) each common intersection that satisfies the above equation will add 1 to the value in the corresponding accumulator;
(3) detecting a local maximum in the accumulator;
if the image contains a straight line, a corresponding accumulator can generate a local maximum value, a pair of parameters corresponding to the straight line can be determined by detecting the local maximum value in the Hough space, and the straight line extracted from the public parameters is the edge position in the two-dimensional code region, so that the two-dimensional code region is extracted by performing straight line detection on the detected corner through Hough transformation.
Three) two-dimensional code area identification method
1) Using a two-dimensional Gaussian convolution operator for image I (x, y) by block sizePerforming convolution;
using a two-dimensional Gaussian convolution operator for image I (x, y) by block sizePerforming convolution by the process of being in a regionCarrying out weighted summation on the regions corresponding to the internal Gaussian operators and the image, and outputting a resultA matrix of (a), the value of each pixel in the matrix representing a gaussian weighting value for each block;
wherein the gaussian operator is:
assuming that the convolved image is G (x, y), then:
2) Performing binarization calculation on the convolved image by using an OTSU algorithm to obtain a binarization matrix;
if the value range of the pixels in the region is (min-max), the total number of the pixels in the region is N, and the optimal threshold for binarizing the region is T, T ∈ (min-max), then when the threshold is Ti:
1) if the number of pixels with the gray scale value larger than Ti in the region is sum1, and the sum of the pixels is max1, the average gray scale value is:the weight is:
2) the number of pixels with the gray scale value smaller than Ti in the region is sum2, the sum of the pixels is max2, and the average value of the gray scales is:the weight is:
3) the overall gray level mean value of the region is obtained as follows: avg3 ═ w1 ═ avg1+ w2 ═ avg 2;
thus, the two-part sum of variance is obtained as: plus ═ w1 ═ w (avg1-avg3) ^2) + w2 ^ w ((avg2-avg3) ^ 2);
4) and traversing all Ti, and taking the threshold value of the maximum variance value as a threshold value for binarizing the area.
3) And taking out the second column of the obtained binary matrix from the initial column, then taking out the value of the next column at intervals, sequentially placing the taken-out columns in a new matrix column, converting the n x 2n matrix to obtain the n x n new matrix which is the two-dimensional code matrix, and decoding the two-dimensional code matrix by using a decoding algorithm to obtain code word information as shown in fig. 4.
By adopting the method, the problem that the printing cannot be carried out when the two-dimension code is not connected in a hollow printing process is solved, and the two-dimension code is converted into an n x n matrix when the two-dimension code is positioned and identified subsequently, so that the identification of the two-dimension code can be facilitated, and the problem that the whole two-dimension code area cannot be completely represented due to the disconnected phenomenon in the hollow printing process is solved. The dot matrix type DM code is a matrix type two-dimensional code and is formed by arranging reserved points and hollow points according to a format of a two-dimensional matrix; by adopting the method, the problem of discontinuous printing caused by the fact that the two-dimensional matrix forms a multi-communication area can be solved, all 0 or all 1 columns are used as fixed supports during printing to realize hollow printing of the two-dimensional code, and the two-dimensional code with n x n square matrixes with 0 and 1 values is regenerated during subsequent two-dimensional code identification, so that the typesetting mode of the symbol to be changed is convenient to print.
The foregoing is directed to preferred embodiments of the present invention, other and further embodiments of the invention, and equivalents thereof, as may be devised by those skilled in the art using the foregoing teachings. However, simple modifications, equivalent changes and modifications made to the above embodiments according to the technical essence of the present invention are within the scope of the claims of the present invention, unless departing from the technical idea of the present invention.
Claims (9)
1. A coding, positioning and identifying method of a two-dimensional code is characterized by comprising the following steps:
a) coding method
1) Converting the data information into data code words;
2) generating error correction code words according to a Reed-Solomon algorithm and error correction requirements;
3) placing error correction code words into the matrix according to a standard template to generate two-dimensional code symbols of the n x n matrix;
4) on the basis of the two-dimensional code symbol of the n x n matrix, adding a column of all 0 or all 1 values on the left side of each column of the matrix, and converting the n x n matrix into an n x 2n matrix;
two) two-dimension code area positioning method
1) Determining the position of the corner by using a Harris corner detection algorithm;
2) extracting a straight line from the corner by a Hough transformation method;
three) two-dimensional code area identification method
1) Using a two-dimensional Gaussian convolution operator for image I (x, y) by block sizePerforming convolution;
2) performing binarization calculation on the convolved image by using an OTSU algorithm to obtain a binarization matrix;
3) and taking out the second column of the obtained binary matrix from the initial column, then taking out the value of the next column at intervals, sequentially placing the taken-out columns in a new matrix column, converting the n x 2n matrix to obtain the n x n new matrix which is the two-dimensional code matrix, and decoding the two-dimensional code matrix by using a decoding algorithm to obtain code word information.
2. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the first step) converts the data information into data code words according to ASCII basic coding rules.
3. The two-dimensional code encoding, positioning and identifying method according to claim 2, wherein: the ASCII basic encoding rule is as follows:
1) basic ASCII characters, namely characters with ASCII values of 0-127, adding 1 to the original value when encoding data, and the encoded code word value is 1-128;
2) the extended ASCII characters, i.e., the characters with ASCII value 128-255, are encoded into two values using the control character 235, the first is to add the switching codeword 235 to the codeword stream, and the second is to subtract 128 from the original ASCII value and add 1 to obtain the result;
3) two digits 00-99, or more than two digits connected, using 130-299 coding, i.e. adding 130 to the actual value of two digits, the coded codeword value is 130-229;
4) in the actual encoding process, when the encoded code words cannot completely occupy the number of the code words, padding characters are added after the code words are encoded; the first pad character is encoded to obtain a code word of 129, and the subsequent pad characters are encoded to obtain a result of adding a pseudo-random number to the code word based on 129.
4. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the error correction requirement of 2) in the step one) is as follows:
i) establishing a codeword polynomial C (X)
C(X)=Cn-1Xn-1+k+Cn-2Xn-2+k+…+C1X1+k+C0Xk;
Wherein, Cn-1,Cn-2,…,C1,C0Is a data codeword, Cn-1Is the first data codeword, C0Is the last data codeword, k is the number of error correction codewords;
ii) establishing an error correction codeword generator polynomial G (x)
G(X)=Xk+Gk-1Xk-1+…+G1X+G0
All operations in the above formula are based on Galois fields;
iii) using C (X) and G (x) to obtain error correction code polynomial E (X)
E(X)=Ek-1Xk-1+Ek-2Xk-2+…+E1X+E0
Ek-1,Ek-2,…,E1,E0For error correcting code words, Ek-1Is the first error correction codeword, E0Is the last error correction codeword; the calculation method of E (X) is also based on Galois field.
5. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the method 3) in the step one) comprises the following steps:
the final generated code word stream is Cn-1,Cn-2,…,C1,C0,Ek-1,Ek-2,…,E1,E0The code word symbols are placed according to a standard template.
6. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the method in step two) comprises the following steps:
i) setting the function of an image as I (x, y), and expanding each pixel point of the image by using Taylor to approximate any direction of the neighborhood, so that the energy of each pixel point and the neighborhood thereof is as follows:
and performing linear transformation expansion and arrangement on the function to obtain:
the final result after unfolding is:
in the formula IxIs the difference in the x direction, IyIs the difference in the y direction, w (x, y) is a Gaussian function;
ii) two eigenvectors l due to the matrix M1And l2Proportional to the principal curvature of the matrix M; wherein l1And l2Is a matrixProjecting base vectors of different dimensions in space; by means of1,l2To characterize the two directions of fastest and slowest change; if the two are large, the two are angular points, one is large and the other is small, the two are small, and the two are in image areas with slow change; however, the solution of the eigenvector needs more calculation amount, and the product of the two eigenvalues is equal to the determinant of the matrix M as the sum of the two eigenvalues is equal to the trace of the matrix M;
the energy at the corner point is determined by the following equation:
R=detM-k(traceM)2(ii) a Wherein k is 0.04-0.06;
7. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the method in step 2) comprises the following steps:
extracting straight lines from the detected corner points by using a Hough transformation method to obtain positioning information of the two-dimensional code area;
the linear equation of a straight line in the rectangular coordinate system is:
y=k*x+b
since the straight line in the rectangular coordinate system becomes a sine curve in the polar coordinate system, the equation for converting the straight line into the polar coordinate system is as follows:
p=x*cos(a)+y*sin(a)
in the above formula, a is an included angle between a ray led out from an origin and the positive direction of an x axis under a polar coordinate system, and p is the length of a perpendicular line led out from the origin; after detecting angular points in the image, a sinusoidal curve of the angular point has a common intersection point in a polar coordinate through Hough transformation; the calculation process of the Hough transformation algorithm is as follows:
(1) mapping each point of the image space to a group of accumulators in the Hough space according to an equation of a rectangular coordinate system;
(2) each common intersection that satisfies the above equation will add 1 to the value in the corresponding accumulator;
(3) detecting a local maximum in the accumulator;
if the image contains a straight line, a corresponding accumulator can generate a local maximum value, a pair of parameters corresponding to the straight line can be determined by detecting the local maximum value in the Hough space, and the straight line extracted from the public parameters is the edge position in the two-dimensional code region, so that the two-dimensional code region is extracted by performing straight line detection on the detected corner through Hough transformation.
8. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the method in step three) comprises the following steps:
using a two-dimensional Gaussian convolution operator for image I (x, y) by block sizePerforming convolution by the process of being in a regionCarrying out weighted summation on the regions corresponding to the internal Gaussian operators and the image, and outputting a resultA matrix of (a), the value of each pixel in the matrix representing a gaussian weighting value for each block;
wherein the gaussian operator is:
assuming that the convolved image is G (x, y), then:
9. The encoding, positioning and identifying method of two-dimensional code according to claim 1, characterized in that: the method in step three) 2) comprises the following steps:
if the value range of the pixels in the region is (min-max), the total number of the pixels in the region is N, and the optimal threshold for binarizing the region is T, T ∈ (min-max), then when the threshold is Ti:
1) if the number of pixels with the gray scale value larger than Ti in the region is sum1, and the sum of the pixels is max1, the average gray scale value is:the weight is:
2) the number of pixels with the gray scale value smaller than Ti in the region is sum2, the sum of the pixels is max2, and the average value of the gray scales is:the weight is:
3) the overall gray level mean value of the region is obtained as follows: avg3 ═ w1 ═ avg1+ w2 ═ avg 2;
thus, the two-part sum of variance is obtained as: plus ═ w1 ═ w (avg1-avg3) ^2) + w2 ^ w ((avg2-avg3) ^ 2);
4) and traversing all Ti, and taking the threshold value of the maximum variance value as a threshold value for binarizing the area.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710393558.4A CN107247985B (en) | 2017-05-27 | 2017-05-27 | Coding, positioning and identifying method of two-dimensional code |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710393558.4A CN107247985B (en) | 2017-05-27 | 2017-05-27 | Coding, positioning and identifying method of two-dimensional code |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107247985A CN107247985A (en) | 2017-10-13 |
CN107247985B true CN107247985B (en) | 2020-07-17 |
Family
ID=60018827
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710393558.4A Active CN107247985B (en) | 2017-05-27 | 2017-05-27 | Coding, positioning and identifying method of two-dimensional code |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107247985B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109271826A (en) * | 2018-09-29 | 2019-01-25 | 连尚(新昌)网络科技有限公司 | The method and apparatus of two dimensional code for identification |
CN110018633B (en) * | 2018-12-14 | 2020-08-18 | 华南理工大学 | A two-dimensional coding design method for AGV positioning and navigation |
CN110275132B (en) * | 2019-06-18 | 2023-03-28 | 西京学院 | Indoor positioning method based on two-dimensional code mapping |
CN111325835B (en) * | 2020-03-31 | 2025-02-18 | 浙江正雅齿科股份有限公司 | Dental jaw model preparation system and method, shell-shaped dental appliance preparation method |
CN112149776B (en) * | 2020-09-30 | 2024-06-21 | 北京小龙潜行科技有限公司 | Visual tag and assembly thereof |
CN114919180B (en) * | 2022-05-19 | 2023-11-10 | 苏州博思美医疗科技有限公司 | Dental model processing method, system and storage medium based on DM code information storage |
CN115195126B (en) * | 2022-07-06 | 2023-02-24 | 中国科学院空间应用工程与技术中心 | Two-dimensional matching method, device, electronic equipment and medium for 3D printed objects |
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 |
CN105550881A (en) * | 2015-12-08 | 2016-05-04 | 浙江大学 | Remote dynamic three-dimensional code generation and authentication method based on two-dimensional code |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9400910B2 (en) * | 2014-02-18 | 2016-07-26 | Adobe Systems Incorporated | Method and apparatus for storing and retrieving data embedded into the surface of a 3D printed object |
-
2017
- 2017-05-27 CN CN201710393558.4A patent/CN107247985B/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 |
CN105550881A (en) * | 2015-12-08 | 2016-05-04 | 浙江大学 | Remote dynamic three-dimensional code generation and authentication method based on two-dimensional code |
Non-Patent Citations (1)
Title |
---|
二维条码Data Matrix的编码和自动识别;杨硕;《中国优秀硕士学位论文全文数据库信息科技辑》;20080915;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN107247985A (en) | 2017-10-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107247985B (en) | Coding, positioning and identifying method of two-dimensional code | |
EP2393035B1 (en) | QR barcode decoding chip and decoding method thereof | |
US8550351B2 (en) | Matrix type two-dimensional barcode decoding chip and decoding method thereof | |
US8733649B2 (en) | Data matrix decoding chip and decoding method thereof | |
KR100414524B1 (en) | Two-dimensional Code having superior decoding property which is possible to control the level of error correcting codes, and method for encoding and decoding the same | |
CN104899630B (en) | The coding/decoding method of colored QR codes | |
CN108073966B (en) | A kind of conversion method of two-dimensional code and hole array code | |
CN105989317B (en) | A two-dimensional code identification method and device | |
CN107545289A (en) | The coding method of matrix two-dimensional code and coding/decoding method | |
CN111046996B (en) | Color QR code generation and identification method | |
JP4410231B2 (en) | Image code generating apparatus and method, and image code decoding apparatus and method | |
CN112187284B (en) | Coding method, coding pattern, coding pattern reading method and shooting device | |
Victor | Enhancing the data capacity of QR codes by compressing the data before generation | |
BR112013011946B1 (en) | METHOD FOR IDENTIFYING A BIDIMENSIONAL BAR CODE IN DIGITAL BAR CODE IMAGE DATA, CONFIGURED APPARATUS TO IDENTIFY A BIDIMENSIONAL BAR CODE IN DIGITAL BAR CODE DIGITAL DATA AND MEDIA LEGIBLE BY NON-TRANSITIONAL COMPUTER | |
BR112013011943B1 (en) | method for identifying a two-dimensional bar code in digital image data of the bar code, non-transitory computer readable medium and apparatus configured to identify a two-dimensional bar code in digital image data of the bar code | |
JP6856956B2 (en) | How to detect and recognize long-range high-density visual markers | |
CN114021596A (en) | Bar code identification method and device based on deep learning | |
CN114298078A (en) | Decoding method for stained one-dimensional bar code | |
US20060289661A1 (en) | Bi-directional readable two-dimensional bar code system and its reading method | |
CN109934036B (en) | Method and system for recognizing and reading QR (quick response) code through single-position detection graph | |
CN109635613B (en) | Two-dimensional code generation method, system and device for sphere surface | |
Rathod et al. | Detecting and decoding algorithm for 2D barcode | |
CN111191759A (en) | Two-dimensional code generation method and positioning and decoding method based on GPU | |
Kumar et al. | Efficient Utilization of 2D Barcode (QR Code) in Boarding Pass for Managing Luggage at Air Port | |
CN110046688B (en) | Bar code positioning and identifying method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address |
Address after: 314006 Building 2, 3556 Linggongtang Road, Daqiao Town, Nanhu District, Jiaxing City, Zhejiang Province Patentee after: Zhejiang Zhengya Dental Co.,Ltd. Address before: 314006 north area, 4th floor, 239 Asia Pacific Road, Nanhu District, Jiaxing City, Zhejiang Province Patentee before: ZHEJIANG YINCHILI MEDICAL TECHNOLOGY Co.,Ltd. |
|
CP03 | Change of name, title or address |