One-dimensional code (barcode)
Before introducing the two-dimensional code, let's take a look at its "big brother" one-dimensional code. One-dimensional code is also called barcode (it seems to be called this in daily life). It is composed of black bars and white bars of different widths according to certain A parallel line pattern composed of sequential arrangement, its width records data information, and its length does not record information. Barcodes are often used to mark the country of origin, manufacturer, commodity name, production date, book classification number, starting and ending location, and category of the item. , date and other information, such as most food packaging bags will have a barcode printed on the back.
One-dimensional code encoding rules
The global barcode standard is GS1
. Usually, the barcode consists of 95
red or black parallel vertical lines. The first three lines are composed of black-white-black, and the middle The five bars are composed of
white-black-white-black-white, and the last three
are also composed of 161da9d17b33e9 black-white-black like the first three bars, so a barcode is divided into two parts: left and right. The remaining 84 (95-3-5-3=84) are divided into 12 groups according to each group of 7, and each group corresponds to a number. The specific representation of different numbers is different due to the encoding method, but all It follows a rule: the number of white vertical bars in each group on the right side of
In this way, it can be recognized whether you are scanning forward or backward.
Most of the barcodes used in China are in EAN-13
format. The meaning of the barcode number code from left to right is the first three identification source country code , such as China: 690–699, the following 4 to 8 digits represent It is the company code of the manufacturer, but the number of digits is not fixed. The next 9~12 digits are the product code, and the 13th digit is the check code, which means that the shorter the company code, the more digits that can be used for the product code. The more products, the more products that can be represented. Of course, the sales price of the company code is correspondingly more expensive. In addition, the EAN-13
barcode used on the product must be applied to the National Article Code Center .
QR code
QR code is an extension of one-dimensional code. There are different types of QR code, which can be roughly divided into these two types ① Stacked/Linear QR Code ② Matrix QR Code , among which the matrix two-dimensional code is the most popular (the two-dimensional code below refers to the matrix two-dimensional code). The difference between it and the one-dimensional code is that its width and length have recorded data information, and the amount of stored data is larger. In addition to this, "Anchor Points" and "Fault Tolerance Mechanisms" have been added. Through the "locating point", the code reader can correctly identify and interpret, so the two-dimensional code can be recognized no matter what direction it is read from.
The "error-tolerant mechanism" can correctly infer and restore the original barcode information even when not all barcodes are recognized. ) is divided into four different levels: L (about 7%), M (about 15%), Q (about 25%), and H (about 30%). For example, the following " mghio " official account QR code can be correctly identified as the function of this "fault tolerance mechanism" despite the official account avatar in the middle. Whether it is a barcode (one-dimensional code) or a two-dimensional code, it is essentially an encoding of information, the difference is only in the way of encoding the information.
QR code structure
There are 40 different versions of the QR code from 1 to 40. The basic structure of each version is the same. Increments from version 1 (21 × 21 symbols) to version 40 (177 × 177 symbols).
The QR code can be divided into these different functional areas, namely version information,
format information,
data and fault tolerance,
positioning mark,
correction mark and other main areas, among which the positioning mark is used to locate the two-dimensional code. , the version information indicates the version of the two-dimensional code, there are 40 different versions of the two-dimensional code, from version 1 to version 40, each version is increased by 4 symbols on each side of the previous version, and the data and fault tolerance are used for actual storage. Two-dimensional code data information and error correction code words used to correct errors caused by damage to the two-dimensional code. The encoding rules of two-dimensional codes are relatively complex. Interested friends can go to see its encoding specifications.
Problems with ordinary QR codes
The ordinary two-dimensional code introduced above only encodes text, website, telephone and other information, and does not support content such as pictures, audio, and video, and the content cannot be changed after the two-dimensional code is generated. The two-dimensional code generated when there is a lot of information content The code pattern is complex and difficult to identify and print. It is because of these characteristics that it is called static two-dimensional code . The advantage of static QR code is that it can be recognized without connecting to the Internet. However, in some offline scenarios, it is often necessary to print a QR code for users to scan the code, or in some operational scenarios, data statistics and analysis of the user's code scanning situation are required. , these functions cannot be provided by using ordinary two-dimensional codes. At this time, the dynamic two-dimensional code should be used.
Dynamic QR code (live code) and its principle
The dynamic QR code is also called live code , the key lies in "live", "live" means that the content is variable, but the two-dimensional code remains unchanged. The advantage of live code is actually the disadvantage of static two-dimensional code. It supports to modify the content of two-dimensional code at any time and the pattern of two-dimensional code remains unchanged. It can track scanning statistics, and support to store a large amount of text, pictures, files, audio and video, video and other content. , and the pattern generated at the same time is simple and easy to scan.
In fact, the QR code is a string of strings encoded according to the specified rules. Usually, it is a URL in most cases. Before the QR code appears, we access a URL by opening the browser and entering the URL and pressing Enter. The corresponding website can be accessed, and after having the QR code, we use the software to scan the QR code. The software will first parse and convert from the QR code to the text, and then judge whether it is a link according to the parsed text result. Yes jump to this link, although the way of operation has changed for us, the principle is the same.
Since there is a URL behind the QR code, to solve the problem that the content cannot be modified after the static QR code is generated, is it necessary to make the URL "live", and then the link of the content can be manipulated, and the same is still exposed to the outside world. URL, the server only needs to make a second jump to this URL. In fact, "live code" does this. This fixed URL exposed to the outside world is also called "live address". At this time, a famous saying in the computer science community came to mind:
Any problem in computer science can be solved by adding an intermediate layer.
The "live address" above is a "middle layer" that shields and isolates changes in the QR code content, and only exposes a fixed URL to the outside world.
The difference between static QR code and dynamic QR code (live code)
comparison | Ordinary QR code | Dynamic QR code (live code) |
---|---|---|
Content modification | not support | can be modified at any time |
content type | Support text, URL, phone, etc. | Support text, pictures, files, audio and video, video and other content |
QR code pattern | More and more complex | Live code pattern is simple |
Statistics | not support | support |
style typography | not support | support |
Summarize
This article mainly barcode , static two-dimensional code and dynamic two-dimensional code who want to know more about the implementation details and principles of two-dimensional code can take a look at Uncle Mouse's This article QR code generation details and principles or go to official website view related documents. Although most people are very familiar with QR codes and scan codes almost every day, there is still a "deeply ingrained" perception in people's brains that after scanning a QR code, only one image will appear. This kind of fixed result, before I came into contact with the concept of live code The more you know, the more you don't know.
References
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。