ROS images

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 CvShare or CvCopy, respectively. However, if possible, it is easier to use the OpenCV image field inside the CvImage class provided bycv_bridge. That is exactly what we do in the camera driver as a pointer:

cv_bridge::CvImagePtr frame;

Being a pointer, we ...

Get Effective Robotics Programming with ROS - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.