Ask Your Question
0

Callback CompressedImage /w image_transport

asked 2018-09-07 13:10:00 -0600

count_dueki gravatar image

Hello, I am trying to get the images of a kinect topic via image_transport. I added a Subscriber like this

image_transport::ImageTransport it(nh);
image_transport::TransportHints th("compressed");
image_transport::Subscriber img_sub = it.subscribe("/camera/rgb/image_raw", 1, savingImagesCb, ros::VoidPtr(), th);

my Callback:

void savingImagesCb(const sensor_msgs::CompressedImageConstPtr& msg)

It produces the compilation error:

logger.cpp:50:118:   required from here
/usr/include/boost/function/function_template.hpp:118:11: error: invalid initialization of reference of type ‘const boost::shared_ptr<const sensor_msgs::CompressedImage_<std::allocator<void> > >&’ from expression of type ‘const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >’
       BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));

I need the CompressedImage format for further processing, but image_transport won't allow this. How can I subscribe to a topic of this type (other than a normal Subscriber)?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-09-07 20:59:17 -0600

image_transport provides transparent transport of images in compressed formats. This transparency means that on the subscriber side in the callback, you receive a sensor_msgs::Image regardless of which transport has actually been used. That's a feature, because this way, the transport can be transparently exchanged, without any need for code modifications on the consumer side.

Things should hence work if you change your callback to

void savingImagesCb(const sensor_msgs::ImageConstPtr& msg)

If you actually want to receive the compressed image, using a plain subscriber on the compressed topic directly should work (e.g. subscriber to /camera/image_raw/compressed for instance).

edit flag offensive delete link more

Comments

Thank you for your quick answer (and sorry for my late comment!). I have to access the compressed Image directly (to save it with its format), so I will go for a standard Subscriber now.

count_dueki gravatar imagecount_dueki ( 2018-09-12 02:32:25 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-09-07 13:10:00 -0600

Seen: 403 times

Last updated: Sep 07 '18