/// <summary> /// Constructor /// </summary> public SkeletonTrackingData(ISkeletonData data, Predicate <Joint> jointFilter, TrackingContext context) { this.points = null; this.JointFilter = jointFilter; this.SkeletonData = data; this.Context = context; }
/// <summary> /// Checks if this skeleton is trying to get attention /// </summary> /// <param name="origData">the skeleton data</param> /// <returns>The cue joint id if such is identified, otherwise -1</returns> /// <remarks> /// Joint is considered requiring attention if it's raised at the same /// height as the skeletons head or higher /// </remarks> private int SkeletonNeedsAttention(ISkeletonData origData) { // get the head and the limb raised the highest (as this one has the highest chance // of being raised to draw attention) Joint head = origData.JointAt(JointID.Head); Joint cueJoint = this.GetCandidateCueJoints(origData.Joints).Max <Joint, float>(j => j.Position.Y, (f1, f2) => { return(f1 - f2); }); return((this.IsItCueJoint(cueJoint) && head.Position.Y <= cueJoint.Position.Y) ? (int)cueJoint.ID : RecognitionConstants.InvalidJointId); }
/// <summary> /// Allows individual skeleton tracking. /// </summary> /// <param name="origData">the original skeleton event data</param> /// <returns>true if traversing should continue with next skeleton, otherwise false</returns> protected override bool ProcessSkeleton(ISkeletonData origData) { bool foundSkeleton = false; int cueJointId = this.SkeletonNeedsAttention(origData); if (RecognitionConstants.InvalidJointId != cueJointId) { foundSkeleton = true; base.Context.ActiveSkeleton = origData.TrackingID; base.Context.CurrentCue = (JointID)cueJointId; base.Controller.PerformTransition(FSMEventId.WaitForCommand); } return(!foundSkeleton); }
/// <summary> /// Allows individual skeleton tracking. /// </summary> /// <param name="origData">the original skeleton event data</param> /// <returns>true if traversing should continue with next skeleton, otherwise false</returns> protected override bool ProcessSkeleton(ISkeletonData origData) { if (this.CanHandleFrame) { ArrayList frameBuffer = base.FrameBuffer; // if we record more than max frames, this state should change if (frameBuffer.Count >= base.Context.MaxFrames) { base.Controller.PerformTransition(FSMEventId.GoIdle); } else { // add current skeleton data to recognition buffer SkeletonTrackingData trackingData = new SkeletonTrackingData(origData, base.Context.IsJointTracked, this.Context); frameBuffer.Add(trackingData.DTWData); this.RaiseEvent(this.FrameRecorded); } } // result doesn't matter as this state only handles 1 skeleton at a time return(false); }
/// <summary> /// Allows individual skeleton tracking. /// </summary> /// <param name="origData">the original skeleton event data</param> /// <returns>true if traversing should continue with next skeleton, otherwise false</returns> protected override bool ProcessSkeleton(ISkeletonData origData) { if (this.CanHandleFrame) { IGesture gesture = null; ArrayList frameBuffer = base.FrameBuffer; // handle recognition if we have some sequence already if (frameBuffer.Count > base.Context.MinFrames) { gesture = this.recognizer.Recognize(frameBuffer); if (gesture != null && gesture.Id != GestureId.Unknown) { base.Controller.RaiseGestureRecognizedEvent(new GestureRecognizedEventArgs(gesture, Configuration.Instance.GestureTransitions[new KeyValuePair <FSMStateId, GestureId>(base.Id, gesture.Id)])); this.ResetState(); } // check if current state should be exited (idle or unsuccessful for too long) this.ExitStateOnIdle(); } // maintain buffer size if (frameBuffer.Count > base.Context.MaxFrames) { frameBuffer.RemoveAt(0); } // add current skeleton data to recognition buffer SkeletonTrackingData trackingData = new SkeletonTrackingData(origData, base.Context.IsJointTracked, this.Context); frameBuffer.Add(trackingData.DTWData); } // result doesn't matter as this state only handles 1 skeleton at a time return(false); }
/// <summary> /// Allows individual skeleton tracking. /// </summary> /// <param name="origData">the original skeleton event data</param> /// <returns>true if traversing should continue with next skeleton, otherwise false</returns> protected virtual bool ProcessSkeleton(ISkeletonData origData) { return(false); }