Conversion from IplImage to sensor_msgs::Image (ROS)

asked 2014-06-05 03:08:29 -0500

hvn gravatar image

Hi, using ROS Hydro and OpenCV, I want to convert IplImage to sensor_msgs::Image. In older ROS version my code was:

image1 = new IplImage(image);
msgs_im_bin = *cvbridge.cvToImageMsg(image1);

With new ROS this doesn't work anymore and I try this:

cv_bridge::CvImagePtr cv_im_ptr;
cv_im_ptr->image.Mat(image1, 1);
msgs_im_bin = cv_im_ptr->toImageMsg();

However, I get errors for invalid use of Mat and "no match for operator =" in the 3rd line. Any clue on what to do ? Thanks.

edit retag flag offensive close merge delete