Extracting only the distance from the camera is more difficult than I anticipated, mostly because the kinnect is built to recognize people rather than objects. With that said, a significant part of the kinect SDK is dedicated to tracking multiple players, skeletal joints, hands, etc.
The same follows when trying to calculate depth as the depth is stored in a 16 bit value and the first 4 bits are used as a player index. This means bit manipulation is needed to extract the depth from the sensor. The following lines of code are used to get the depth at a certain coordinate bit:
int pixelIndex = pixelX + (pixelY * frame.Width);
int depth = pixelData[pixelIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;
Although allowing the programmer more availability by manipulating the bits, it makes transitions between raw depth data and readable depth data quite tedious.
The same follows when trying to calculate depth as the depth is stored in a 16 bit value and the first 4 bits are used as a player index. This means bit manipulation is needed to extract the depth from the sensor. The following lines of code are used to get the depth at a certain coordinate bit:
int pixelIndex = pixelX + (pixelY * frame.Width);
int depth = pixelData[pixelIndex] >> DepthImageFrame.PlayerIndexBitmaskWidth;
Although allowing the programmer more availability by manipulating the bits, it makes transitions between raw depth data and readable depth data quite tedious.