Skeleton Basics-WPF C# Sample

Kinect for Windows 1.5, 1.6, 1.7, 1.8


When you run this sample, you see the following:

  • Skeleton tracking for up to two players standing in front of the Kinect; 20 joints per skeleton are rendered.
  • A checkbox for seated mode. If you select this, you will see skeleton tracking for up to two players while seated; 10 joints per skeleton are rendered.
The Sample Uses the Following APIsTo Do This
KinectSensor.KinectSensors PropertyGet the Kinect sensors that are plugged in and ready for use.
SkeletonStream.Enable MethodEnable the skeleton stream.
SkeletonFrame.SkeletonArrayLength PropertySpecify the length of the array of Skeleton classes when you allocate memory to store the skeleton stream data from the Kinect.
KinectSensor.Start Method and KinectSensor.Stop MethodStart or stop streaming data.
KinectSensor.SkeletonFrameReady EventAdd an event handler for the skeleton data. The sensor will signal the event handler when each new frame of skeleton data is ready.
SkeletonFrameReadyEventArgs.OpenSkeletonFrame MethodGet a frame of skeleton data in the event handler.
SkeletonFrame.CopySkeletonDataTo MethodCopy a frame of skeleton data to the pre-allocated array of Skeletons.
SkeletonTrackingState EnumerationFor each frame of skeleton data, use the enumeration value to distinguish a fully tracked skeleton (SkeletonTrackingState.Tracked) from a skeleton that is tracked with position data only (SkeletonTrackingState.PositionOnlyTracked).
JointType EnumerationDraw a skeleton by drawing the bones that make up the skeleton. For each skeleton, use this enumeration to identify each bone from the two joints that are the endpoints of the bone. For instance, use the head joint (JointType.Head) and the shoulder center joint (JointType.ShoulderCenter) to identify the bone between the head and the center of the shoulders.
Skeleton.Joints PropertyUse the joints collection to walk through a list of joints in a skeleton.
CoordinateMapper.MapSkeletonPointToDepthPoint MethodConvert points from skeleton space to depth space so you can identify their position on screen.
SkeletonStream.TrackingMode PropertyCheck the depth mode to distinguish between default depth (SkeletonTrackingState.Default) and near mode (SkeletonTrackingState.Seated).

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