Share via


DepthImageFrame.CopyPixelDataTo Method (IntPtr, Int32)

Kinect for Windows 1.5, 1.6, 1.7, 1.8

Copies the per-pixel depth data to a pre-allocated array of shorts using the data buffer length. The array size must be equal to the PixelDataLength property.

Syntax

public void CopyPixelDataTo (
         IntPtr pixelData,
         int pixelDataLength
)

Parameters

  • pixelData
    Type: IntPtr
    An array of shorts to receive the pixel data.
  • pixelDataLength
    Type: Int32
    The number of pixels that matches the value of the PixelDataLength property.

Remarks

Each pixel of depth data is stored in a short; therefore the array in this method is an array of shorts. Here's an example:

  // For depth data
  //frame = DepthImageFrame
  IntPtr pixelData = Marshal.AllocHGlobal(sizeof(short) * frame.PixelDataLength);
  try
  {
    frame.CopyPixelDataTo(pixelData, frame.PixelDataLength);
  }
  finally
  {
    if (pixelData != IntPtr.Zero) Marshal.FreeHGlobal(pixelData);
  }
    

Requirements

Namespace: Microsoft.Kinect

Assembly: Microsoft.Kinect (in microsoft.kinect.dll)

See Also

Reference

DepthImageFrame Class
DepthImageFrame Members
Microsoft.Kinect Namespace