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

sensor_msgs::CvBridge’ has not been declared

asked 2014-08-06 21:13:39 -0600

Azl gravatar image

Im currently using Ubuntu and running on ROS groovy. I just started using ROS and opencv. Trying to capture image using my Asus Xtion Pro and using opencv codes.

Im starting on tutorial: Running the Simple Image Publisher and Subscriber with Different Transports, and i encountered a problem after make to run my_publisher and my_subscriber.

Error: sensor_msgs::CvBridge’ has not been declared

Can anyone help me out with this?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-08-07 04:12:29 -0600

Chrissi gravatar image

updated 2014-08-07 04:13:10 -0600

Because there's no such thing as a sensor_msgs::CvBridge. Have a look at the cv_bridge tutorial

especially this part for an image callback:

void imageCb(const sensor_msgs::ImageConstPtr& msg)
 cv_bridge::CvImagePtr cv_ptr;
  cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
 catch (cv_bridge::Exception& e)
  ROS_ERROR("cv_bridge exception: %s", e.what());

 // Draw an example circle on the video stream
 if (cv_ptr->image.rows > 60 && cv_ptr->image.cols > 60)
  cv::circle(cv_ptr->image, cv::Point(50, 50), 10, CV_RGB(255,0,0));

 // Update GUI Window
 cv::imshow(OPENCV_WINDOW, cv_ptr->image);

 // Output modified video stream

You have to create a cv_bridge::CvImagePtr and afterwards you can publish it as a sensor_msgs/Image again with cv_bridge::CvImagePtr::toImageMsg().

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-08-06 21:13:39 -0600

Seen: 2,674 times

Last updated: Aug 07 '14