Face Tracking Basics-WPF C# Sample

Kinect for Windows 1.5, 1.6, 1.7, 1.8


When you run this sample, you see the following:

  • The scene in front of the camera is rendered.
  • Wave your hands to engage skeleton tracking.
  • Once your skeleton is tracked, a grid is rendered over the face. The grid tracks the movement of the player's face through the scene.
The Sample Uses the Following APIsTo Do This
KinectSensor.Start Method and KinectSensor.Stop MethodStart or stop streaming data.
ColorImageStream.Enable Method and ColorImageFormat.RgbResolution640x480Fps30 enumeration valueChoose the color format and enable the sensor to stream out color data.
DepthImageStream.Enable Method and DepthImageFormat.Resolution320x240Fps30 enumeration valueChoose the depth format and enable the sensor to stream out depth data.
DepthImageStream.Range PropertySet the sensor depth to near mode.
SkeletonStream.EnableTrackingInNearRange PropertyEnable skeleton tracking while the depth stream is in near mode.
SkeletonStream.TrackingMode Property and SkeletonTrackingMode.Seated enumeration valueEnable skeleton tracking in seated mode.
SkeletonStream.Enable MethodEnable the sensor to stream out skeleton data.
KinectSensor.AllFramesReady EventAdd an event handler for all the streams. The sensor will signal the event handler when each new frame of color, depth, and skeleton data is ready.
ColorImageFrameReadyEventArgs.OpenColorImageFrame MethodGet a frame of color 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.
Skeleton ClassUse the collection of skeletons to get data for a particular skeleton.
Skeleton.TrackingState Property, SkeletonTrackingState.Tracked and SkeletonTrackingState.PositionOnly enumeration values, Skeleton.TrackingId PropertyDetermine if a skeleton is tracked and get its tracking ID.
SkeletonFaceTracker classA custom class for storing skeleton data and drawing a face grid positioned over a skeleton head.
FaceTrackFrame classA custom class that detects a face based on the Kinect input data, identifies characteristic points and tracks the face as it moves.

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.

Community Additions