[ros-users] problem using TimeSynchronizer with two images

James Bowman jamesb at willowgarage.com
Thu Mar 11 23:03:13 UTC 2010

TimeSynchronizer is doing fine, the problem is caused by CvBridge.

A CvBridge object is designed to handle one image at a time.  So for this
case you should create two CvBridge objects, one for left and one for right.

So the code should be:

*sensor_msgs::CvBridge bridge[2];

void callback(const ImageConstPtr& left, const ImageConstPtr& right) {
     IplImage* im_left = bridge[0].imgMsgToCv(left, "rgb8");
     IplImage* im_right = bridge[1].imgMsgToCv(right, "rgb8");

     cvShowImage("left", im_left);
     cvShowImage("right", im_right);

On Thu, Mar 11, 2010 at 2:55 PM, Dan Lazewatsky
<lazewatskyd at cse.wustl.edu>wrote:

> Hi all -
> I'm trying to use TimeSynchronizer to sync up images from two cameras, but
> I'm having some problems. In the following lines:
>    message_filters::Subscriber<Image> left_sub(nh, "stereo/left/image", 1);
>    message_filters::Subscriber<Image> right_sub(nh, "stereo/right/image",
> 1);
>    TimeSynchronizer<Image, Image> sync(left_sub, right_sub, 10);
>    sync.registerCallback(boost::bind(&callback, _1, _2));
> in the callback, both left and right appear to be the same image (they both
> seem to come from the rightmost subscriber given to sync). I've checked
> stereo/left/image and stereo/right/image with image_view and they are
> definitely different. Is there something I'm missing here? Code to reproduce
> is attached.
> On a related note, is there a way to use TimeSynchronizer with
> image_transport rather than subscribing to the image directly?
> Thanks,
> -Dan
> _______________________________________________
> 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/20100311/186da3d5/attachment-0004.html>

More information about the ros-users mailing list