yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
RDK X3 Robot📖
01. About RDK-X3-Robot
1. Instructions
  • 1. Introduction
  • 2. FAQ
  • 3. Battery and charger use precautions
  • 4.TF card expand capacity
2. Common problem analysis
02. Assembly video
  • Part1-Install Motor
  • Part2-Install Battert Fixing Column
  • Part3-Install Motor Coupling
  • Part4-Install Mecanum wheel
  • Part5-Install Expansion Board
  • Part6-Wiring Show
  • Part7-Install Main Control Board
  • Part8-Install Car Top Plate and Antenna
  • Part9-Install OLED Screen
  • Part10-Install Depth Camera(Optional)
  • Part11-Install OLED Screen
  • Part12-Install HD Camera
  • Part13-Install Top Plate
  • Part14-Install Right Side Plate
  • Part15-Motor Wiring Show
  • Part16-lnstall Car Body
  • Part17-Install Battery
  • Part18-Install Lidar
03. Remote control tutorial
  • 1. The phone APP remote tutorial
  • 2. USB wireless controller remote tutorial
04. ROS functional tutorial
  • 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 tutorial
  • 1. Update the firmware of the expansion module
  • 2. Install the Python driver library
  • 3. Set the type of bottom car
  • 4. Open and close the APP program control
  • 5. Turn hotspot mode on and off
  • 6. The buzzer blows
  • 7. Control the motor forward and reverse
  • 8. Control robot movement
  • 9. OLED display
  • 10. Control fan and lamp effect
06. Development environment setup
  • 1. Virtual Machine
  • 2. Linux Basics
  • 3. Remote connection
  • 4. Multi-computer communication configuration
  • 5. Bind the 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
  • 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 courses
  • 1. Introduction and use of lidar
  • 2. Lidar obstacle avoidance
  • 3. Lidar following
  • 4. Lidar guard
  • 5. Patrol
  • 6. gmapping algorithm
  • 7. cartographer algorithm
  • 8. Navigation and obstacle avoidance
  • 9. App mapping and navigation
10. OpenCV courses
  • 1. Introduction to OpenCV
  • 2. OpenCV geometric transformation
  • 3. OpenCV image processing
  • 4. OpenCV image beautification
  • 5. Qr code creation and identification
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 command
  • 7. Face detection
  • 8. Object detection
  • 9. Visual Inspection -OpenCV
  • 10. Visual inspection - Deep learning
  • 11. Human tracking
  • 12. Gesture control
12. Depth Camera courses
  • 1. Use depth camera
  • 2. Calibration of camera internal reference
  • 3. ROS+OpenCV Foundation
  • 4. AR vision
  • 5. Color tracking
  • 6. Object tracking
13. Multi vehicle control
  • 1. Multi-vehicle synchronous control
  • 2. Multi-vehicle navigation
Remote login control
  • 1. VNC and SSH remote login
  • 2. Jupyter lab login and case code running
Download
  • RemoteCtrl_APP(iOS/Android))
  • Mapping_APP(iOS_Android)
  • Code
  • System File
  • VM_File
  • Manual
  • Software_File
  • Hardware_File
  • ROS2_Basic_VM
Download ZIP

Welcome to RDK X3 Robot repository

5. Qr code creation and identification

QR code creation and identification

QR code creation and identification5.1、QR code5.1.1、Introduction of QR code5.1.2、Structure of QR codes5.1.3. Features of QR codes5.2. Description of program function5.3. Program Code Reference paths5.4. Program Startup5.4.1. Create QR codes5.4.2. Identify QR code5.5 Core source code parsing5.5.1. QRcode_Create.py5.5.2、QRcode_Parsing.py

 

5.1、QR code

5.1.1、Introduction of QR code

QR code is a two-dimensional bar code, QR from the English "Quick Response" abbreviation, that is, rapid response meaning, from the inventor hopes that the QR code can make its content quickly decoded. 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, and its security is strong and it is very convenient to use. What's more, the QR code technology is open source.

5.1.2、Structure of QR codes

image-20230426101118368

5.1.3. Features of QR codes

The data values in the QR code contain duplicate information (redundant values). Therefore, even if up to 30% of the structure of the QR code is destroyed, the readability of the QR code is not affected. The QR code has a storage space of 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, you can encode words and phrases, such as web addresses. As more data is added to the QR code, the code size increases and the code structure becomes more complex.

5.2. Description of program function

After running the QR code creation program, input the contents of the QR code, you can generate a QR code picture and save it locally.

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

After VSCode is configured to connect with the car, the image can be visualized.

5.3. Program Code Reference paths

After SSH connection car, the location of the function source code is located at.

~/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples

The commands to install the required packages, as following.

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 codes

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

x
#切换至代码所在目录
# Switch to the directory where the code is located
cd ~/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples
#运行二维码创建程序
# Run the QR code creator
python3 QRcode_Create.py

After the program is run, it will prompt you to enter the generated content. Enter to confirm the content. As an example of creating a "yahboom" string.

1684982462181

The saved path of the created QR code.

xxxxxxxxxx
~/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures/myQRcode.jpg

Remotely connect the car in VSCode, enter the directory /userdata/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures, you can click the image to view the QR code.

1684983567408

Take out your phone and try to scan the QR code displayed. The scan results in the characters yahboom.

5.4.2. Identify QR code

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

x
#切换至代码所在目录
# Switch to the directory where the code is
cd ~/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples
#运行二维码识别程序
# Run QR code recognition program
python3 QRcode_Parsing.py

1684983031885

The program will print out the identified content in the terminal, and save the identification result picture to the path.

xxxxxxxxxx
~/yahboomcar_ws/src/yahboomcar_astra/qrcode_examples/figures/myQRcode_result.jpg

The program will print out the identified content in the terminal, and save the identification result picture to the path.

1684983749286

5.5 Core source code parsing

5.5.1. QRcode_Create.py

x
#创建qrcode对象
# Create a qrcode object
qr = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_H,
        box_size=10,
        border=4,)
#各参数含义
# Meaning of each parameter
'''version:值为1~40的整数,控制二维码的大小(最小值是1,是个12×12的矩阵)。
             如果想让程序自动确定,将值设置为 None 并使用 fit 参数即可。
error_correction:控制二维码的错误纠正功能。可取值下列4个常量。
      ERROR_CORRECT_L:大约7%或更少的错误能被纠正。
      ERROR_CORRECT_M(默认):大约15%或更少的错误能被纠正。
      ROR_CORRECT_H:大约30%或更少的错误能被纠正。
box_size:控制二维码中每个小格子包含的像素数。
border:控制边框(二维码与图片边界的距离)包含的格子数(默认为4,是相关标准规定的最小值)
version: The value is an integer ranging from 1 to 40, which controls the size of the two-dimensional code (the minimum value is 1, which is a 12×12 matrix).
        If you want the program to determine this automatically, set the value to None and use the fit argument.
error_correction: Controls the error correction function of the two-dimensional code. It can take the following four constants.
    ERROR_CORRECT_L: Approximately 7% or less of errors can be corrected.
    ERROR_CORRECT_M (default) : Approximately 15% or less of errors can be corrected.
    ROR_CORRECT_H: About 30% or less of errors can be corrected.
box_size: Controls the number of pixels contained in each small box in the QR code.
border: Control the number of squares included in the border (the distance between the QR code and the image border) (default is 4, which is the minimum specified by the relevant standard)
'''

# 生成图片# Generate pictures
img = qr.make_image(fill_color="green", back_color="white")
# 添加数据# Add data
qr.add_data(data)
# 填充数据# Fill data
qr.make(fit=True)
# 添加logo# Add logo
my_file = Path(logo_path)
if my_file.is_file(): img = add_logo(img, logo_path)

5.5.2、QRcode_Parsing.py

x
def decodeDisplay(image, font_path):
    gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
    # 需要先把输出的中文字符转换成Unicode编码形式
    # Need to first convert the output Chinese characters to Unicode encoding form
    barcodes = pyzbar.decode(gray)
    for barcode in barcodes:
        # 提取二维码的边界框的位置
        # Extract the position of the boundary 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'
        # 画出来,就需要先将它转换成字符串
        # To draw it, you need to convert it to 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)
        # 参数1:字体文件路径,参数2:字体大小
        # Parameter 1: font file path, parameter 2: font size
        fontStyle = ImageFont.truetype(font_path, size=20, encoding=encoding)
        # 参数1:打印坐标,参数2:文本,参数3:字体颜色,参数4:字体
        # 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)
        # PIL图片转cv2 图片
        # PIL turn cv2 pictures
        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/中文