ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

sensor_msgs::CompressedImage subscribe fails to build

asked 2016-07-15 09:09:18 -0500

jtim gravatar image

updated 2016-07-19 08:01:30 -0500

Hey I have the following subscriber:

ImageConverter(ros::NodeHandle &n) :  n_(n), it_(n_)
{
  image_pub_ = it_.advertise("/output_img",1);

  cv::namedWindow(OPENCV_WINDOW);
  image_transport::TransportHints TH("compressed");
  image_sub_compressed.subscribe(n,"/Logitech_webcam/image_raw/compressed",5,&ImageConverter::imageCallback,ros::VoidPtr(),TH);
}

And the callback function

void imageCallback(const sensor_msgs::CompressedImageConstPtr& msg)

When I compile this I get an error:

from /home/johann/catkin_ws/src/uncompressimage/src/publisher_uncompressed_images.cpp:1:
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static void boost::detail::function::function_void_mem_invoker1<MemberPtr, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with MemberPtr = void (ImageConverter::*)(const boost::shared_ptr<const sensor_msgs::CompressedImage_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&]’:
/usr/include/boost/function/function_template.hpp:934:38:   required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = void (ImageConverter::*)(const boost::shared_ptr<const sensor_msgs::CompressedImage_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:722:7:   required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = void (ImageConverter::*)(const boost::shared_ptr<const sensor_msgs::CompressedImage_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/usr/include/boost/function/function_template.hpp:1069:16:   required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = void (ImageConverter::*)(const boost::shared_ptr<const sensor_msgs::CompressedImage_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/johann/catkin_ws/src/uncompressimage/src/publisher_uncompressed_images.cpp:27:126:   required from here

The red error statement was:

/usr/include/boost/function/function_template.hpp:225:11: error: no match for call to ‘(boost::_mfi::mf1<void, ImageConverter, const boost::shared_ptr<const sensor_msgs::CompressedImage_<std::allocator<void> > >&>) (const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&)’
           BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));

I am not using BOOST, and searching around hasn't helped me solve it, this is how I think it should be based on reading the github for the sensor_msgs::compressedImages, if another method exists that is better?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2016-07-29 07:08:18 -0500

jtim gravatar image

ended up recompiling opencv and ros from source, the error was removed. However the subscription didn't work. Therefore I subscribed to the raw image that I had republished in a launch file. Now everything works.

edit flag offensive delete link more
1

answered 2016-07-15 09:44:52 -0500

soulslicer gravatar image

Read the source code:

https://github.com/ros-perception/ima...

const sensor_msgs::CompressedImageConstPtr& compressedImg outputImg = cv::imdecode(cv::Mat(compressedImg->data), CV_LOAD_IMAGE_UNCHANGED);

edit flag offensive delete link more

Comments

@soulslicer Can't seem to find it in the source could you specify the file? Also the code you refer, creates and const pointer to a compressedImg data? Seems to be some wrong with the code? Also the idea was to decompress the image? so from Sensor_msgs::CompressedImage to Sensor_msgs::Image.

jtim gravatar image jtim  ( 2016-07-17 15:12:09 -0500 )edit

@soulslicer I am not able to find the code you refer to, can you be more precise?

jtim gravatar image jtim  ( 2016-07-18 07:28:42 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-15 09:09:18 -0500

Seen: 1,700 times

Last updated: Jul 29 '16