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

Republished depth image not working in rviz [closed]

asked 2017-03-16 11:04:31 -0500

Mathias Ciarlo gravatar image

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. The two topics both show the images correctly as depth images

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: The lower depth cloud is the republished one

Here the depth cloud from the original topic is shown image description

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 :)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by NEngelhard
close date 2017-03-31 07:21:15.435481

Comments

1

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.

William gravatar image William  ( 2017-03-16 15:19:09 -0500 )edit
1

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?

NEngelhard gravatar image NEngelhard  ( 2017-03-16 15:36:12 -0500 )edit

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 :)

Mathias Ciarlo gravatar image Mathias Ciarlo  ( 2017-03-16 19:17:24 -0500 )edit
1

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.

William gravatar image William  ( 2017-03-16 19:55:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-31 04:52:27 -0500

Mathias Ciarlo gravatar image

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! :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-16 10:58:15 -0500

Seen: 1,552 times

Last updated: Mar 31 '17