How does a QR code work? What do the black and white squares represent? | Digital Literacy

How does a QR code work? What do the black and white squares represent? | Digital Literacy

Audit expert: Jing Yuan, Intermediate Accountant

Driven by the wave of digitalization, QR codes have quietly penetrated into every aspect of our lives. From shopping and payment to social interaction, it plays a pivotal role. Have you ever wondered what kind of technological principle is hidden behind this QR code composed of black and white squares? Why can a mobile phone accurately scan the code from any angle? A huge amount of QR codes are generated every day around the world. Will they run out one day? Today, let's step into the world of QR codes and explore the technological secrets behind them.

Image source: Qianku.com

The origin of QR code

The origin of the QR code we are familiar with today can be traced back to the first generation of barcodes, namely one-dimensional codes, which are considered to be the early form of QR codes. In the 1950s, with the development of the economy, the Japanese invented barcodes to solve the problem of slow checkout efficiency caused by cashiers recording the sales of goods by hand.

Image source: Baidu Images

Nowadays, you can easily find it on the corners of the outer packaging of various products. The barcode uses a combination of black and white lines of different widths to store information by using the different reflection characteristics of the black and white parts when exposed to light.

Specifically, black lines absorb most of the incident light and reflect almost nothing back to the scanning device, while white lines reflect most of the incident light. The scanner emits light of a specific wavelength, and when the light shines on the barcode, the receiver detects the change in the intensity of the reflected light.

These changes are converted into corresponding electrical signals according to the arrangement order of black and white lines, and then decoded into digital or letter data containing product information. However, due to the limited length of barcodes, the information stored will soon fail to meet the needs of society.

In 1994, Japanese researcher Hirohara Teng modified the barcode and designed a dot matrix information storage color block.

Barcode and QR code | Baidu Images

He changed the original barcode that could only express information in the horizontal direction, and realized the storage and expression of information in both the horizontal and vertical directions. In this way, the amount of information in the matrix color block has been greatly increased.

After years of continuous development, a variety of QR code formats have been produced, such as Data Matrix, MaxiCode, Aztec, QR Code, PDF417, Vericode, Ultracode, Code 49, and Code 16K. Among them, QR Code has become one of the most common and widely used formats due to its significant advantages.

QR Code has the advantages of large information capacity, being able to encode various types of data, strong error correction capability, and being able to still identify even when partially damaged, high decoding reliability, and extremely low bit error rate, and data can be encrypted before encoding to improve confidentiality and anti-counterfeiting, making it widely used in various fields.

Image source: Baidu Images

How QR codes work

Simply put, a QR code is an open information storage device that can store fixed information in a small black and white square, and it can be used indefinitely. There are no strict restrictions on the device that can recognize a QR code. As long as it has the corresponding scanning function, such as a smart phone, a dedicated code reader, or even some smart cameras, it can read the information stored in it.

The working principle of QR code is actually binary algorithm. Binary is to express all language information in machine language 0 and 1. The QR code pattern is composed of a series of black and white squares, where black squares represent the binary value "1" and white squares represent "0" . These black and white patterns are combined according to specific coding rules to form a binary sequence, which is used to store various types of data.

The recognition device captures the image and analyzes the black and white contrast to parse the binary code sequence in the QR code. Then, the decoding software uses the corresponding decoding algorithm to convert the binary data into human-readable characters. These characters can include numbers, letters, special characters, Chinese characters, etc., depending on the encoding standard and encoding content adopted by the QR code.

We noticed that there are three position detection patterns (usually large squares) at the corners of each QR code, which together constitute the positioning system of the QR code. These three position detection patterns can ensure that the recognition device can quickly and accurately locate the position and direction of the QR code.

QR code positioning | Baidu images

Three points can determine a surface, which ensures that when we scan the code, no matter whether the phone is scanned horizontally, vertically or diagonally, we can correctly obtain the QR code information.

Numbers and error correction codewords | Baidu Images

In addition, the QR code also contains verification mechanisms, such as an error correction code area, which is used to detect and correct errors that may occur during the transmission process to ensure the integrity and accuracy of the data.

Will there ever be a day when QR codes run out of use?

Assume that the world consumes 10 billion QR codes every day. If humans have been consuming QR codes at this rate since the birth of the universe 13.8 billion years ago, how many years of the universe can a 33×33 version of the QR code support? Let's first determine a few key values:

1. The number of QR codes consumed worldwide every day: Assumed to be 10 billion, or 10^9.

2. Total consumption in one year: There are about 365 days in a year, and the annual consumption is about 365×10^9=3.65×10^11 QR codes.

3. Age of the Universe: The age of the universe is approximately 13.8 billion years, expressed in scientific notation as 1.38×10^10 years.

The theoretical total number of 4.33×33 version QR codes: 2^942 different codes.

5. Consumption within one universe age: 3.6×10^11×1.38×10^10 =5.037×10^21 QR codes.

Next, we can calculate the number of years of the universe that the 33×33 version of the QR code can support at the current consumption rate, that is, the total number of QR codes divided by the product of annual consumption and the age of the universe:

The number of years of the universe's age that can be supported = 2^942/3.65×10^11×1.38×10^10

In summary, if we start to consume QR codes at the above assumed speed, humans will only use 5.037×10^21 of them. In other words, the 33×33 version is enough for humans to use for 7.3805×10^261 "13.8 billion years".

In addition, there are many types of QR codes (including QR Code, Code 49, Code 16K, etc., QR Code is a widely used one), and each QR code can carry a lot of information. The same QR code type provides different sizes or versions, and each version can carry different amounts of information.

Therefore, in theory, if humans can exist in the universe for a long enough time, the QR codes can be used up, but this time is too long, and perhaps even the universe itself cannot wait until that day. Even if the QR codes are really used up, perhaps humans in the distant future will continue to add more dimensions, and the changes will be more numerous.

<<:  Can cancer be transmitted between husband and wife? These 4 types are likely to develop into "couple cancer", take precautions →

>>:  Weaving, rapping, tilling the land...the "workers" in the cultural relics are also admirable!

Recommend

Chinese mobile phones only have craftsmanship but no craftsmanship? !

The so-called difference between craftsmanship an...

What are the product methods to improve user retention?

Recently I saw a written test question that requi...

Analysis of ideas and steps for writing online promotion plans

Internet promotion, a promotion method that requi...

Sad culture is popular, so is heartfelt marketing far behind?

Looking at the popular advertising cases today, i...

13 aspects to consider when developing a mobile app

This article is for newcomers to the field of mob...

Why do we get more and more addicted to celebrity gossip?

At the beginning of the new year, eye-catching &q...

How to build e-commerce live streaming 0-1?

How did a successful e-commerce live broadcast co...

Tencent's operational path over the years

I would like to share with you four short stories...