QR Code is a special barcode that encodes information such as numbers, letters, and Chinese characters. This article will provide guidance to programmers who want to learn about QR coding. QR code coding is a complex process, especially the generation of error-correcting code this step. This article attempts to introduce the entire encoding process as simply and concisely as possible. This article will assume that the reader has basic coding capabilities.
The QR code was invented in 1994 by Japanese company Denso-wave, a subsidiary of Toyota that manufactures automation components. The QR code standards are now codified in ISO/IEC 18,004:2006 and are not authorized to use.
The minimum size of the QR code is 21x21 pixels and the maximum size is 177x177 pixels. In the QR code, these different sizes are called versions (version). The 21x21 corresponds to the verion 1,25x25 as version 2, and so on. The largest 177x177 is version 40.
The QR Code also has the error correction function: When we encode the information, we need to generate some redundant data, so that the QR scanner will still be able to decode accurately if part of the code is unreadable. Optional error correction level has 4 levels: the lowest level is the L class, the QR code with L-level error correction allows a maximum of 7% code corruption, followed by the M class, support 15% error correction, followed by the Q level, support 25% error correction, the highest level of H, support 30% error correction.
The capacity of a QR code depends on the version, the error correction level, and the type of data being encoded. QR code supports four types of data encoding: digital, Latin alphabet, binary, kanji. Denso-wave's list of QR versions provides the amount of data that each version's code can hold.
- QR Code generation overview
The QR coding process is described in detail later in this section. Here is a general overview of the encoding process, which you can browse through again before reading its detailed steps.
The QR code encodes a text string, and the QR Code standard defines four modes for encoded text: Digital encoding, character encoding, byte encoding, and Japanese encoding (also available for men). Each mode treats the text as a binary string (a sequence of 1 and 0). Each mode implements the conversion between the text and the binary string in different ways, each of which is self-optimizing and can be used to minimize the number of data encoded. Therefore, the first step should be to analyze the data to determine which type of data it belongs to and choose the best model.
After selecting the appropriate encoding mode, the next step is to encode the data. The Data Encoding section describes the process details for each encoding pattern, and the end result is that the binary string is split into words (codewords), each with a word length of 8bit.
-
- Step 3: Error-Correcting code generation
As mentioned above, the QR code contains the error correction capability, which means that after the data is converted into a binary string, it is also necessary to generate an error-correcting code for this string, which will use the Reed-solomon error correction check method.
The QR scanner scans both the data code and the error-correcting code, and compares the two to determine if the data read is correct, and if it is not correct, the wrong data can be corrected back with the error correction code. The Error Correction Check section explains the details of the error-correcting code generation process. For more details, see Wikipedia article Reed-solomon error correction.
The data code and error correction code generated in the preceding step are arranged in a certain order. For large QR codes. The code word will be organized into blocks (blocks), and these blocks shall be interwoven with the specifications of the QR code. The structured section will detail this process.
After generating the data code and error correction codes and arranging them in the correct order, these bits need to be populated into the QR code matrix. The arrangement of these bits also has a specific way. In this process, there are a number of QR code uniform formats, such as three code eyes in the three corners of the matrix, respectively. The Matrix Fill section will detail this process.
Some features of the QR code may cause the scanner to be difficult to parse correctly. To solve this problem, the standard defines 8 types of masks, each of which can be modified to look different from the QR code. When generating a QR code, we need to determine in advance which mask is most appropriate. The evaluation and selection of the mask can be based on 4 penalty rules, the final generated QR code, the penalty must be minimized. The Mask section details the process.
-
- Step 7: Format and version information
The final step is to populate the QR matrix with some formatting data and version information (if necessary), filling in a specific area of some whitespace that was not processed by the previous steps. Formatted data defines the level of error correction and the type of mask. and version information defines the size of the two-dimensional code, only in some of the larger QR code will be required. The format and version Information section details the process.
"Translate" QR Code Tutorial-Introduction