コード例 #1
0
 /// <summary>
 ///  launch the update on all gestures
 /// </summary>
 /// <param name="depthFrame">the depthImageFrame to observe</param>
 public void FindHandGestures(DepthImageFrame depthFrame)
 {
     if (skeleton != null)
     {
         handDetector.SetUp(skeleton, depthFrame);
         foreach (HandType handtype in Enum.GetValues(typeof(HandType)))
         {
             //Only LEFT and RIGHT
             if (handtype != HandType.NULL)
             {
                 result = handDetector.FindHandGesture(handtype);
                 if (!String.IsNullOrEmpty(result))
                 {
                     HandGestureName handGesture = (HandGestureName)Enum.Parse(typeof(HandGestureName), result.ToString());
                     if (this.GestureRecognised != null)
                     {
                         GestureDatas e = new GestureDatas();
                         e.handGestureEventData = new HandGestureDatas(handGesture, handtype);
                         this.GestureRecognised(this, new GestureEventArgs(EventType.HAND, e, Helper.GetTimeStamp()));
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        /// <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;
            }
        }