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

Error when converting IR kinect image to CvImage using cv_bridge

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

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

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.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

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

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

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


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 image Median  ( 2013-03-11 06:10:56 -0600 )edit

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

Median gravatar image Median  ( 2013-03-12 04:57:11 -0600 )edit

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

K_Yousif gravatar image K_Yousif  ( 2013-03-12 18:49:53 -0600 )edit

yup , this one works

saips gravatar image saips  ( 2014-08-19 23:36:32 -0600 )edit

Question Tools

1 follower


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

Seen: 1,321 times

Last updated: Feb 19 '13