O'Reilly logo

Effective Robotics Programming with ROS - Third Edition by Aaron Martinez, Enrique Fernández, Luis Sánchez, Anil Mahtani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required