Atitit Java two-dimensional code recognition image recognition

Source: Internet
Author: User

Atitit Java two-dimensional code recognition image recognition



1.1. decoding 1
1.2. first, Let's talk about the QR code a total of 40 sizes. The official name is version Versions. 1
1.3. Sample two-d Code: 2
1.4. Positioning Pattern 2
1.5. Data Encoding 3
1.6. error correction capacity L level 7% Loadline can be corrected m level 15% loadline can be corrected Q level 25% Loadline can be corrected H level 30% Loadline can be modified 3
1.7. How does QR code add error correction codes to data codes? 3
1.8. Draw two-dimensional code Figure 4
1.9. Brief coding process: Data analysis: determine the encoded character type, convert to the symbol character according to the corresponding character set, select the error correction level, 7
1.10. QR length capacity 7




1.1. decoding
Code Lib:Qrcode_swetake.jar (official WEBSITE--HTTP://WWW.SWETAKE.COM/QR/INDEX-E.HTML)
Decoding Lib:qrcode.jar (official website--http://sourceforge.jp/projects/qrcode/)




1.2. first, Let's talk about the QR code a total of 40 sizes. The official name is version Versions.
Version 1 is a matrix of x 21, version 2 is a matrix of x 25, version 3 is the size of 29, each add a Version, will increase the size of 4, the formula Is: (V-1) + (V is the version number) highest version 40, (40- 1) *4+21 = 177, so the highest is a square of 177 x 177.




/**
* @param args the command line arguments
*/
public static void main (string[] Args) {
Qrcodedecoderhandler handler = new Qrcodedecoderhandler ();
String Imgpath = "c:\\3bf33a87e950352a5936aa0a5543fbf2b2118b59.jpg";
String decodercontent = Handler.decoderqrcode (imgpath, "gbk");
System.out.println ("parse the result as follows:");
System.out.println (decodercontent);
System.out.println ("========decoder success!!!");
}
1.3. Example of two-d code:





1.4. positioning pattern
? Position Detection pattern is a positional pattern that is used to mark the rectangular size of a two-dimensional code. These three positioning patterns have white edges called separators for postion Detection Patterns. The reason three instead of four means three can be used to identify a rectangle.
? The Timing patterns is also used for positioning. The reason is that the two-dimensional code has 40 sizes, size is too large after the need for a standard line, or the scan may be swept Crooked.
? Alignment Patterns only version 2 or more (including Version2) QR code needs this stuff, also for the purpose of Positioning.


Functional data
? Format information exists in all dimensions and is used to store some formatted Data.
? Version information on >= version 7, you need to reserve two 3 x 6 zones to store some release Information.
Data code and error correction code
In addition to the above, the rest of the place contains the data code code and error Correction code error-correcting code.
1.5. Data encoding
Let's talk about data encoding First. The QR code supports the following encodings: numbers, characters, byte


1.6. error correction capacity L level 7% Loadline can be corrected m level 15% loadline can be corrected Q level 25% Loadline can be corrected H level 30% Loadline can be modified


1.7.QR is how to add error-correcting code to the data code?
First of all, we need to group the data code, that is, divided into different blocks, and then error-correcting code for each block, for how to group, we can view the QR Code Spec page 33rd to page 44 of the Table-13 to Table-22 definition Table. Note the last two columns:




1.8. Draw two-dimensional code map
Position Detection Pattern
first, The position detection pattern is drawn on three Corners.


1.8.1.1.1.Alignment Pattern
then, Draw the Alignment Pattern.


About Ali
1.8.1.1.2.Timing Pattern
Next is the line of timing pattern (this doesn't have to be said)


1.8.1.1.3.Format Information
And then there's the blue part of formation Information.


Format information is a 15 bits of information, each bit of the location as Shown: (note the Dark Module in the figure, which is always Present)


These 15 bits include:
? 5 data Bits: where 2 bits is used to indicate what error Correction level is used, and 3 bits indicates what mask to use
? 10 error-correcting Bits. Mainly through BCH code to calculate
Then 15 bits also do an XOR operation with 101010000010010. This ensures that we do not use the 00 error correction level, and the 000 mask, to re-create
1.8.1.1.4.Version Information
The next step is the blue part of version information (which requires this code after 7).


Version information is a total of 18 bits, which includes 6 bits of the version number and 12 bits of the error-correcting code, the following is an example:
Data and data error correcting codes
Then we fill in our final code, and the final code is populated as follows: from the bottom left, we fill our bits,1 with black, 0 is White. If the above Non-data area is encountered, it is bypassed or skipped.


Mask pattern
So down, our diagram is filled out, but maybe those points are not balanced, so we have to do masking operation (rely on, also not complicated) the QR spec said, QR has 8 masks you can use, as follows: each mask formula under each Diagram. The so-called mask, plainly, is and the above generated diagram do XOR Operation. Mask will only be XOR with the data area and will not affect the Ribbon.




1.9. A brief coding process: data analysis: determine the encoding of the character type, according to the corresponding character set to convert the symbol character; Select error correction level,
Under certain conditions, the higher the error correction level, the smaller the capacity of the real Data. Data encoding: converts data characters to bit streams, each 8 bits of a code word, the whole form a sequence of data code Word. Actually know this data code word sequence to know the data content of the two-dimensional code.
Data can be encoded in a pattern for more efficient decoding, for example: for data: 01234567 encoding (version 1-h), 1) grouping: 012 345 672) turn into binary: 012→0000001100 345→0101011001 67→10000113) turn into sequence: 0000001100 0101011001 10000114) number of characters into binary: 8→00000010005) add mode indicator (number) 0001:0001 0000001000 00000 01100 0101011001 1000011 for letters, chinese, japanese, and so on only the way of grouping, mode and other content is Different. The basic method is consistent
1.10.QR Length Capacity
Cn UTF8 984
Byte 2953byte
Ch 4296 Num 7089








1.11. Two-dimensional code parsing


1, positioning Graphics: First look for the detection of graphics, is the QR code of three blocks. The effect of these three blocks is that no matter in which direction scan the graphics, can be swept, do not believe that the phone can be flipped Test. The image of two-dimensional code information is determined by locating the graphics and separators on the QR Code. The positioning graph determines the coordinates of the module in the two-dimensional code symbol, and the modules in the QR Code are fixed, including correction graphics, version information, data and error correcting Codes. separator, is the detection of the image and the two-dimensional code information images Separate.


2, Grayscale Two-dimensional code information pixels: the image of the mobile phone is colored, so the two-dimensional code is also not listed outside, it is also color, except Black and white, the other color is very shallow. Grayscale refers to the color by the depth of the identification of the two-dimensional code, that is, the color of deep dark gray processing, Light-gray treatment, Remove other Colors.


3, Remove the two-dimensional code information pixel noise: the Camera's sensor in the light as the receiving signal and the output process of rough pixels, these coarse pixels are not in the photo should be the interference Factor. Noise refers to these coarse pixels.


4, binary two-dimensional code information Pixel: Two value is said to set the image of the pixel gray value to 0 or 255, that is, only two colors of black and White. The first step has been grayscale into only dark gray and light gray two colors, now binary is to turn dark gray into black, light gray to White. Why it turns black and White. Because the two-dimensional code image is actually composed of binary 0 or 1, 0 for white, 1 for Black. Two-dimensional code in the binary will be the two-dimensional code image into only black and white barcode, and then according to the analytic formula (because the pixel is 0-255, to all convert to 0 or 255, estimated after some calculation, and then 0 is 0,255 to 1) into binary Information.


5, two-dimensional code decoding and error correction: the obtained binary information decoding and error Correction. The binary information obtained is the version format information, data and error correcting code generated by a certain encoding method, so decoding is the version of the format information, data and error correction code decoding and Comparison. Error correction is performed at the same time as decoding, and the data is Corrected.






Atitit. two dimensional code function design practice Attilax summary-attilaxati-blog Park. HTML
Atitit. two-d Code Generation summary Java zxing-attilax column-blog channel-CSDN.NET.html

Java to implement QR code QRCode encoding and Decoding-memory is Summer-blog channel-CSDN.NET.html
Two-dimensional code generation details and principles-51cto.com.html
Two-dimensional code Principle Introduction _ Baidu Experience. HTML
The generation and parsing principle of QR Code-kelindame's column-blog channel-CSDN.NET.html
Two-dimensional code working principle _ Baidu Know. html


author:: nickname: old Wow's paw (full name:: attilax Akbar Al Rapanui Attilaksachanui)
Kanji name: Etila (ayron), email:[email protected]
Reprint please indicate source: http://www.cnblogs.com/attilax/
Atiend


Atitit Java two-dimensional code recognition image recognition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.