Ask Your Question
1

Error when converting IR kinect image to CvImage using cv_bridge

asked 2013-02-17 14:31:22 -0500

updated 2016-10-24 09:10:45 -0500

ngrennan gravatar image

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,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-02-19 16:23:25 -0500

updated 2013-02-19 16:23:45 -0500

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)

edit flag offensive delete link more

Comments

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).

Median gravatar imageMedian ( 2013-03-11 06:10:56 -0500 )edit

I don't understand what ImageIn_ is .. is it a cv_bridge::CvImagePtr ??

Median gravatar imageMedian ( 2013-03-12 04:57:11 -0500 )edit

imageIn_ is a sensor_msgs::ImageConstPt , imageOut_ is a cv_bridge::CvImagePtr

K_Yousif gravatar imageK_Yousif ( 2013-03-12 18:49:53 -0500 )edit

yup , this one works

saips gravatar imagesaips ( 2014-08-19 23:36:32 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-02-17 14:31:22 -0500

Seen: 1,019 times

Last updated: Feb 19 '13