Ask Your Question

Is this the right way to obatin depth information? [closed]

asked 2016-07-01 16:36:51 -0500

skr_robo gravatar image

updated 2016-07-01 16:37:20 -0500

Hello, I am trying to find the closest object to a zed camera. I am using the package: zed_wrapper. I need to find the depth (z value) of each pixel in the scene. My understanding is that the topic:


will provide me the required information. The command rostopic type /camera/depth/image_rect_color returned


which I believe is the msg type for depth images. The command rosmsg show sensor_msgs/Image returned

std_msgs/Header header
 uint32 seq
 time stamp
 string frame_id
uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data

I believe that the last field:

uint8[] data

gives the actual info.

I believe that at this point, I should write a subscriber. Do I have enough information to write a subscriber? Is there any other way I can get this information without writing a subscriber? Kindly help. Thank You.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by skr_robo
close date 2016-07-15 14:05:24.685931


subscribe to sensor_msgs::PointCloud2 input, where input is your camera topic than convert it to pcl::PointCloud<pcl::pointxyzrgb> cloud, then make struct: PointXYZRGB p1, then access the z value as depth = p1.z where p1 =,y), where (x,y) is pixel position of depth image.

dinesh gravatar image dinesh  ( 2016-07-06 03:08:25 -0500 )edit

I am not looking to subscribe to point cloud at this stage. I just need depth values. I believe zed provides separate topic for depth alone without relying on topics related to point cloud.

skr_robo gravatar image skr_robo  ( 2016-07-06 11:19:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-04 19:56:20 -0500

janindu gravatar image

If you want to process this data, yes you need to write a subscriber. And yes, if you know the topic name and the message type, that's enough to write a subscriber (for fine tuning you might need information like publishing frequency etc).

You can follow the ROS tutorial to write the subscriber :

You can see what each field in the message represents here :

Does this answer your question?

edit flag offensive delete link more


Thanks for the help. Is there anywhere I can know for sure that the topic I am subscribing to is right i.e. some source that says so and so topic gives depth, without relying on the name of the topic. I mean any page similar to the one to identify fields of the messages.

skr_robo gravatar image skr_robo  ( 2016-07-06 11:27:33 -0500 )edit

In Zed-ros-wrapper docs it only says which topics are published by the node and assuming that the developers are not intentionally trying to mislead us (LOL) I think we can rely on the topic name.

janindu gravatar image janindu  ( 2016-07-06 17:52:41 -0500 )edit

I browsed the code and from the first glance, in line 365 the depth topic is defined. So yes, /camera/depth/image_rect_color looks like the topic you want to subscribe to. Also please read the comment in line 24

janindu gravatar image janindu  ( 2016-07-06 17:56:33 -0500 )edit

Thank You so much for your help. I am sorry if I asked too much. I am relatively new to this. I am grateful for all the info.

skr_robo gravatar image skr_robo  ( 2016-07-08 10:41:41 -0500 )edit

Question Tools

1 follower


Asked: 2016-07-01 16:36:51 -0500

Seen: 589 times

Last updated: Jul 04 '16