0
$\begingroup$

Rosanswers logo

Hi guys,

I am trying to obtain the IR images (of type const sensor_msgs::ImageConstPtr& image) from the kinect, copy this image to a class attribute ImageIn_, and then convert it to an opencv type image using cv_bridge so I can do some processing: imageOut_ = cv_bridge::toCvCopy(imageIn_, enc::MONO16);

The compilation is successful but when running the node, I keep getting this error message: [ERROR] [1361153962.171443742]: Unable to convert '' image to bgr8: 'Unrecognized image encoding []'

I am not sure why its trying to convert it to bgr8 and not mono16. I have also tried imageOut_ = cv_bridge::toCvCopy(imageIn_, enc::BGR8); but I still get the same error.

I am also not sure why it is not recognizing the image encoding, I printed out the input image encoding in the callback function : ROS_INFO("imageIn_Time = %s", imageIn_->encoding.c_str() );, it prints out mono16.

I am not sure if this is a bug or if I am doing something wrong. Any help would be much appreciated. I am using ROS Fuerte and Ubuntu 12.04.

Thanks,


Originally posted by K_Yousif on ROS Answers with karma: 735 on 2013-02-17

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The solution was to remove the enc::MONO16 from the toCvVopy function imageOut_ = cv_bridge::toCvCopy(imageIn_) and then convert the image to type CV_U8C1 imageOut_->image.covertTo(imageOut_->image, CV_8UC1)


Originally posted by K_Yousif with karma: 735 on 2013-02-19

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Median on 2013-03-11:
Can you please share the whole code? I have the exact same problem and your solution is not working. If I try to run toCvCopy without a 2nd argument I get the same exception (Unrecognized enconding).

Comment by Median on 2013-03-12:
I don't understand what ImageIn_ is .. is it a cv_bridge::CvImagePtr ??

Comment by K_Yousif on 2013-03-12:
imageIn_ is a sensor_msgs::ImageConstPt , imageOut_ is a cv_bridge::CvImagePtr

Comment by saips on 2014-08-19:
yup , this one works

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.