Try just using the FREENECT_DEPTH_MM depth format, which will give a
distance in millimeters using a slightly smarter distance
reconstruction algorithm. If you want the RGB and depth images to
overlay directly, try using the FREENECT_DEPTH_REGISTERED depth
format, which will also align the depth image with the RGB image.
> Second question is if I record as video using libfreenect (record). it
> uses the ffmpeg and save the depth as rgb24 (3 channel). How should
> the distance be restore from here?
The output of the record program is meant to be used with fakenect:
http://openkinect.org/wiki/Fakenect
At this point, fakenect/record don't have support for depth formats
other than FREENECT_DEPTH_11BIT, but you could probably hack it to use
your format of choice.
-Drew
The formula you gave was an approximation empirically derived during
the very early days of OpenKinect. Since then, we've added functions
that use more precise trigonometry and take into account the internal
parameters of the Kinect, so I suggest using those instead via
FREENECT_DEPTH_MM.
-Drew