/// <summary> /// launch the update on all gestures relying on skeleton datas /// </summary> /// <param name="skel">the skeleton datas</param> /// <param name="gesture_context">the context when the gesture is triggered</param> public void UpdateAllGestures(Skeleton skel, ContextGesture gesture_context) { foreach (BodyGesture bg in this.gestures) { bg.updateGesture(skel, gesture_context); } }
/// <summary> /// check the state of the gesture compared with the skeleton datas /// </summary> /// <param name="skel">the skeleton datas</param> /// <param name="gesture_context">the gesture context</param> public void updateGesture(Skeleton skel, ContextGesture gesture_context) { //are we in pause ? if (this.paused) { if (this.frameCount >= this.pausedFrameCount) { this.paused = false; } this.frameCount++; } //get the result GesturePartResult result = this.segments[this.currentGesturePart].checkGesture(skel); if (result == GesturePartResult.SUCCESS) { if (this.currentGesturePart + 1 < this.segments.Length) { //search for to next part this.currentGesturePart++; this.frameCount = 0; this.pausedFrameCount = 25; this.paused = true; } else { //gesture had been recognised if (this.GestureRecognised != null) { //use the method GestureDatas e = new GestureDatas(new BodyGestureEvent(name), null, gesture_context); this.GestureRecognised(this, new GestureEventArgs(EventType.BODY, e, Helper.GetTimeStamp())); //reset this.reset(); } } } else if (result == GesturePartResult.FAIL || this.frameCount >= 50) { this.currentGesturePart = 0; this.frameCount = 0; this.pausedFrameCount = 5; this.paused = true; } else { this.frameCount++; this.pausedFrameCount = 25; this.paused = true; } }
/// <summary> /// default constructor /// </summary> /// <param name="b">a bodygesture event</param> /// <param name="h">a handgesture event</param> /// <param name="c">the context of the gesture</param> public GestureDatas(BodyGestureEvent b = null, HandGestureDatas h = null, ContextGesture c =null) { this.bodyGestureEventData = b; this.handGestureEventData = h; this.contextGestureDatas = c; }