yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
RDK X5 Robot📖
01. RDK-X5-Robot Introduction
  • 1.Introduction
  • 2.Common Problem Analysis
  • 3.Battery and charger usage precautions
  • 4.TF card expand capacity
02. Assembly Tutorial
  • Assembly Tutorial
  • Assembly Video-1
  • Assembly Video-2
  • Assembly Video-3
  • Assembly Video-4
03. Remote Control Course
  • 1.Mobile APP remote control
  • 2.USB Wireless Controller Remote Control
04. ROS Driver Board Course
  • 1. Introduction of extension board
  • 2. Set up STM32 development environment
  • 3. Key control buzzer sound
  • 4. FreeRTOS application
  • 5. Serial communication
  • 6. SBUS model remote control
  • 7. CAN bus communication
  • 8. RGB color light strip
  • 9. Timer interrupt control PWM servo
  • 10. Control serial steering gear
  • 11. Nine-axis attitude sensor to obtain data
  • 12. Control motor forward and reverse
  • 13. The timer captures encoder data
  • 14. Theory of robot kinematics analysis
  • 15. PID control robot motion
05. Basic Control Course
  • 1.Update expansion board firmware
  • 2.Install Python driver library
  • 3.Set the car type
  • 4.Open and close APP program control
  • 5.Turn hotspot mode on and off
  • 6.Buzzer sound
  • 7.Control the motor to rotate forward and reverse
  • 8.Controlling robot movement
  • 9.OLED display
  • 10.Control fans and lighting effects
06. Development Environment
  • 1. Virtual machine installation and use
  • 2. Linux Basics
  • 3. Remote connection
  • 4. Multi-machine communication configuration
  • 5. Bind device ID
  • 6. Image installation and backup
07. ROS2 Basic Course
  • 1. Introduction to ROS2
  • 2. ROS2 install Humble
  • 3. ROS2 development environment
  • 4. ROS2 workspace
  • 5. ROS2 function package
  • 6. ROS2 node
  • 7. ROS2 topic communication
  • 8. ROS2 service communication
  • 9. ROS2 action communication
  • 10. ROS2 custom interface message
  • 11. ROS2 parameter service case
  • 12. ROS2 meta-function package
  • 13. ROS2 distributed communication
  • 14. ROS2 DDS
  • 15. ROS2 time related API
  • 16. ROS2 common command tools
  • 17. ROS2 rviz2 use
  • 18. ROS2 rqt toolbox
  • 19. ROS2 Launch startup file configuration
  • 20. ROS2 recording and playback tool
  • 21. ROS2 URDF model
  • 22. ROS2 Gazebo simulation platform
  • 23. ROS2 TF2 coordinate transformation
08. Robot Chassis Control Course
  • 1. PID algorithm theory
  • 2. Robot information release
  • 3. Robot control
  • 4. Robot state estimation
  • 5. Robot calibration
  • 6. Robot trajectory tracking
  • 7. URDF Model
09. LiDAR Course
  • 1. Introduction and use of lidar
  • 2. Lidar obstacle avoidance
  • 3. Lidar tracking
  • 4. Lidar guard
  • 5. Lidar patrol
  • 6. gmapping mapping algorithm
  • 7. Cartographer mapping algorithm
  • 8. Navigation and obstacle avoidance
  • 9. App Mapping and Navigation
10. OpenCV Course
  • 1. Getting started with OpenCV
  • 2. OpenCV geometric transformation
  • 3. OpenCV Image Processing
  • 4. OpenCV image beautification
  • 5. QR code creation and recognition
11. Mipi Camera Course
  • 1. Camera driver
  • 2. Adjust the color HSV value
  • 3. Color recognition
  • 4. Color Tracking
  • 5. Color Follow
  • 6. QR code instructions
  • 7. Face Detection
  • 8. Object Detection
  • 9. Visual line patrol-OpenCV
  • 10. Visual line patrol-deep learning
  • 11. Human body tracking
  • 12. Gesture control
12. Depth Camera Course
  • 1. Use of Depth Camera
  • 2. Camera intrinsic calibration
  • 3. ROS+OpenCV Basics
  • 4. AR Vision
  • 5. Color Tracking
  • 6. Object Tracking
  • 7. RTAB-Map 3D Mapping Navigation
13. Multi-robot Synchronous Control
  • Multi-vehicle synchronous control
Remote login control
  • 1. VNC and SSH remote login
  • 2. Jupyter lab login and case code running
Download
  • System_File
  • Code
  • VM_File
  • Software_Tools
  • Hardware_Info
  • Firmware
  • Instruction_Manual
  • ROS2_Basic_VM
Download ZIP

Welcome to RDK X5 Robot repository

5. QR code creation and recognition

QR code creation and recognition

QR code creation and recognition5.1. QR QR code5.1.1. Introduction to QR QR code5.1.2. QR QR code structure5.1.3. Characteristics of QR QR code5.2, Program Function Description5.3, Program code reference path5.4, Program Startup5.4.1, Create QR Code5.4.2, QR code recognition5.5, core source code analysis5.5.1、QRcode_Create.py5.5.2, QRcode_Parsing.py

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,

xxxxxxxxxx
/home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples

The command to install the required package is,

xxxxxxxxxx
python3 -m pip install qrcode pyzbar
sudo apt-get install libzbar-dev

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,

xxxxxxxxxx
#Switch to the directory where the code is located
cd /home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples
#Run the QR code creation program
python3 QRcode_Create.py

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,

xxxxxxxxxx
/home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures/myQRcode.jpg

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,

xxxxxxxxxx
#Switch to the directory where the code is located
cd /home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples
#Run the QR code recognition program
python3 QRcode_Parsing.py

1684983031885

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

xxxxxxxxxx
/home/sunrise/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures/myQRcode_result.jpg

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

​x
#Create qrcode object
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=10,
border=4,)
#Meaning of each parameter
'''version: An integer with a value of 1 to 40, which controls the size of the QR code (the minimum value is 1, which is a 12×12 matrix).
If you want the program to determine it automatically, set the value to None and use the fit parameter.
error_correction: Controls the error correction function of the QR code. The following 4 constants can be used.
ERROR_CORRECT_L: About 7% or less errors can be corrected.
ERROR_CORRECT_M (default): About 15% or less errors can be corrected.
ERROR_CORRECT_H: About 30% or less errors can be corrected.
box_size: controls the number of pixels contained in each small grid in the QR code.
border: controls the number of grids contained in the border (the distance between the QR code and the image border) (the default is 4, which is the minimum value specified by the relevant standards)'''

# Generate image
img = qr.make_image(fill_color="green", back_color="white")
# Add data
qr.add_data(data)
# Fill data
qr.make(fit=True)
# Add logo
my_file = Path(logo_path)
if my_file.is_file(): img = add_logo(img, logo_path)

5.5.2, QRcode_Parsing.py

def decodeDisplay(image, font_path):
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
# You need to convert the output Chinese characters into Unicode encoding format first
barcodes = pyzbar.decode(gray)
for barcode in barcodes:
# Extract the position of the bounding box of the QR code
(x, y, w, h) = barcode.rect
# Draw the bounding box of the barcode in the image
cv.rectangle(image, (x, y), (x + w, y + h), (225, 0, 0), 5)
encoding = 'UTF-8'
# Draw it, you need to convert it into a string first
barcodeData = barcode.data.decode(encoding)
barcodeType = barcode.type
# Draw the data and type on the image
pilimg = Image.fromarray(image)
# Create a brush
draw = ImageDraw.Draw(pilimg)
# Parameter 1: font file path, parameter 2: font size
fontStyle = ImageFont.truetype(font_path, size=20, encoding=encoding)
# Parameter 1: print coordinates, parameter 2: text, parameter 3: font color, parameter 4: font
draw.text((x, y - 30), str(barcode.data, encoding), fill=(0, 0, 255), font=fontStyle)
# Convert PIL image to cv2 image
image = np.array(pilimg)
# Print barcode data and barcode type to the terminal
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
return image
OpenCV image beautification
Camera driver

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文