ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Good or bad the code compiles and links. I will need to check the routine at work: This involved linking in boost and cv_bridge also painful.
void convert_image_BGR82PNG(const sensor_msgs::Image msg) {
//Convert from the ROS image message to a CvImage suitable for working with OpenCV for processing
cv_bridge::CvImagePtr cv_ptr;
try
{
//Always copy, returning a mutable CvImage
//OpenCV expects color images to use BGR channel order.
sensor_msgs::ImagePtr itI = boost::make_shared<sensor_msgs::Image>(msg);
cv_ptr = cv_bridge::toCvCopy(itI,"bgr8");
cv::imwrite("jnk.pcd",cv_ptr->image);
}
catch (cv_bridge::Exception& e)
{
//if there is an error during conversion, display it
ROS_ERROR("tutorialROSOpenCV::main.cpp::cv_bridge exception: %s", e.what());
return;
}
}