QR code recognition

1 Ready to start

Before performing QR code recognition, we need to make some preparations.

  1. Print the QR code, the QR code is placed in the /handsfree_ros_ws/src/handsfree/handsfree_ar_tags/config directory picture

    Tips: Due to the algorithm here, if you open the QR code on your phone for recognition, it will be difficult for the camera to recognize it!

  2. Make sure the camera can work normally, according to rgbd_camera in Drive Test Test completes this step. (If the test has been completed before, please ignore this step)

Note: To close a terminal with a process running, use Ctrl+C in the window to interrupt the program, and then close the window.

2 Concise steps

You only need to open two terminals and enter the following two commands respectively

roslaunch handsfree_camera view_camera.launch
roslaunch hands free_ar_tags ar_indiv_rgb_camera.launch

Then shake the paper with the QR code in front of the camera (don't shake it too fast!)

Tips: roslaunch handsfree_camera view_camera.launch can also be replaced by roslaunch handsfree_camera camera.launch. The former will automatically open the RViz visualization interface, and the latter will not open the visualization interface, but you can use other visualization interfaces according to your personal preference.

3 Recognize the QR code

  1. Open the terminal (Ctrl+Alt+T), run the camera driver node and open the visual interface

      roslaunch handsfree_camera view_camera.launch
    

    This command runs the driver node of the camera and opens the RViz visualization interface. If you only need to run the driver node of the camera, you can replace the above command roslaunch handsfree_camera view_camera.launch with roslaunch handsfree_camera camera.launch rgbd-run

    If your RViz visual interface does not have windows for these two cameras, you need to add them manually. Click the Add button in the lower left corner to add, a small window will pop up, select Camera inside, and then click ok. will be added successfully. rviz_add_camera_01

    After the addition is successful, you need to make settings to make the Camera box display images. Find the Camera in the sidebar and click to expand it. Remove the check from the Visiblity check box and set the image topic of the Image Topic. Generally, we choose /camera/ rgb/image_raw and /camera/depth/image_raw rviz_add_camera_02

    If the added Camera component cannot display the screen, change to the Image component to do the same operation.

  2. Start the QR code recognition node

    Open a new terminal, we choose to use RGB image data for QR code recognition, enter the following command

      roslaunch hands free_ar_tags ar_indiv_rgb_camera.launch
    

    Normally, it will display: ar_indiv_rgb_camera

    Or choose to use depth image data for QR code recognition, the command is as follows

      roslaunch hands free_ar_tags ar_indiv_depth_camera.launch
    

    Tips: You can choose one of the above two commands. They both use the open source QR code recognition library ar_track_alvar to recognize QR codes. The main difference between ar_indiv_rgb_camera.launch and ar_indiv_depth_camera.launch files is subscription The topic is different, for more information, please refer to the WIKI of ar_track_alvar.

  3. View QR code information

    We can see the QR code information on the previously opened RViz visualization interface rviz_rgb_qr

    Or open a new terminal and use the rostopic echo command to view the real-time information of the topic /ar_pose_marker of the QR code recognized by the camera

      rostopic echo /ar_pose_marker
    

    The result of the operation is as shown in the figure below code_rgb_qr

    When you move the QR code to the camera, you will see that the information printed in this window has changed ar-topic

    After the camera prints out the topic information of the QR code, you will see the information of position and orientation, which means that the robot calculates the position and attitude of the space where the QR code is located through the data obtained by the camera. These data will facilitate the tracking of QR codes by robots.

  4. Summary

    To recognize the QR code, you need to run two commands on the terminal and open two nodes

    • First run the driver node of the camera to ensure that the camera can be turned on and capture image data.
    • It is necessary to run the recognition node of the QR code to ensure that the camera can process the image data and recognize the QR code.

results matching ""

    No results matching ""