Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Pulling depth data from the Kinect SDK can be extracted from the <a href="http://msdn.microsoft.com/en-us/library/microsoft.kinect.depthimagepixel.aspx" rel="nofollow">DepthImagePixel</a> structure.</p> <p>The example code below loops through the entire <code>DepthImageFrame</code> to examine each of the pixels. If you have a specific coordinate you wish to look at, remove the <code>for</code> loop and set the <code>x</code> and <code>y</code> to a specific value.</p> <pre><code>// global variables private const DepthImageFormat DepthFormat = DepthImageFormat.Resolution320x240Fps30; private const ColorImageFormat ColorFormat = ColorImageFormat.RgbResolution640x480Fps30; private DepthImagePixel[] depthPixels; // defined in an initialization function this.depthWidth = this.sensor.DepthStream.FrameWidth; this.depthHeight = this.sensor.DepthStream.FrameHeight; this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength]; private void SensorAllFramesReady(object sender, AllFramesReadyEventArgs e) { if (null == this.sensor) return; bool depthReceived = false; using (DepthImageFrame depthFrame = e.OpenDepthImageFrame()) { if (null != depthFrame) { // Copy the pixel data from the image to a temporary array depthFrame.CopyDepthImagePixelDataTo(this.depthPixels); depthReceived = true; } } if (true == depthReceived) { // loop over each row and column of the depth for (int y = 0; y &lt; this.depthHeight; ++y) { for (int x = 0; x &lt; this.depthWidth; ++x) { // calculate index into depth array int depthIndex = x + (y * this.depthWidth); // extract the given index DepthImagePixel depthPixel = this.depthPixels[depthIndex]; Debug.WriteLine("Depth at [" + x + ", " + y + "] is: " + depthPixel.Depth); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload