Export (0) Print
Expand All
2 out of 7 rated this helpful - Rate this topic

Coordinate Mapping Basics-WPF C# Sample

Kinect for Windows 1.5, 1.6, 1.7, 1.8

Before Kinect for Windows SDK 1.8, this sample was named Green Screen-WPF C# Sample.


When you run this sample, you see the following:

  • A background image.
  • If you move in front of the camera, your body is rendered over the background image. This is done using the depth data to choose the pixel color.
  • Select Near Mode to change the range of the depth data.
  • Click Screenshot to capture the screen and save it in a file.

The Sample Uses the Following APIsTo Do This
KinectSensor.KinectSensors PropertyGet the Kinect sensors that are plugged in and ready for use.
KinectStatus.Connected enumeration valueCheck the sensor to see if it is connected and ready to use.
ColorImageFormat.RgbResolution640x480Fps30 enumeration valueChoose the color stream format including the data type, resolution, and frame rate of the data.
ColorImageStream.Enable MethodEnable the color stream.
DepthImageFormat.Resolution320x240Fps30 enumeration valueChoose the depth stream format including the data type, resolution, and frame rate of the data.
DepthImageStream.Enable MethodEnable the depth stream.
SkeletonStream.Enable MethodEnable the skeleton stream so that you can get the player mask.
ImageStream.FramePixelDataLength PropertySpecify the length of the pixel data buffer when you allocate memory to store the depth stream data from the Kinect.
ImageStream.FrameWidth Property and ImageStream.FrameHeight PropertySpecify the width and height of the WriteableBitmap used to store/render the depth data.
DepthImagePixel StructureCreate a local array for depth data.
KinectSensor.Start Method and KinectSensor.Stop MethodStart or stop streaming data.
KinectSensor.AllFramesReady EventAdd an event handler for all of the streaming data. The sensor will signal the event handler when each new frame of color, depth, and skeleton data is ready.
AllFramesReadyEventArgs.OpenColorImageFrame Method and AllFramesReadyEventArgs.OpenDepthImageFrame MethodGet a frame of color data and a frame of depth data in the event handler.
ColorImageFrame.CopyPixelDataTo MethodCopy a frame of color data to a pre-allocated array, so it can then be written to an optional WriteableBitmap.
DepthImageFrame.CopyPixelDataTo MethodCopy a frame of depth data to a pre-allocated array, so it can then be written to an optional WriteableBitmap.
CoordinateMapper.MapDepthFrameToColorFrame MethodConvert a frame of depth data to a frame of color data.
DepthImagePixel StructureGet the depth of a pixel so that you can extract the player index from the depth data. Use the player index to choose the foreground color data (from the player) or the background color data (from the background image) to save in the optional WriteableBitmap.

To run a sample you must have the Kinect for Windows SDK installed. To compile a sample, you must have the developer toolkit installed. The latest SDK and developer toolkit are available on the developer download page. If you need help installing the toolkit, look on this page: To Install the SDK and Toolkit. The toolkit includes a sample browser, which you can use to launch a sample or download it to your machine. To open the sample browser, click Start > All Programs > Kinect for Windows SDK [version number] > Developer Toolkit Browser.

If you need help loading a sample in Visual Studio or using Visual Studio to compile, run, or debug, see Opening, Building, and Running Samples in Visual Studio.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.