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

Revision history [back]

click to hide/show revision 1
initial version

The call cv_ptr->toImageMsg(); retuns you an instance of sensor_msgs::ImagePtr

See:

http://docs.ros.org/indigo/api/cv_bridge/html/c++/classcv__bridge_1_1CvImage.html#a48a7cc72fa96bdf0180d0306543ceb07

In your line

sensor_msgs::Image img2_ = cv_ptr->toImageMsg();

you attempt to assign the pointer to an object.

So try either:

sensor_msgs::Image img2_ = *(cv_ptr->toImageMsg());  // dereference pointer to get content before assigning to object

or:

sensor_msgs::ImagePtr img2_ = cv_ptr->toImageMsg();  //assign pointer to pointer