0
$\begingroup$

Rosanswers logo

Hi, I'm trying to write code to take two image messages called /stereocam/left/image_raw, and /stereocam/right/image_raw, each from two different cameras. I want to combine them to both into one image, however I can't figure out how to set up one callback function to determine which camera the particular image came from. I tried this, but it won't compile.

image_transport::Subscriber sub1 = it.subscribe<sensor_msgs::Image> ("/stereocam/left/image_raw", 1, boost::bind(imageCallback, _1, 1)); image_transport::Subscriber sub2 = it.subscribe<sensor_msgs::Image> ("/stereocam/right/image_raw", 1, boost::bind(imageCallback, _1,2));

and

void imageCallback(const sensor_msgs::ImageConstPtr& msg, int queue_id) { }

I tried a variation of this using just ROS instead of image_transport and it compiles just fine, but this doesn't.

Any help would be greatly appreciated.


Originally posted by Fred99 on ROS Answers with karma: 13 on 2012-05-11

Post score: 1


Original comments

Comment by Mac on 2012-05-12:
Offhand, it's sensor_msgs::Image, with a capital I. Can you post your complete code, or at least the smallest snippet that doesn't compile?

Comment by Fred99 on 2012-05-12:
image_transport::Subscriber sub = it.subscribe<sensor_msgs::Image>("/stereocam/left/image_raw", 1, boost::bind(imageCallback, _1, 1));

That is the part that it says doesn't have a matching function call.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You need to remove the template parameter for the subscribe call. According to the image_transport api docs, the version of it.subscribe that accepts a boost::function object for the callback is not templated.


Originally posted by Eric Perko with karma: 8406 on 2012-05-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Fred99 on 2012-05-12:
Thank you! It compiles now. Much appreciated :)

Comment by Eric Perko on 2012-05-12:
Please use the checkmark to mark this answer as "accepted" if it solved your issue. That way, the next person to have this problem can easily find the solution. Thanks for helping to keep ROS Answers organized and easy to use!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.