Welcome to RDK X5 Board repository
1.ROS+opencv application
1. ROS+opencv application
ROS transmits images in its own sensor-msgs/Image message format and cannot directly process images, but the provided CvBridge can perfectly convert and convert image data formats. CvBridge is a ROS library that serves as a bridge between ROS and Opencv.
The conversion of Opencv and ROS image data is shown in the following figure:

This lesson will use two cases to demonstrate how to use CvBridge for data conversion.
1.1 Camera Topic Data
We have already set up the camera driver environment and visible color images, depth images, and infrared IR images in the previous section. We can first check which topics are published and what the content of the image data is after driving the camera. Enter the following command on the terminal to start the camera,
x
#AI VIEW camera startros2 launch astra_camera gemini.launch.xml
Then, use the following command to view the list of topic data.
xxxxxxxxxxros2 topic list

Among them,/camera/color/image_raw and/camera/depth/image_raw are the data of color and depth maps. You can use the following command to view the data content of a certain frame,
x
#View RGB image topic data contentros2 topic echo /camera/color/image_raw#View Depth image topic data contentros2 topic echo /camera/depth/image_rawColor image:

Depth map:

Here is the main value needed: encoding, which represents the encoding format of the image and needs to be referred to when converting image data later.
1.2、Read color image topic data and display color images
1.2.1、Run command
x
#astraproplus cameraros2 launch astra_camera gemini.launch.xmlros2 run yahboomcar_visual astra_rgb_image
View topic communication between nodes.
Input following command in the terminal
xxxxxxxxxxros2 run rqt_graph rqt_graph

1.2.2、Core code
Code path
xxxxxxxxxx~/orbbec_ws/src/yahboomcar_visual/yahboomcar_visual/astra_rgb_image.py/The get_ astra_rgb_node node subscribed to the topic of/camera/color/image_raw, and then converted the topic data into car image data for publication through data conversion.
The code is as follows.