[ros-users] cvbridge conversion failure

Patrick Mihelich mihelich at willowgarage.com
Thu May 20 02:23:32 UTC 2010


Hi Chriss,

You can do:

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

These methods are deprecated, but currently the easiest way to do what you
want.

-Patrick

On Wed, May 19, 2010 at 7:09 PM, Chriss Lei <lei.chriss at gmail.com> 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?
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100519/c492a11f/attachment-0003.html>


More information about the ros-users mailing list