ROS provide the
sensor_msgs::Image message to send images between nodes. However, we usually need a data type or object to manipulate the images in order to do some useful work. The most common library for that is OpenCV, so ROS offers a bridge class to transform ROS images back and forth from OpenCV.
If we have an OpenCV image, that is,
cv::Mat image, we need the
cv_bridge library to convert it into a ROS image message and publish it. We have the option to share or copy the image with
CvCopy, respectively. However, if possible, it is easier to use the OpenCV image field inside the
CvImage class provided by
cv_bridge. That is exactly what we do in the camera driver as a pointer:
Being a pointer, we ...