The working principle of two-dimensional code and bar code
Qr codes were invented by a US company in the 1970s, but they have only become popular in recent years due to device constraints. But before, when we paid in supermarkets, we could always see cashiers scanning barcodes to identify items. In practice, QR codes are much older than barcodes.
Let's start with the big brother of QR codes: the bar code, the black and white bar that the cashier sweeps over time. The computer can identify the horizontal black and white bars of uneven thickness and find the product number information hidden in them. According to their width and spacing, we can encode a small amount of information in it, and then connect to the database through this small amount of information, we can find a large number of data, such as commodity information, inventory, logistics information and so on. Commonly used one-dimensional code standards include UPC,Code128,Code3/9 (commercial electron guns are free to set the required standards). And we can think of it as, this is one-dimensional code!
The biggest difference between QR code and barcode is that barcode only carries information in a horizontal dimension, while QR code carries information in both horizontal and vertical directions, which is why barcode is rectangular and QR code is square. There's another difference. While one-dimensional bar codes can only be composed of numbers and letters, two-dimensional codes can also store information such as Chinese characters and pictures. Compared with one-dimensional codes, two-dimensional codes have a wider range of applications.
So, the most critical question comes, these characters, in the end how to become this two-dimensional code pattern?
The QR code is actually a digital matrix composed of many zeros and ones. To put it simply, QR code is to translate the information you want to express into two small squares, black and white, and then fill in the big square. Somewhat similar to our middle school answer sheet, it is to translate our language into machine-recognized language, which is to translate information such as numbers, letters, Chinese characters into binary 0 and 1 through a specific code. A 0 is a small white square, and a 1 is a small black square.
After the characters are transformed into a sequence of numbers consisting only of 0s and 1s, a series of optimization algorithms (imagine a series of optimization algorithms here) is performed to obtain the final binary encoding. In the final code, a 0 corresponds to a 'white square', and a 1 corresponds to a 'black square'. We divide these squares into groups of 8 and fill them into large squares. This is a complete two-dimensional code pattern that can be recognized by mobile phones.