/// <summary> /// This event fires when a *tracked* Body frame is available /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Viewer_BodyTracked(object sender, BodyTrackedEventArgs e) { // Get the Z position of the hand and spine var hand = e.Body.Joints[JointType.HandRight].Position.Z + 1.0f; // Add 1 to avoid the negative number problem var spine = e.Body.Joints[JointType.SpineMid].Position.Z + 1.0f; // if the hand is at least .3 meters in front of the spine... if (Math.Abs(hand - spine) > .3) // turn the background red Background = Brushes.Red; else Background = Brushes.White; }
/// <summary> /// Local method for firing the BodyTracked event /// </summary> /// <param name="e"></param> protected virtual void OnBodyTracked(BodyTrackedEventArgs e) { if (BodyTracked != null) BodyTracked(this, e); }