|
using System.Threading.Tasks;
using System.Windows;
using Microsoft.Research.Kinect.Nui;
namespace KinectDepthSmoothing
{
public partial class MainWindow : Window
{
private short[] CreateDepthArray(ImageFrame image)
{
// When creating a depth array, it will have half the number of indexes than the original depth image
// This is because the depth image uses two bytes to represent depth. These values must then be
// transformed to a single value per pixel of the final image that represents depth
// for purposes of smoothing prior to rendering.
short[] returnArray = new short[image.Image.Width * image.Image.Height];
byte[] depthFrame = image.Image.Bits;
Parallel.For(0, 240, depthImageRowIndex =>
{
for (int depthImageColumnIndex = 0; depthImageColumnIndex < 640; depthImageColumnIndex += 2)
{
var depthIndex = depthImageColumnIndex + (depthImageRowIndex * 640);
var index = depthIndex / 2;
returnArray[index] = CalculateDistanceFromDepth(depthFrame[depthIndex], depthFrame[depthIndex + 1]);
}
});
return returnArray;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.