ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

You don't want to start with the OpenCV datatypes. The best method in ROS is to use nodelets with sensor_msgs::ImageConstPtrs. Then you cast them to a cv share using cv_bridge: http://www.ros.org/wiki/cv_bridge

http://www.ros.org/wiki/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages#cv_bridge.2BAC8-Tutorials.2BAC8-UsingCvBridgeCppDiamondback.Examples_of_sharing_the_image_data

This shares the large amount of image data that you do not want to copy, but sets up the correct metadata for each image type.

If you want to see this "in the wild" take a look at image_pipline, it all uses nodelets and follows best practices for image processing in ROS: https://github.com/ros-perception/image_pipeline/blob/groovy-devel/image_proc/src/nodelets/rectify.cpp