[ros-users] cvbridge conversion failure

Cedric Pradalier cedric.pradalier at mavt.ethz.ch
Thu May 20 06:33:19 UTC 2010


On 05/20/2010 04:09 AM, Chriss Lei wrote:
> Hello.
>
> I'm subscribing to three topics and trying to extract image part of 
> DisparityImageConstPtr message and convert it to IplImage.
>
> Here's the callback function I'm using.
>
>     void callback(const sensor_msgs::CameraInfo::ConstPtr& info,
>                 const sensor_msgs::ImageConstPtr& left,
>                 const stereo_msgs::DisparityImageConstPtr& disparity_msg)
>     {
>         K_intrinsic[0] = info->K[0];
>         ROS_INFO("fx [%f]", K_intrinsic[0]);
>
>         cerr << "f: " << disparity_msg->f << " , T: " << 
> disparity_msg->T << endl;
>
>         IplImage* im_left = bridge[1].imgMsgToCv(left, "passthrough");
>
>         //const sensor_msgs::Image& disp = (disparity_msg->image);
>         //const sensor_msgs::ImageConstPtr& dispPtr = disp;
>
>         IplImage* dispImg = bridge[2].imgMsgToCv(disparity_msg->image, 
> "passthrough");
>
>         cvShowImage("left", im_left);
>
>     }
>
> Subscribing works fine (I can see the rectified image displayed) but 
> I'm having a difficult time extracting the image member of the 
> DisparityImageConstPtr message.
>
> I have to following error:
>
> /home/lei/ros/stacks/poseEstimation/src/vizDepthMap.cpp:79: error: no 
> matching function for call to ‘sensor_msgs::CvBridge::imgMsgToCv(const 
> sensor_msgs::Image&, const char [12])’
> /home/lei/ros/stacks/vision_opencv/cv_bridge/include/cv_bridge/CvBridge.h:424: 
> note: candidates are: IplImage* 
> sensor_msgs::CvBridge::imgMsgToCv(boost::shared_ptr<const 
> sensor_msgs::Image>, std::string)
>
>
> It seems like there's an error from cvbridge expecting ImageConstPtr 
> as input but I'm supplying Image type.
>
> Is there a way to extract and convert the disparity image from the 
> DisparityImageConstPtr message?

It looks to me, you should just replace:

         IplImage* dispImg = bridge[2].imgMsgToCv(disparity_msg->image, 
"passthrough");

with

         IplImage* dispImg = 
bridge[2].imgMsgToCv(&(disparity_msg->image), "passthrough");

and let boost::shared_ptr do its magic.

Or, is there something more subtle I just missed?

-- 
Cedric
- http://www.asl.ethz.ch/people/cedricp
- http://www.skybotix.com




More information about the ros-users mailing list