You can't set a simple boolean for this because the SDK's event driven approach will return 6 skeletal structures even if they are all empty. Using a bit of LINQ and a null check will get you what you are looking for though.
Steps:
- Initialize Kinect (I would use the included KinectSensorChooser for this app WPFViewers) enable and register for the skeletal stream.
- In the skeletal event check to make sure you didn't get a null skeleton collection (it happens)
- Use LINQ to get the first skeleton that has it's tracking property set to tracked. You can also just use a for loop, I just find LINQ to be useful for these types of iteration.
- If your skeleton after the LINQ query is not null do something.
If you are wanting to get this up quick and with some flair you can utilize the sample that is included when you download the SDK Kinect Explorer. There is a skeletal viewer along with KinectSensorChooser that will allow you to have a fully functioning app with very little code.
read more about the Skeletal Viewer included with this sample here
I stumbled a little bit with wether to provide code for this or not. I thought it better to answer this with the logic needed to perform the action rather than the actual code... since you asked :) however, if you want code for this you can either get it from Channel 9's Quickstarts or my book chapter four
Edit (Extending KinectExplorer):
In order to extend KinectExplorer to respond when a skeleton is detected just find the function KinectAllFramesReady in KinectSkeletonViewer.xaml.cs. Inside of this function there is a bool check for haveSkeletonData, this if statement will get called when there is a skeleton present in the viewable frame of the Kinect.
so:
private void KinectAllFramesReady(object sender, AllFramesReadyEventArgs e)
{
//Checking for Skeleton
if (haveSkeletonData)
{
//Do Stuff Here
}
}