Republished depth image not working in rviz
I have a depth image topic that is visualized perfectly in rviz, both as image and as depth cloud. I created a node for subscribing to said topic and then just republish all the messages. The new topic can be visualized as a depth image in rviz, but no points are visible when I select "depth cloud". I compared the depth images from the two topics, and they look the same.
However, it looks like the republished topic lacks information. Under "status", the republished depth cloud does not have the field "Depth Image Size", as well as it lacks a color transformer. See the image below:
Here the depth cloud from the original topic is shown
Ultimately I am going to use OpenCV to change the depth image, but first I just want to see the republished depth could visualized in rviz.
I followed the image_transport tutorial and created this code:
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cv_bridge/cv_bridge.h>
#include <ros/console.h>
image_transport::Publisher pub;
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
pub.publish(msg);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_listener");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
pub = it.advertise("hacked/image_raw", 1);
image_transport::Subscriber sub = it.subscribe("camera/depth/image_raw", 1, imageCallback);
ros::spin();
}
Hope you have an idea about what might be wrong :)
Asked by Mathias Ciarlo on 2017-03-16 10:58:15 UTC
Answers
The problem was that I did not republish the camera_info topic. This topic is needed for generation of point clouds! Either do it manually in the node or this way. Thank you so much for the help! :)
Asked by Mathias Ciarlo on 2017-03-31 04:52:27 UTC
Comments
Have you tried using an
image_transport::Publisher
? As suggested here: http://wiki.ros.org/image_transport#CA-13f3bae9c8540b0039c7ca49178fcb45062185e7_13 Without looking closer, I don't know why you'd need to do this, but it is an asymmetry I saw in your code.Asked by William on 2017-03-16 15:19:09 UTC
I've never used this plugin, but I guess that the DepthCloud needs the camera_info which you do not republish. Could you check if rviz is subscribing to /camera/hacked/camera_info?
Asked by NEngelhard on 2017-03-16 15:36:12 UTC
Thanks, William, but that's actually what I'm doing, I just created the pointer outside of main. NEngelhard: That actually makes a lot of sense! To project 2d points to 3d you obviously need to know the camera caracteristics! I'll try it tomorrow :)
Asked by Mathias Ciarlo on 2017-03-16 19:17:24 UTC
Ah, you're right. Sorry I missed that. I was going to suggest you needed camera_info to be forwarded as well, but I thought the image_transport Publisher might do that for you. If it still doesn't work I'd recommend adding the output of
rostopic list
to your post.Asked by William on 2017-03-16 19:55:56 UTC