Ask Your Question

sensor_msgs::CvBridge::cvToImgMsg in Groovy?

asked 2013-04-09 00:02:52 -0500

Javier J. Salmerón García gravatar image

updated 2014-01-28 17:16:06 -0500

ngrennan gravatar image

Hello everyone,

Following the tutorial in Ros Wiki for creating a simple image publisher (from a set of .png files) I found a compilation error in groovy (in fuerte everything works fine):

cv::WImageBuffer3_b image(cvLoadImage(filePath.c_str(), CV_LOAD_IMAGE_COLOR));
sensor_msgs::ImagePtr msg = sensor_msgs::CvBridge::cvToImgMsg(image.Ipl(), "bgr8");

This is the error I found:

 error: ‘sensor_msgs::CvBridge’ has not been declared

I suppose that the API has changed, but I cannot find an alternative way. Can somebody help me?

Thank you in advance

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2013-04-09 02:13:59 -0500

Javier J. Salmerón García gravatar image

updated 2013-04-09 02:14:34 -0500

I managed to sort it out the following way, using this answer as a reference :

cv::WImageBuffer3_b image(
                    cvLoadImage(filePath.c_str(), CV_LOAD_IMAGE_COLOR));
            cv::Mat imageMat(image.Ipl());

            cv_bridge::CvImage out_msg;
            out_msg.encoding = sensor_msgs::image_encodings::BGR8; 
            out_msg.image    = imageMat;
            out_msg.header.seq = i;
            out_msg.header.frame_id = i;
            out_msg.header.stamp = ros::Time::now();

            ci->header.seq = i;
            ci->header.frame_id = i;
            ci->header.stamp = out_msg.header.stamp;

            pub.publish(out_msg.toImageMsg(), ci);
edit flag offensive delete link more


What does i refer to? I am trying to convert Mat to sensor_msgs::image need help with header values.

balakumar-s gravatar image balakumar-s  ( 2013-09-07 00:56:46 -0500 )edit

answered 2013-06-09 20:29:19 -0500

Refer to for the recommended solution to this problem, the code should look something like:

sensor_msgs::ImagePtr msg;
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-04-09 00:02:52 -0500

Seen: 1,778 times

Last updated: Jun 09 '13