Now we have the depth data as an array of short integers. All we have to do now is move each pixel in turn to the new z position by updating its translation transform:
int temp = 0; int i = 0; for (int y = 0; y < 240; y +=s) for (int x = 0; x < 320; x +=s) { temp = ((ushort)pixelData[x+y*320])>>3; ((TranslateTransform3D) points[i].Transform).OffsetZ = temp; i++; } }
That's all you have to do. Now when you run the program you will see triangles positioned according to the depth returned by the Kinect. It takes some time to get used to reading the image, but you should be able to see shapes and the 3D effect should be clear. Try modifying the angle of view and the distance the camera is from the point cloud. Notice also that the field of view is left right reversed - this is a consequence of turning the camera upside down!
A person standing in a doorway
The results are more impressive when you view a moving 3D image rather than a static screenshot, but there are a few things you need to understand about the image. The first is that areas that have no points are either to far away or too close. Each point in the depth field is positioned at a particular depth and because of the perspective projection the this makes it appear to leave a sort of shadow if itself in the background as triangles are x,y displaced in the image.
You can also get some interesting results by placing the view camera at an angle to the z direction. which is the direction the Kinect is pointing in. This allows you to look sideways at the depth image.
You can download the code for this program from the CodeBin (note you have to register first).