CN107563475A - A kind of coding method of Quick Response Code and device - Google Patents
A kind of coding method of Quick Response Code and device Download PDFInfo
- Publication number
- CN107563475A CN107563475A CN201710586912.5A CN201710586912A CN107563475A CN 107563475 A CN107563475 A CN 107563475A CN 201710586912 A CN201710586912 A CN 201710586912A CN 107563475 A CN107563475 A CN 107563475A
- Authority
- CN
- China
- Prior art keywords
- code
- information
- quick response
- version information
- format
- 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.)
- Granted
Links
Abstract
The embodiment of the present invention provides coding method and the device of a kind of Quick Response Code.Methods described includes:The outer rim for carrying out position sensing is determined according to input information;Input information is handled, acquisition includes code word data sequence and the final code word sequence of error correction codeword sequence, and final code word sequence is arranged on according to preset rules to the coding region in Quick Response Code code figure;Obtain format information and version information, format version information is generated after format information and version information are merged, format version information is arranged in size identical format version information region, and the format version information deposited in each format version information region is identical;Calculating is masked to coding region, obtains mask graph;According to outer rim, coding region, format version information and mask graph, Quick Response Code code figure is obtained.Coding method provided in an embodiment of the present invention and device can strengthen Quick Response Code robustness, strengthen fouling resistance ability.
Description
Technical field
The present embodiments relate to field of computer technology, and in particular to a kind of coding method of Quick Response Code and device.
Background technology
With the constantly improve of China market economy and developing rapidly for information technology, the country is to this new technology of Quick Response Code
Demand it is growing day by day.Energetically support of the Article Numbering Center of China in former China State Bureau of Quality and Technical Supervision and national departments concerned
Under, the research to planar bar code technology deepens continuously.
Quick Response Code is also known as QR Code, QR full name Quick Response, is one super popular on mobile device in recent years
A kind of coded system, it can deposit more information than traditional Bar Code bar codes, can also represent more data types.
Fig. 1 is traditional QR code figures of the prior art, as shown in figure 1, traditional QR codes include position sensing region, form
Version information region and mask functions mould etc., wherein upper left, lower-left, three square parts of upper right are position sensing figure
Shape.And each position sensing figure be considered as being made up of 3 overlapping concentric squares (respectively 7*7 dark module,
5*5 light module and 3*3 dark module), the module width ratio of position sensing figure is 1:1:3:1:1.Therefore for QR
For code, these three position sensing figures are identified, it is possible to clearly determine the position and direction of symbol in visual field.
Secondly for format information and version information, the format information of QR codes is located at these three positions spy of Quick Response Code
The periphery of mapping shape, the wherein upper left corner include a complete format information, and lower-left and upper right include partial complementarity respectively
Format information;And version information is located at lower-left and the upper right portion of code figure respectively, wherein containing the version information of complementation respectively.
But in the identification process of Quick Response Code, if some position sensing region of Quick Response Code lacks, or by
To being stained, the identification of Quick Response Code will be influenceed, therefore, how to improve robustness, the enhancing fouling resistance ability of Quick Response Code
As urgent problem to be solved.
The content of the invention
For in the prior art the defects of, the embodiments of the invention provide a kind of coding method of Quick Response Code and device.
In a first aspect, the embodiment of the present invention provides a kind of coding method of Quick Response Code, including:
Determined to be used for the outer rim for carrying out position sensing in Quick Response Code code figure according to input information;
The input information is handled, acquisition includes code word data sequence and the final code word sequence of error correction codeword sequence
Row, and the final code word sequence is arranged on according to preset rules to the coding region in the Quick Response Code code figure;
Format information and version information are obtained, format version is generated after the format information and the version information are merged
Information, the format version information is arranged on to the size identical format version information area at three angles of the Quick Response Code code figure
In domain, and the format version information deposited in each format version information region is identical;
Calculating is masked to the coding region in the Quick Response Code code figure, obtains mask graph;
According to the outer rim, the coding region, the format version information and the mask graph, described two are obtained
Tie up code code figure.
Second aspect, the embodiment of the present invention provide a kind of code device of Quick Response Code, including:
Outer rim determining module, for being determined to be used for the outside for carrying out position sensing in Quick Response Code code figure according to input information
Frame;
Data coding module, for handling the input information, acquisition includes code word data sequence and error correcting code
The final code word sequence of word sequence, and the final code word sequence is arranged in the Quick Response Code code figure according to preset rules
Coding region;
Format version information determining module, for obtaining format information and version information, by the format information and described
Version information generates format version information after merging, and the format version information is arranged on to three angles of the Quick Response Code code figure
Size identical format version information region in, and in each format version information region deposit the format version information
It is identical;
Mask computing module, for being masked calculating to the coding region in the Quick Response Code code figure, obtain mask artwork
Shape;
It is determined that code module, for according to the outer rim, the coding region, the format version information and described covering
Mould figure, obtain the Quick Response Code code figure.
Two-dimentional code encoding method and device provided in an embodiment of the present invention, by being passed to the position sensing region of Quick Response Code
Formula version information region is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability,
Improve code figure error-correcting performance.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
There is the required accompanying drawing used in technology description to be briefly described, it should be apparent that, drawings in the following description are this hairs
Some bright embodiments, for those of ordinary skill in the art, on the premise of not paying creative work, can be with root
Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is Quick Response Code code figure structure schematic representation in the prior art;
Fig. 2 is the schematic flow sheet of two-dimentional code encoding method provided in an embodiment of the present invention;
Fig. 3 is the Quick Response Code code figure structure schematic representation that further embodiment of this invention provides;
Fig. 4 is the schematic flow sheet that Quick Response Code coding region provided in an embodiment of the present invention carries out data encoding;
Fig. 5 is the method flow schematic diagram of Error Correction of Coding provided in an embodiment of the present invention;
Fig. 6 is the structural representation of two-dimentional code encoding device provided in an embodiment of the present invention;
Fig. 7 is the schematic diagram of 8 kinds of mask graphs provided in an embodiment of the present invention.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
Part of the embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
Fig. 2 is the schematic flow sheet of two-dimentional code encoding method provided in an embodiment of the present invention, as shown in Fig. 2 methods described
Including:
S101, according to input information determine to be used to carry out the outer rim of position sensing in Quick Response Code code figure;
Fig. 3 is the structural representation for the Quick Response Code code figure that further embodiment of this invention provides, as shown in figure 3, the two dimension
Code code figure comprises at least outer rim, format version information region, correcting area, data-encoding area, positioning figure and clear area,
Wherein, the outer rim is determined according to the information of user's input, and the outer rim is to be used for position sensing, separately
Outside, the improvement of outer rim can also store more information, and improvement is made in the coding method to format version information, can also protect
Protect the code figure of Quick Response Code.
S102, the input information is handled, obtaining includes the final of code word data sequence and error correction codeword sequence
Codeword sequence, and the final code word sequence is arranged on according to preset rules to the coding region in the Quick Response Code code figure;
As shown in figure 3, the Quick Response Code code figure also includes data-encoding area, computer gets the information of user's input
Afterwards, and the input information to receiving analyzes and processes, and code word data sequence and error correction codeword sequence is obtained, by code word data
The final code word sequence of sequence and error correction code word series arrangement is arranged on the coding in the Quick Response Code code figure according to preset rules
In region.
S103, format information and version information are obtained, lattice are generated after the format information and the version information are merged
Formula version information, the format version information is arranged on to the size identical format version at three angles of the Quick Response Code code figure
In information area, and the format version information deposited in each format version information region is identical;
On the basis of above-described embodiment, the Quick Response Code code figure also includes 3 format version information regions, is located at respectively
On three angles of Quick Response Code code figure, the identical format version information of storage, the lattice in each format version information region
Formula version information is the format version information after the format information and version information merging.
S104, calculating is masked to the coding region in the Quick Response Code code figure, obtains mask graph;
In order to improve the reliability of two dimension code reading, it is desirable to balanced arrangement dark color and light module, while also
The unit bitmap of functional module is avoided the occurrence of as far as possible, and (such as the unit bitmap 1011101 of position sensing figure occur) is right
Coding region described above is masked calculating, so to be masked to Quick Response Code code figure.At following step
Reason, the purpose of mask can be met.
A. mask process is not used to functional graphic, wherein, the functional area is not include format information region, only
Including clear area, outer rim, figure and correction graph are positioned;
B. xor operation continuously is carried out (by module map to the module figure of known coding region with multiple Matrix Patterns
Shape is successively placed on each mask graph, identical value 0, different value 1)
C. each result is assessed, selects the minimum figure that wherein scores.
8 kinds of different mask graphs of two-dimentional code mask code Design.Table 1 below is that mask graph refers to and corresponding mask
The formation condition of figure.Each mask graph has 3 codes as mark.Each mask graph is by by coding region
Those meet that condition is that genuine module definition is dark and caused in (not including form, version, functional area).In such as following table
In 1 condition, the line position of module is put with i to represent, the column position of module is represented with j, wherein (i, j)=(0,0) represents
The position of code figure upper left corner unit module.
The mask graph of table 1 refers to and the formation condition of corresponding mask graph
Mask graph refers to | Condition |
000 | (i+j) mod2=0 |
001 | Imod2=0 |
010 | Jmod3=0 |
011 | (i+j) mod3=0 |
100 | ((i div 2)+(j div 3)) mod2=0 |
101 | (ij) mod2+ (ij) mod3=0 |
110 | ((ij) mod2+ (ij) mod3) mod2=0 |
111 | ((ij) mod3+ (i+j) mod2) mod2=0 |
Such as:In the Quick Response Code code figure that initial version is 1, all 8 kinds of mask graphs are as shown in fig. 7, Fig. 7 is this hair
The schematic diagram for 8 kinds of mask graphs that bright embodiment provides.
After operation is masked with each mask graph successively.The appearance of following situation each time penalize a little
Score, to assess each result, fraction is higher, and its mask graph is more unavailable.In the following table, N1To N4For not
Weight (the N of good feature institute point penalty number1=3, N2=3, N3=40, N4=10), i be close to color identical molds block number be more than 5
Number, k be ratio shared by symbol dark color module with 50% gap (step-length 5%).
The point penalty appreciation condition of table 2
Finally, the mask of symbol is used for using the minimum mask graph of point penalty.
For one and same coding region, to carry out 8 masks and calculate, 8 mask graphs be obtained, from 8 mask graphs
Select mask of the minimum mask graph of point penalty as symbol.
S105, according to the outer rim, the coding region, the format version information and the mask graph, obtain
The Quick Response Code code figure.
By above-mentioned outer rim, the coding region, the format version information and the mask graph collectively form as
Quick Response Code code figure shown in Fig. 3.
Two-dimentional code encoding method provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, it is described to be determined to be used for the outer rim for carrying out position sensing in Quick Response Code code figure according to input information, specifically
For:
The information inputted according to user, determine the line number and columns of the Quick Response Code code figure, further, it is determined that code
The outermost of figure inserts the dark module that bit stream value is all 1 for one week.
On the basis of above-described embodiment, according to user input information difference, some input information character length compared with
Long, the character length of some input information is shorter, determines the line number and columns of Quick Response Code code figure, Quick Response Code code figure is being determined
After line number and columns, the dark module that bit stream value is all 1 is inserted within one week in the outermost of code figure, is positioned and is protected to protect
Protect code figure.
Two-dimentional code encoding method provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, described that the input information is handled, acquisition includes code word data sequence and error correction codeword sequence
Final code word sequence, and the final code word sequence is arranged on according to preset rules to the code area in the Quick Response Code code figure
Domain is specially:
S201, the input information is analyzed, determine code character type;
, it is necessary to analyze input information on the basis of above-described embodiment, code character type is determined.In Quick Response Code
There are several different coding patterns in face, and this several coding mode causes different character subsets to be converted to the efficiency of sign character and become
It is high.If user does not have to specify the specific symbol version needed to use, the version that selection most matches with data should be given tacit consent to.
For main comprising numeral, letter, Chinese character these three patterns in the relevant information of the circulation of agricultural product, so this hair
Bright embodiment encodes to alphanumeric pattern and Chinese character pattern both coding modes.
S202, according to the code character type to it is described input information carry out data encoding, obtain code word data sequence;
If the information of input is alphanumeric type, according to following table, different numerical value V is given to each input
Character, V value is 0 to 44.Alphanumeric character set (digital 0-9,26 letters and 9 Te Shuzifu $%*+-. |:) in
45 characters are all corresponding with the character value in table 3 below:
The alphanumeric pattern of table 3 (0010 pattern) coding schedule
The generating process of code word is as follows under alphanumeric pattern:
The data of input are divided into one group of two character, every group is represented with the binary system of 11.By first character
Value is multiplied by 45 values plus second character, then represents obtained result with 11 bits.When input data not
When being 2 integral multiple character, the coding of last character is represented with 6 bits.
Secondly, binary number is connected, and is above adding mode indicators and character count designator.In letter
In figure pattern, the length of character count designator is divided into 9,11,13 according to the difference of selected symbol version and (see the table below 4
Standard).
Such as:Input information is ww, is found in above-mentioned alphanumeric pattern (0010 pattern) coding schedule corresponding to w
It is worth for 32, two characters are divided into one group, calculate 32*45+32=1472,11 bits are changed into by 1472:1011 1000
000, and mode indicators 0010 and character count designator 00000010 are added before obtained binary number, finally obtain
Binary sequence be 0,010 0,000 0,010 1,011 1,000 000.
The digit standard of the character count designator of table 4
Quick Response Code version | Digital alphabet pattern 0010 | Chinese character pattern 1101 |
1-9 | 9 | 8 |
10-26 | 11 | 10 |
27-40 | 13 | 12 |
If input information is Chinese character pattern, provide chinese character by two byte representations, Mei Gehan in GB2312
The character value of word is the character interior code value in GB2312.The character of input is converted to 13 binary codes in the following way
Word, binary number is then connected, and plus mode indicators (1101), Chinese character Subset Indicator and character count instruction
Symbol.Under Chinese character pattern the subset of Chinese character is represented with 4 bit designators 0001.The digit of character designator
By being defined as 8,10,12, for all Chinese character designators, mode indicators are added before the bit stream of data character
1101, Chinese character Subset Indicator 0001 and character count designator.
The step of 13 bit streams being converted into for Chinese character:
A. the byte value of Chinese character first (16 system HEX) is subtracted into A6HEX
B. a result is multiplied by 60HEX
C. the byte value of Chinese character second is subtracted into A1HEX
D., b result is added to c result
E. result is converted into 13 binary strings
Such as:Chinese character " peace and quiet ":
Character value pacifies (B0B2), quiet (BEB2).
A. the byte value of Chinese character first (16 system HEX) is subtracted into A6HEX
Peace:B0-A6=0A;
It is quiet:BE-A6=18;
B. a result is multiplied by 60HEX
0A*60=3C0;
18*60=900;
C. the byte value of Chinese character second is subtracted into A1HEX
B2-A1=11;
B2-A1=11;
D., b result is added to c result
3C0+11=3D1;
900+11=911;
E. result is converted into 13 binary strings
Peace:0 0011 1101 0001;
It is quiet:0 1001 0001 0001;
Therefore, the binary bit stream sequence finally obtained is:1101 0001 00000100 00011 1101 0001
01001 0001 0001。
Bit stream sequence is converted into code word:
A. full stop 0000 is added;
B. by bit stream sequence before, every 8 one group is divided into code word, if deficiency then adds filler;
C., it is specified that the numeric data codes of corresponding different editions and error-correction level Quick Response Code code figure in the table 7 in GB/T18284
11101100 Hes are used alternatingly in word capacity, the number of codewords divided according to input data, supplement filling code word, filling code word
00010001。
S203, according to version number set in advance and error-correction level, piecemeal is carried out to the code word data sequence, calculated every
The error correction code word of individual code word data piecemeal;
The general principle of error correcting code is that redundancy is added in information, may be occurred in storage and transmission to correct information
Mistake.New Two Dimensional code realizes Error Correction of Coding using RS error correction algorithms.
The implementation process of Error Correction of Coding is:According to version number set in advance and error-correction level, to the data of above-mentioned acquisition
Codeword sequence carries out piecemeal, for each block number according to the error correction code word for calculating the block number evidence respectively, then in code word data
Error correction code word is added below, it is as shown in table 5 below:
The error-correction level of table 5 and error correction code word account for the percentage of total code word
Error-correction level | Error correction code word accounts for the percentage (%) of total code word |
L(00) | 7 |
M(01) | 15 |
Q(10) | 25 |
H(11) | 30 |
Quick Response Code is using RS error correction algorithms on GF (256) domain, and primitive 2, the mould of byte is 100101101, code length 255.
Quick Response Code uses and is segmented error correction on GF (256) domain.It is divided into n data codeword block and n error correction according to version and error-correction level
Codeword block, after completing each piece of coding, by each block number according to being connected in turn, generate error correction codeword sequence.It is error correction code word below
Generation.
A. algorithmic derivation:
Receive code word (n+k):Code word data sequence (dn-1, dn-2..., d1, d0)+error correction codeword sequence (ck-1,
ck-2..., c1, c0)
It is expressed as:Rn+k-1, Rn+k-2..., Rk-1, Rk-2..., R1, R0;
Receiverd polynomial:R (x)=R0+R1*x+R2*x2+...+Rn+k-1*xn+k-1;
Code word data (n):d0, d1, d2..., dn-1;
Data polynomial:D (x)=d0+d1*x+d2*x2+...+dn-1*xn-1;
Error correction code word (k):ck-1, ck-2..., c1, c0;
Error correction code polynomial:C (x)=c0+c1*x+c2*x2+...+ck-1*xk-1;
Generator polynomial:G (x)=(x-a) (x-a2)...(x-ak), a is GF primitive;
Business's multinomial:q(x);
Poor multinomial:e(x);
According to RS algorithm principles, c (x) need to be constructed so that e (x)=0;
R (x)=g (x) q (x)+e (x) wherein e (x)=0;
R (x)=g (x) * q (x);
R (x)=d (x) * xk+c(x);
d(x)*xk+ c (x)=g (x) * q (x);
B. method for solving
Because g (x) zero point is a, a2..., ak;
Thus d (ai)*xik=-c (ai);I=1,2 ..., k:
Export
Afterwards Gaussian elimination or polynomial division can be used to solve c0,c1,c2,...,ck-1。
C. solution procedure:
Fig. 5 is the method flow schematic diagram of Error Correction of Coding provided in an embodiment of the present invention, as shown in Figure 5:
C is solved using polynomial division method0, c1, c2..., ck-1;
Code word data d (x) coefficients:d0, d1, d2..., dn-1;
The first step:Generator polynomial is deployed:G (x)=xk+g1*xk-1+...+gk-1*x+gk;
Second step:If temporary variable t=0;c0=1;
3rd step:From i=0~n-1 systemic circulations (code word data circulation)
4th step:T=di*c0;
5th step:From j=0~k-1 partial circulatings (circulation of error correction code word)
6th step:cj=cj+1+t*gj;
7th step:Finally obtain c0,c1,c2,...,ck-1It is error correction code word, is entangled corresponding to as each code word data piecemeal
Error code word.
S204, by the code word data sequence and the error correction code word series arrangement, obtain the ultimate sequence of code word;
Obtained code word data sequence and error correction codeword sequence are arranged, each piece of code word data sequence is drained
Afterwards, error correction codeword sequence corresponding with digital word is being arranged, is obtaining the ultimate sequence of code word.
It is S205, the code word data sequence and the error correction codeword sequence is described according to being subsequently placed at from right to left
The coding region of Quick Response Code code figure.
Whole code word ultimate sequence is considered as a single bit stream, by its since highest order according to from right to left, to
The direction of upper (or downward) is alternately arranged in two wide sequences of module, and the region that skip functions figure takes.Two
In the wide file of individual module, bit stream is alternately arranged, now to avoid functional graphic region.The cardinality of two-dimensional code symbol leads to
It is often the error correction block that can just fill up included data block, but then needs to add residue to information in a small number of versions
Position, to ensure just fill up the number of modules of coding region in final data message bit stream.
And when bit stream last bit word data capacity less than 8 when, with remaining bit filling symbol 0 come
Supply.
Two-dimentional code encoding method provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, it is described by the code word data sequence and the error correction codeword sequence according to being subsequently placed at from right to left
The coding region of the Quick Response Code code figure, it is specially:
By the code word data sequence according to the number for being subsequently placed at the Quick Response Code code graph code region from right to left
According in code word region, by the error correction codeword sequence according to from right to left be subsequently placed at the Quick Response Code code graph code region
Error correcting code block domain in.
Specifically, on the basis of above-described embodiment, the code word data sequence is pressed from right to left, up or down
Order is put into the code word data region in Quick Response Code code graph code region, and the error correction codeword sequence is suitable according to from right to left
Sequence is put into the error correcting code block domain in the Quick Response Code code graph code region, if in code word data region and error correcting code block domain
Have vacant position and do not pile, then with remaining bit polishing.
Two-dimentional code encoding method provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, the format version information of the Quick Response Code includes 18 version informations and 18 bit format information, wherein, institute
Stating version information includes 6 edition datas and 12 error correction bits, the format information include error-correction level, mask graph reference and
12 error correction bits.
On the basis of above-described embodiment, the format version information region be two independent regions are passed through it is new
Coding method is combined into 6*6 module, and inserts the region of three formed objects of yard figure, i.e., each angle has a complete
Form and version information.It is as follows that the format version information includes content:Include line number, columns, version information, error-correction level
And mask version, the information that the format version information in the embodiment of the present invention is 36, wherein:
Format information is 18, wherein there is 6 to be used for representing data, 12 are used to indicate that BCH (18,6) codings produce
Error correction bit.The error-correction level of data information area is represented with first, second and third data bit.And the content of the 4th to the 6th
Referred to for mask graph, calculate 12 error correction datas, and error correction data is added after 6 data bit.
Version information is 18, wherein having 6 to represent data, 12 error correction bits are to encode to produce by BCH (18,6)
's.Wherein version information is represented with 6 data, and first is highest order, and the error correction for being followed by 12 of 6 data bit is believed
Breath.
Two-dimentional code encoding method provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, the acquisition format information and version information, after the format information and the version information are merged
Format version information is generated, the format version information is arranged on to the size identical lattice at three angles of the Quick Response Code code figure
In formula version information region, and the format version information deposited in each format version information region is identical, is specially:
After 18 version informations and 18 bit format information are merged, described two are filled into according to certain preset order
In the size identical format version information region for tieing up three angles of code code figure, and deposited in each format version information region
Format version information is identical.
On the basis of above-described embodiment, after 18 version informations and 18 bit format information are merged, by 36 letters
Breath data insert format information region according to the order of table 6 below:
The structure chart in the format version information region of table 6
0 | 1 | 16 | 17 | 4 | 5 |
2 | 3 | 18 | 19 | 6 | 7 |
28 | 29 | 32 | 33 | 20 | 21 |
30 | 31 | 34 | 35 | 22 | 23 |
12 | 13 | 24 | 25 | 8 | 9 |
14 | 15 | 26 | 27 | 10 | 11 |
Two-dimentional code encoding method provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Fig. 4 is the structural representation of two-dimentional code encoding device provided in an embodiment of the present invention, as shown in figure 4, described device
Including outer rim determining module 10, data coding module 20, format version information determining module 30, mask computing module 40 and really
Determine code module 50, wherein:
Outer rim determining module 10 is used to determine to be used to carry out the outer of position sensing in Quick Response Code code figure according to input information
Frame;
Data coding module 20 is used to handle the input information, and acquisition includes code word data sequence and error correcting code
The final code word sequence of word sequence, and the final code word sequence is arranged in the Quick Response Code code figure according to preset rules
Coding region;
Format version information determining module 30 is used to obtain format information and version information, by the format information and described
Version information generates format version information after merging, and the format version information is arranged on to three angles of the Quick Response Code code figure
Size identical format version information region in, and in each format version information region deposit the format version information
It is identical;
Mask computing module 40 is used to be masked calculating to the coding region in the Quick Response Code code figure, obtains mask artwork
Shape;
It is determined that code module 50 is used for according to the outer rim, the coding region, the format version information and described
Mask graph, obtain the Quick Response Code code figure.
On the basis of above-described embodiment, after user inputs an information, outer rim determining module 10 is believed according to input
Breath determines to be used for the outer rim for carrying out position sensing in Quick Response Code code figure;Data coding module 20 is inputted at information to described
Reason, acquisition include code word data sequence and the final code word sequence of error correction codeword sequence, and by the final code word sequence according to
Preset rules are arranged on the coding region in the Quick Response Code code figure;Format version information determining module 30 is believed by obtaining form
Breath and version information, format version information is generated after the format information and the version information are merged, by the form version
This information is arranged in the size identical format version information region at three angles of the Quick Response Code code figure, and each form version
The format version information of storage is identical in this information area;Mask computing module 40 is to the coding in the Quick Response Code code figure
Region is masked calculating, obtains mask graph;It is determined that code module 50 is according to the outer rim obtained above, the coding
Region, the format version information and the mask graph, obtain the Quick Response Code code figure.
Device provided in an embodiment of the present invention, suitable for methods described above, its function specifically can refer to the above method
Embodiment, here is omitted.
Two-dimentional code encoding device provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, the outer rim determining module is specially:The information inputted according to user, determines the Quick Response Code code figure
Line number and columns, further, it is determined that the outermost of code figure insert within one week the dark module that bit stream value is all 1.
On the basis of above-described embodiment, according to user input information difference, some input information character length compared with
Long, the character length of some input information is shorter, and to determine the line number and columns of Quick Response Code code figure, Quick Response Code code figure is being determined
Line number and columns after, insert within one week the dark module that bit stream value is all 1 in the outermost of code figure, in order to protect carry out positioning and
Protected code figure.
Two-dimentional code encoding device provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, the format version information of the Quick Response Code includes 18 version informations and 18 bit format information, wherein, institute
Stating version information includes 6 edition datas and 12 error correction bits, the format information include error-correction level, mask graph reference and
12 error correction bits.
On the basis of above-described embodiment, the format version information region be two independent regions are passed through it is new
Coding method is combined into 6*6 module, and inserts the region of three formed objects of yard figure, i.e., each angle has a complete
Form and version information.It is as follows that the format version information includes content:Include line number, columns, version information, error-correction level
And mask version, the information that the format version information in the embodiment of the present invention is 36, wherein:
Format information is 18, wherein there is 6 to be used for representing data, 12 are used to indicate that BCH (18,6) codings produce
Error correction bit.The error-correction level of data information area is represented with first, second and third data bit.And the content of the 4th to the 6th
Referred to for mask graph, calculate 12 error correction datas, and error correction data is added after 6 data bit.
Version information is 18, wherein having 6 to represent data, 12 error correction bits are to encode to produce by BCH (18,6)
's.Wherein version information is represented with 6 data, and first is highest order.The error correction for being followed by 12 letter of 6 data bit
Breath.
Two-dimentional code encoding device provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Alternatively, the format version information determining module, it is specially:18 version informations and 18 bit formats are believed
In the size identical format information region for ceasing three angles that the Quick Response Code code figure is filled into according to certain preset order, and
The format version information placed in each format information region is identical.
On the basis of above-described embodiment, after 18 version informations and 18 bit format information are merged, by 36 letters
Breath data insert format information region according to the order of table 6.
Two-dimentional code encoding device provided in an embodiment of the present invention, by the position sensing region of Quick Response Code and format version
Information area is improved, and realizes the space for saving domain, strengthens Quick Response Code robustness, strengthens fouling resistance ability, improves code
Figure error-correcting performance.
Device and system embodiment described above is only schematical, wherein described be used as separating component explanation
Unit can be or may not be physically separate, can be as the part that unit is shown or may not be
Physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to the actual needs
Some or all of module therein is selected to realize the purpose of this embodiment scheme.Those of ordinary skill in the art are not paying
In the case of performing creative labour, you can to understand and implement.
Claims (10)
- A kind of 1. coding method of Quick Response Code, it is characterised in that including:Determined to be used for the outer rim for carrying out position sensing in Quick Response Code code figure according to input information;The input information is handled, acquisition includes code word data sequence and the final code word sequence of error correction codeword sequence, And the final code word sequence is arranged on according to preset rules to the coding region in the Quick Response Code code figure;Format information and version information are obtained, format version letter is generated after the format information and the version information are merged Breath, the format version information is arranged on to the size identical format version information region at three angles of the Quick Response Code code figure It is interior, and the format version information deposited in each format version information region is identical;Calculating is masked to the coding region in the Quick Response Code code figure, obtains mask graph;According to the outer rim, the coding region, the format version information and the mask graph, the Quick Response Code is obtained Code figure.
- 2. according to the method for claim 1, it is characterised in that described to determine to be used in Quick Response Code code figure according to input information The outer rim of position sensing is carried out, is specially:The information inputted according to user, determine the line number and columns of the Quick Response Code code figure, further, it is determined that code figure Outermost inserts the dark module that bit stream value is all 1 for one week.
- 3. according to the method for claim 1, it is characterised in that it is described that the input information is handled, including The final code word sequence of code word data sequence and error correction codeword sequence, and the final code word sequence is set according to preset rules Coding region in the Quick Response Code code figure is specially:The input information is analyzed, determines code character type;Data encoding is carried out to the input information according to the code character type, obtains code word data sequence;According to version number set in advance and error-correction level, piecemeal is carried out to the code word data sequence, calculates each numeric data code The error correction code word of word piecemeal;By the code word data sequence and the error correction code word series arrangement, the ultimate sequence of code word is obtained;By the code word data sequence and the error correction codeword sequence according to from right to left be subsequently placed at the Quick Response Code code The coding region of figure.
- 4. according to the method for claim 3, it is characterised in that described by the code word data sequence and the error correction code word Sequence is specially according to the coding region for being subsequently placed at the Quick Response Code code figure from right to left:By the code word data sequence according to the numeric data code for being subsequently placed at the Quick Response Code code graph code region from right to left In the domain of block, by the error correction codeword sequence according to from right to left be subsequently placed at entangling for the Quick Response Code code graph code region In the domain of error code block.
- 5. according to the method for claim 1, it is characterised in that the format version information of the Quick Response Code includes 18 versions Information and 18 bit format information, wherein, the version information includes 6 edition datas and 12 error correction bits, the format information Including error-correction level, mask graph reference and 12 error correction bits.
- 6. according to the method for claim 5, it is characterised in that the acquisition format information and version information, by the lattice Formula information and the version information generate format version information after merging, and the format version information is arranged on into the Quick Response Code In the size identical format version information region at three angles of code figure, and deposited in each format version information region described Format version information is identical, is specially:After 18 version informations and 18 bit format information are merged, the Quick Response Code is filled into according to certain preset order In the size identical format version information region at three angles of code figure, and the form deposited in each format version information region Version information is identical.
- A kind of 7. code device of Quick Response Code, it is characterised in that including:Outer rim determining module, for being determined to be used for the outer rim for carrying out position sensing in Quick Response Code code figure according to input information;Data coding module, for handling the input information, acquisition includes code word data sequence and error correction code word sequence The final code word sequence of row, and the final code word sequence is arranged on according to preset rules to the coding in the Quick Response Code code figure Region;Format version information determining module, for obtaining format information and version information, by the format information and the version Information merge after generate format version information, the format version information is arranged on the Quick Response Code code figure three angles it is big In small identical format version information region, and the format version information phase deposited in each format version information region Together;Mask computing module, for being masked calculating to the coding region in the Quick Response Code code figure, obtain mask graph;It is determined that code module, for according to the outer rim, the coding region, the format version information and the mask artwork Shape, obtain the Quick Response Code code figure.
- 8. device according to claim 7, it is characterised in that the outer rim determining module is specially:The information inputted according to user, determine the line number and columns of the Quick Response Code code figure, further, it is determined that code figure Outermost inserts the dark module that bit stream value is all 1 for one week.
- 9. device according to claim 7, it is characterised in that the format version information of the Quick Response Code includes 18 versions Information and 18 bit format information, wherein, the version information includes 6 edition datas and 12 error correction bits, the format information Including error-correction level, mask graph reference and 12 error correction bits.
- 10. device according to claim 9, it is characterised in that the format version information determining module, be specially:18 version informations and 18 bit format information are filled into the Quick Response Code code figure according to certain preset order In the size identical format information region at three angles, and the format version information placed in each format information region is identical.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710586912.5A CN107563475B (en) | 2017-07-18 | 2017-07-18 | Two-dimensional code encoding method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710586912.5A CN107563475B (en) | 2017-07-18 | 2017-07-18 | Two-dimensional code encoding method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107563475A true CN107563475A (en) | 2018-01-09 |
CN107563475B CN107563475B (en) | 2020-04-28 |
Family
ID=60973622
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710586912.5A Expired - Fee Related CN107563475B (en) | 2017-07-18 | 2017-07-18 | Two-dimensional code encoding method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107563475B (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108734048A (en) * | 2018-05-29 | 2018-11-02 | 西安理工大学 | Various dimensions Quick Response Code based on proprietary code generates and interpretation method |
CN110889304A (en) * | 2018-09-11 | 2020-03-17 | 杭州海康威视数字技术股份有限公司 | Two-dimensional code quality evaluation method and device, storage medium, electronic device and system |
CN111079455A (en) * | 2019-11-01 | 2020-04-28 | 西安科成新果信息科技有限公司 | Automatic generation, verification and detection integrated equipment based on two-dimensional code |
CN112561016A (en) * | 2020-12-23 | 2021-03-26 | 杭州天谷信息科技有限公司 | Two-dimensional code generation method and system and document anti-counterfeiting method and system |
CN113557530A (en) * | 2019-03-12 | 2021-10-26 | 微软技术许可有限责任公司 | Hybrid two-dimensional barcode and hybrid two-dimensional barcode generator |
CN116320200A (en) * | 2023-05-23 | 2023-06-23 | 南京龟兔赛跑软件研究院有限公司 | Multi-point fusion anti-cracking encryption method applied to 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 |
CN104361308A (en) * | 2014-11-24 | 2015-02-18 | 天津理工大学 | STM32-based handheld two-dimension code recognizer |
-
2017
- 2017-07-18 CN CN201710586912.5A patent/CN107563475B/en not_active Expired - Fee Related
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 |
CN104361308A (en) * | 2014-11-24 | 2015-02-18 | 天津理工大学 | STM32-based handheld two-dimension code recognizer |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108734048A (en) * | 2018-05-29 | 2018-11-02 | 西安理工大学 | Various dimensions Quick Response Code based on proprietary code generates and interpretation method |
CN110889304A (en) * | 2018-09-11 | 2020-03-17 | 杭州海康威视数字技术股份有限公司 | Two-dimensional code quality evaluation method and device, storage medium, electronic device and system |
CN110889304B (en) * | 2018-09-11 | 2023-04-28 | 杭州海康威视数字技术股份有限公司 | Two-dimensional code quality evaluation method and device, storage medium, electronic equipment and system |
CN113557530A (en) * | 2019-03-12 | 2021-10-26 | 微软技术许可有限责任公司 | Hybrid two-dimensional barcode and hybrid two-dimensional barcode generator |
CN111079455A (en) * | 2019-11-01 | 2020-04-28 | 西安科成新果信息科技有限公司 | Automatic generation, verification and detection integrated equipment based on two-dimensional code |
CN112561016A (en) * | 2020-12-23 | 2021-03-26 | 杭州天谷信息科技有限公司 | Two-dimensional code generation method and system and document anti-counterfeiting method and system |
CN116320200A (en) * | 2023-05-23 | 2023-06-23 | 南京龟兔赛跑软件研究院有限公司 | Multi-point fusion anti-cracking encryption method applied to two-dimensional code |
CN116320200B (en) * | 2023-05-23 | 2023-08-11 | 南京龟兔赛跑软件研究院有限公司 | Multi-point fusion anti-cracking encryption method applied to two-dimensional code |
Also Published As
Publication number | Publication date |
---|---|
CN107563475B (en) | 2020-04-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107563475A (en) | A kind of coding method of Quick Response Code and device | |
CN105574572B (en) | A kind of generation method of color 2 D code | |
CN104899630B (en) | The coding/decoding method of colored QR codes | |
CN102999772B (en) | A kind of decoding method of novel matrix formula Quick Response Code | |
CN107545289A (en) | The coding method of matrix two-dimensional code and coding/decoding method | |
CN104143109A (en) | Two-dimensional code coding method, two-dimensional code decoding method and two-dimensional code print | |
CN100481117C (en) | A two dimensional bar code coding-decoding method | |
CN104636780B (en) | Matrix two-dimensional code and its coding method and interpretation method | |
CN101515335A (en) | Color two dimension bar code with high compression ratio Chinese character coding capability and its coding and decoding method | |
CN101197004A (en) | Two-dimension bar code and its coding and decoding method | |
CN101093553A (en) | 2D code system, and identification method | |
CN105989389A (en) | Two-dimensional code | |
CN102999773A (en) | Colorful lattice point code picture and three-dimensional bar code coding method thereof | |
CN106845593A (en) | A kind of rectangle fixes dot matrix information encoding-decoding method | |
CN107563477A (en) | Quick Response Code and its generation method and device | |
CN107247985A (en) | Coding, positioning and the recognition methods of New Two Dimensional code | |
CN106022425A (en) | Layered-structure 2D code encoding and decoding method | |
CN109886711A (en) | A kind of bar code coding method and device | |
CN110991589A (en) | Two-dimensional code and encryption method thereof | |
CN108734048A (en) | Various dimensions Quick Response Code based on proprietary code generates and interpretation method | |
CN101303742B (en) | Microminiature Hanxin code and method for generating symbol thereof | |
CN107370555A (en) | Error decision method and its device | |
CN111738389B (en) | Two-dimensional code generation method and generation system | |
JP2024505116A (en) | Dot matrix code construction method, generation and reading method, terminal, and dot matrix code system | |
CN100504912C (en) | Two dimensional bar code symbol generation 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 | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20200428 Termination date: 20200718 |