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

What is the best way to get depth values from kinect?

asked 2012-04-27 12:45:17 -0500

Maltenrazer gravatar image

updated 2016-10-24 08:59:41 -0500

ngrennan gravatar image

I have installed ros with the kinect drivers in ubuntu and have it all up and running.i'm new to ros.

What I am ultimately trying to achieve is this: extract the distance in millimetres of a particular point in an RGB image. So what ever the kinect sees in front of it I want to be able to get the depth values out of it. i'm not sure which topic I need to use and

I had a look at:

depth/image_raw (sensor_msgs/Image) Raw image from device. Contains uint16 depths in mm.

But this seems to return each pixel as a max value of 256 and not a u16bit int when viewing the topic by running rostopic echo /camera/depth/image_raw ... how do I convert this depth into millimetres? is the the best one to use at all? or should I use something else?

edit retag flag offensive close merge delete


If you want to extract depth values from an RGB image, you'd probably want to use a registered depth image, i.e. one in which the Depth values are aligned with RGB values. So try using: camera/depth_registered/image

kshitij gravatar image kshitij  ( 2012-04-30 07:16:53 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-27 15:29:24 -0500

Kevin gravatar image

Take a look at depth_image_proc and openni_launch. Also do a search here on for kinect. Between these three things, it should give you a good head start ... good luck!

edit flag offensive delete link more



the depth values that obtain by kinect driver is actually a no. of streams that continuously changing even if kinect remain stationary can u tell me plz y is it so? secondly if i want to access the depth of particular point out of the depth of all points that is seen by kinect, how can i do it? plz guide me

fairy gravatar image fairy  ( 2013-07-25 09:14:47 -0500 )edit

@fairy check my answer below to get depth value at a specific point

askkvn gravatar image askkvn  ( 2021-06-25 01:37:07 -0500 )edit

answered 2021-06-25 01:36:05 -0500

askkvn gravatar image

My answer with complete code (c++) :

Code funtionality:

  • Subscribed to /camera/depth/image_raw rostopic,
  • Convert ROS image to OpenCV image
  • Get image dimension
  • Get global max and min value,
  • Get depth value at specific point,
edit flag offensive delete link more

Question Tools


Asked: 2012-04-27 12:45:17 -0500

Seen: 3,377 times

Last updated: Jun 25 '21