getting and reading depth values from kinect2 sensor
Hi All,
I am very new to ROS, I installed ROS and also libfreenect2 Driver and iai_kinect2 library (are required software for the kinect v2 to interface with ROS).
Ubantu 14.04 ROS, libreenect2, Iai_kinect2
I have below data when i use 'rostopic list' command
bhaskar@D125-40806Linux:~$ rostopic list /kinect2/hd/camerainfo
/kinect2/hd/imagecolor
/kinect2/hd/imagecolor/compressed
/kinect2/hd/imagecolorrect
/kinect2/hd/imagecolorrect/compressed
/kinect2/hd/imagedepthrect
/kinect2/hd/imagedepthrect/compressed
/kinect2/hd/imagemono
/kinect2/hd/imagemono/compressed
/kinect2/hd/imagemonorect
/kinect2/hd/imagemonorect/compressed
/kinect2/qhd/camerainfo
/kinect2/qhd/imagecolor
/kinect2/qhd/imagecolor/compressed
/kinect2/qhd/imagecolorrect
/kinect2/qhd/imagecolorrect/compressed
/kinect2/qhd/imagedepthrect
/kinect2/qhd/imagedepthrect/compressed
/kinect2/qhd/imagemono
/kinect2/qhd/imagemono/compressed
/kinect2/qhd/imagemonorect
/kinect2/qhd/imagemonorect/compressed
/kinect2/sd/camerainfo
/kinect2/sd/imagecolorrect /kinect2/sd/imagecolorrect/compressed
/kinect2/sd/imagedepth
/kinect2/sd/imagedepth/compressed
/kinect2/sd/imagedepthrect
/kinect2/sd/imagedepthrect/compressed
/kinect2/sd/imageir
/kinect2/sd/imageir/compressed
/kinect2/sd/imageirrect
/kinect2/sd/imageirrect/compressed
/rosout
/rosoutagg
Can you please tell what each list describes ? I would like to know which one is useful from above to get depth values of image and also how to read the those depth data ?
I used below command
rostopic echo /kinect2/sd/image_depth
I got below values
header:
seq: 1298
stamp:
secs: 1489614685
nsecs: 946450545
frameid: kinect2iropticalframe
height: 424
width: 512
encoding: 16UC1
is_bigendian: 0
step: 1024
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 30, 244, 28, 206, 4, 0, 0, 0, 0, 57, 5, 0, 0, 27, 9, 159, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 4, 0, 0, 0, 0, 0, 0, 34, 37, 0, 0, 0, 0, 42, 9, 238, 32, 0, 0, 0, 0, 0,.................]
Can you please explain what each value represents above ?
Thanks in advance,
Bhaskar.
Asked by BHAASKARR on 2017-03-15 17:03:59 UTC
Answers
sd
, qhd
and hd
are resolutions of the image. Details are given in iai_kinect2 repo.
For topic names,
_ir
: infrared image
_color
: color image
_depth
: depth_image
additional _rect
is for rectified image.
If you use depth_image_proc, with point_cloud_xyzrgb
nodelet, you can convert depth images to point clouds.
Update:
For the depth values, asked in comments below, you need to check encoding. Encoding given in the question is: encoding: 16UC1
. This means 16-bits unsigned short with 1 channel. So each depth is represented with 2 bytes. To convert these bytes to depth, you should also check is_bigendian: 0
. In this question byte order is little-endian. As a result, depth = data[i] + (data[i + 1] << 8)
which is also mentioned in comments below.
The point is, you need to check encoding and endianness.
Asked by Akif on 2017-03-21 04:47:06 UTC
Comments
Thank you @Akif for your explanation.
Asked by BHAASKARR on 2017-03-22 15:37:45 UTC
If i use rostopic echo /kinect2/sd/image_depth
can you help me what does each value represents here
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 30, 244, 28, 206, 4, 0, 0, 0, 0, 57, 5, 0, 0, 27, 9, 159, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 4, 0, 0, 0, 0, 0, 0, 34, 37, 0, 0, 0, 0, 42,
Asked by BHAASKARR on 2017-03-22 15:40:10 UTC
Hi,
Did you find a way to convert the depth data to MM or any measuring unit ?
Asked by Abdu on 2017-07-16 17:17:17 UTC
temp_val = depth_image->data[index] + (depth_image->data[index + 1] << 8);
200 + 3 (shift left by 8)
=~96 cm
Asked by BHAASKARR on 2017-07-17 06:08:47 UTC
Sorry for bothering you, but I am new in ROS and Kinect 2, would you please give me more details, how can i use this formula. Right now, when I run rostopic echo /kinect2/sd/image_depth
I am getting random data I dont know how to make it useful
Asked by Abdu on 2017-07-19 09:44:38 UTC
The data you will get will be something like this
data: [0,0,0,0,......200,3,.......114,4,0,0,0,0.....]
I hope each pair represents one pixel and by using each pair, we can calculate the distance like =200+3(shift left by 8 times) //do this calculation by converting to decimals//
Asked by BHAASKARR on 2017-07-19 15:27:10 UTC
=11001000 + 1100000000 =968 mm
Asked by BHAASKARR on 2017-07-19 15:28:02 UTC
Comments
@gvdhoorn
@pallavbakshi
@clungzta
@ngrennan
@naman
@est_CEAR
@denim_patel
@akif
@lilouch
@Miquel Massot
Asked by BHAASKARR on 2017-03-15 17:29:42 UTC