Skip to content

QR code detection and tracking

Hint

The operating environment and software and hardware configurations are as follows:

  • OriginBot robot(Visual Version/Navigation Version)

  • PC:Ubuntu (≥20.04) + ROS2 (≥Foxy)

In our daily lives, what are the image recognition scenarios that we are exposed to the most every day? Scanning the code must be one of them.

Wechat login to scan the QR code, mobile payment to scan the QR code, shared bikes to scan the QR code. In addition to these scanning scenarios that have been very popular in daily life, QR codes have also been widely used in industrial production, such as using QR codes to mark material models, or saving product production information in QR codes, as long as you scan through the camera, you can quickly see the corresponding content.

There are many ways to encode QR codes, the common one is QR Code, which is mainly used on mobile devices.

Since the QR code can store a lot of information, can it also be combined with the robot, for example, when the robot recognizes different QR codes, it will make different actions accordingly?

Next, let's try to let the robot recognize the QR code and follow the movement of the QR code.

QR code recognition

After SSH connection to OriginBot, enter the following command in the terminal to enable the QR code recognition function:

$ ros2 launch qr_code_detection qr_code_detection.launch.py
二维码识别命令

View the routine effect on the WEB side

After the operation is successful, on the PC side of the same network, open the browser, enter http://IP:8000 ,and select "web display side" to view the image and algorithm effect, and the IP is the IP address of OriginBot.

二维码识别效果

QR code tracking

Start the chassis

After the SSH connection to OriginBot is successful, enter the following command in the terminal to start the robot chassis:

$ ros2 launch originbot_bringup originbot.launch.py

底盘命令

Start the QR code control node

SSH connects to OriginBot, and after the QR code recognition node is activated, enter the following command in the terminal to start the QR code control node:

$ ros2 run qr_code_control qr_code_control_node

QR code control

By default, the QR code content Front, Back, Left, Right is used to control the OriginBot, and the following QR code can be used to control OriginBot.

F B
L R

二维码控制效果

Check out the control mode

It is also possible to identify the relative position of the QR code and realize the tracking of the QR code.

Enter the following commands in the terminal to view the control mode:

$ ros2 param get /qrcode_control control_with_qrcode_info
# False Do not understand the content of the QR code, only follow the position of the QR code
# True  Identify the contents of the two-dimensional code and execute the command according to the contents of the two-dimensional code

查看控制模式

Modify the control mode

Enter the following command in the terminal to modify the control mode:

$ ros2 param set /qrcode_control control_with_qrcode_info False

修改控制模式

At this point, the relative position of the QR code will be recognized, and the sending speed will be recognized.

二维码跟随效果

You can adjust the movement speed in File qr_code_control_node.py. 调整速度代码

图片1