decompress jpeg depth data
- OS: Ubuntu 16.04 LTS
- ROS distro: kinetic
Hey, I am using an old Microsoft Kienct camera and freenect for publishing the data.
Subscribing to the topic "/camera/depth_registered/image_raw/compressed", the format of the recieved message of type CompressedImage is 16UC1; jpeg compressed.
Question: How can I decompress the jpeg data to get my 16UC1 encoded depth data? It doesn't matter if ropsy or roscpp.
EDIT:
I tried using image_transport. It works when subscribing to a topic with message type /Image, like /camera/depth_registered/image_raw/. Subscribing to a message of type /CompressedImage leads to a compiler error when running catkin_make.
My node:
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CompressedImage.h>
#include <image_transport/image_transport.h>
void depthCallback(const sensor_msgs::CompressedImage::ConstPtr& msg)
{
sensor_msgs::CompressedImage image;
image.data = msg->data;
image.format = msg->format;
int length = image.data.size();
ROS_INFO("Data:[%i]", length);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "depth");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub = it.subscribe("/camera/depth_registered/image_raw/compressed", 1, depthCallback);
ros::spin();
return 0;
}
the error message when compiling:
gtcc1@gtcc1-Latitude-E5520:~/catkin_gunnar_ws$ catkin_make
Base path: /home/gtcc1/catkin_gunnar_ws
Source space: /home/gtcc1/catkin_gunnar_ws/src
Build space: /home/gtcc1/catkin_gunnar_ws/build
Devel space: /home/gtcc1/catkin_gunnar_ws/devel
Install space: /home/gtcc1/catkin_gunnar_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/gtcc1/catkin_gunnar_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/gtcc1/catkin_gunnar_ws/build"
####
Scanning dependencies of target depth
[ 50%] Building CXX object depth_node/CMakeFiles/depth.dir/src/depth.cpp.o
In file included from /usr/include/boost/function/detail/maybe_include.hpp:18:0,
from /usr/include/boost/function/detail/function_iterate.hpp:14,
from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52,
from /usr/include/boost/function.hpp:64,
from /opt/ros/kinetic/include/ros/forwards.h:40,
from /opt/ros/kinetic/include/ros/common.h:37,
from /opt/ros/kinetic/include/ros/ros.h:43,
from /home/gtcc1/catkin_gunnar_ws/src/depth_node/src/depth.cpp:1:
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static void boost::detail::function::void_function_invoker1<FunctionPtr, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionPtr = void (*)(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:940:38: required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = void (*)(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:728: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 (*)(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:1077:16: required from ‘boost::function<R ...
Does image_transport not work for you?
Thanks for the response, I updated my post.
You should not subscribe to the compressed topics.
image_transport
will take care of all that for you. Please refer to the tutorials.