Republished depth image not working in rviz [closed]
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 :)
Have you tried using an
image_transport::Publisher
? As suggested here: http://wiki.ros.org/image_transport#C... Without looking closer, I don't know why you'd need to do this, but it is an asymmetry I saw in your code.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?
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 :)
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.