I am using Kinect combined with ROS for accessing depth data.
/camera/depth_registrered/image is supposed to output depth as float in meters (http://www.ros.org/wiki/openni_launch).
When echoing this topic it does not at all looks like floats. But rather like 8-bit integers as defined by http://www.ros.org/doc/api/sensor_msgs/html/msg/Image.html.
How do I access the depth value in meters (as a float). How do I do this casting?
More specifically, can someone write some pseudo code that would go into the callback function for /camera/depth_registrered/image. I would like this code to output the depth in meters (float) for the pixel in the middle (the 640*480/2-th pixel).
Thanks in advance!
rostopic echoing an image is not going to give you easily intelligible information, as the data doesn't get deserialized as is it actually does when using CvBridge. Try subscribing to the image in code, then converting it to an OpenCV type using CvBridge, and see if it looks more like what you expect.
answered 2012-03-27 13:36:25 -0500f_r
Thanks for the answers. OpenCV and casting are good options.
The easiest solution is however to simply subscribe to /camera/depth_registrered/image_raw and then get this float value as: float middlepoint = (float)msg->data[640*480/2] * 0.001f;
This also results in 1/4th of the communication which is useful if doing this over a network.
The reason I got confused is because OpenNI's "raw data" is in millimeters and OpenKinect's raw data is 11-bit values certainly not in millimeters.
Asked: 2012-03-26 16:43:38 -0500
Seen: 203 times
Last updated: Mar 27 '12