faimer
faimer

Reputation: 21

Get Depth in mm for recorded video from Kinect SDK

I am using video recorded from Kinect with c++ language for my project. I am trying to get the real world coordinates (real depth) for a point. But I don't know, if there is a function in the Kinect SDK for that purpose. So I reversed this formula:

BYTE b = 255 - static_cast (256  realDepth / 0x0FFF)

to get this:

realDepth = (255-b) * 0x0FFF / 256

I do not know if what I did is correct or not. What do you suggest?

Upvotes: 1

Views: 443

Answers (1)

Vito Gentile
Vito Gentile

Reputation: 14356

After having seen this video, I think that you should proceed as follows:

  • white pixels are the farest distance possible, which (for Kinect SDK 1.x not in near mode, i.e. default mode) is equal to 4 meters;
  • black pixels can be unknown values, as well as the closest possible value, which (for Kinect SDK 1.x in default mode) is equal to 0.8 meters.

So this means that, if I have correctly guessed that those videos have been recorded in default mode, and assuming that you convert each frame in a grayscale image (each pixel value ranges from 0 to 255), you should use the following formula:

realDepth (in meters) = ( 3.2 * grayValue / 255 ) + 0.8

This way, if grayValue is equal to 0 (black), then realDepth is 0.8 meters. While if grayValue is equal to 255 (white), then realDepth is 4 meters.

If you want the realDepth in millimiters, just divide it by 1000.

Note also that some black pixels can also represent an unknown value. So if realDepth is equal to 0.8, you cannot be sure that this is the correct value, or if it is actually an unknown one.

Upvotes: 1

Related Questions