QR code creation and recognition

5.1. QR QR code

5.1.1. Introduction to QR QR code

QR code is a type of two-dimensional barcode. QR comes from the abbreviation of "Quick Response" in English, which means quick response. It comes from the inventor's hope that QR code can allow its content to be decoded quickly. QR code not only has large information capacity, high reliability and low cost, but also can represent a variety of text information such as Chinese characters and images. It has strong confidentiality and anti-counterfeiting properties and is very convenient to use. More importantly, the QR code technology is open source.

5.1.2. QR QR code structure

image-20230426101118368

5.1.3. Characteristics of QR QR code

The data value in the QR code contains repeated information (redundant value). Therefore, even if up to 30% of the QR code structure is destroyed, it does not affect the readability of the QR code. The storage space of the QR code is up to 7089 bits or 4296 characters, including punctuation and special characters, which can be written into the QR code. In addition to numbers and characters, words and phrases (such as URLs) can also be encoded. As more data is added to the QR code, the code size increases and the code structure becomes more complex.

5.2, Program Function Description

After running the QR code creation program, enter the QR code content to generate a QR code image and save it locally.

After running the QR code recognition program, the created QR code image will be read and recognized, the recognition result will be output and the image will be saved locally.

The image can be visualized by configuring VSCode to connect with the car.

5.3, Program code reference path

After SSH connects to the car, the source code of this function is located at,

The command to install the required package is,

The factory system image has been installed.

5.4, Program Startup

5.4.1, Create QR Code

After SSH connects to the car, open the terminal and input,

After the program runs, you will be prompted to enter the generated content, and press Enter to confirm the content. Here we take the creation of the "yahboom" string as an example,

1684982462181

The created QR code is saved in the path,

Remotely connect to the car in VSCode, enter the /home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures directory, you can click on the picture to view the QR code,

1684983567408

Take out your phone and try to scan the displayed QR code, the scan result will be the characters of yahboom.

5.4.2, QR code recognition

After SSH connects to the car, open the terminal and input,

1684983031885

The program will print out the recognized content in the terminal and save the recognition result image to the path,

SSH connect to the car in VSCode, enter the /home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures directory, you can click on the image to view the QR code,

1684983749286

5.5, core source code analysis

5.5.1、QRcode_Create.py

5.5.2, QRcode_Parsing.py