Пример #1
0
        public bool IdentifyGesture(UserSkeletonState userState)
        {
            ISkeleton skeleton = userState.Skeleton;

            var rightHand = skeleton.HandRight;
            var leftHand = skeleton.HandLeft;
            var spine = skeleton.Spine;

            return IdentifyGrippedMove(rightHand, leftHand, spine, userState.IsRightHandGripped);
        }
Пример #2
0
        public bool IdentifyGesture(UserSkeletonState userState)
        {
            ISkeleton skeleton = userState.Skeleton;

            var rightHand = skeleton.HandRight;
            var leftHand = skeleton.HandLeft;
            var spine = skeleton.Spine;
            var shoulderCenter = skeleton.ShoulderCenter;
            
            return IdentifyCloseHandAfterTime(rightHand, leftHand, spine, shoulderCenter, userState.IsRightHandGripped, userState.IsLeftHandGripped);
        }
Пример #3
0
        public bool IdentifyGesture(UserSkeletonState userState)
        {
            ISkeleton skeleton = userState.Skeleton;
            var rightHand = skeleton.HandRight;
            var head = skeleton.Head;
            var spine = skeleton.Spine;

            if (State == 1 && 
                GestureUtils.HasMovedToLeft(initialPosition, rightHand.Position, minimumDistanceToTrigger) && 
                GestureUtils.IsHandBelow(rightHand, initialPosition, heightToReset))
            {
                State = 0;
                return true;
            } 
            else if (GestureUtils.IsHandBelow(rightHand, spine))
            {
                State = 0;
                return false;
            }

            if (State == 0 && userState.IsRightHandGripped )
            {
                State = 1;
                initialPosition = rightHand.Position;

                Output.Debug("SwipeLeft", "Identifyed hand above shoudler");

                return false;
            }

            if (State == 1)
            {
                SkeletonPoint nextPoint = rightHand.Position;
                
                if ((GestureUtils.HasMovedToLeft(initialPosition, nextPoint, minimumDistanceToTrigger) && !userState.IsRightHandGripped))
                {
                    State = 0;
                    Output.Debug("SwipeLeft", "Left Gesture Executed");
                    return true;
                }
                else if (!userState.IsRightHandGripped)
                {
                    Output.Debug("SwipeLeft", "Hand Open and not moved to gesture, reseting state");
                    State = 0;
                    return false;
                }

                return false;
            }

            State = 0;
            return false;
        }
 /// <summary>
 /// Find the first gesture that is identified and then stop searching
 /// </summary>
 /// <param name="closestSkeleton"></param>
 protected virtual void VerifyGestures(UserSkeletonState skeletonState)
 {
     foreach (IGestureRecognizer recognizer in gestureRecognizers)
     {
         if (recognizer.IdentifyGesture(skeletonState))
         {
             //Assume the recognizer has a name globally identifiable
             TriggerGestureEvent(recognizer.Name);
             break;
         }
     }
 }
Пример #5
0
        public bool IdentifyGesture(UserSkeletonState userState)
        {
            ISkeleton skeleton = userState.Skeleton;
            var rightHand = skeleton.HandRight;
            var leftHand = skeleton.HandLeft;
            var spine = skeleton.Spine;
            var rightShoulder = skeleton.ShoulderRight;
            var leftShoulder = skeleton.ShoulderLeft;

            if (rightHand.State != JointTrackingState.Tracked || leftHand.State != JointTrackingState.Tracked) return false;

            return IdentifyGesture(rightHand, leftHand, userState.IsRightHandGripped, userState.IsLeftHandGripped, spine, rightShoulder, leftShoulder);
        }
Пример #6
0
        public bool IdentifyGesture(UserSkeletonState userState)
        {
            ISkeleton skeleton = userState.Skeleton;
            var rightHand = skeleton.HandRight;
            var leftHand = skeleton.HandLeft;
            var spine = skeleton.Spine;

            //If hands are to low then reset state
            if (rightHand.Position.Y < spine.Position.Y || leftHand.Position.Y < spine.Position.Y)
            {
                State = 0;
                return false;
            }

            if (State == 2) return false;

            float handsDistance = rightHand.Position.X - leftHand.Position.X;
            handsDistance = Math.Abs(handsDistance);

            if (State == 0)
            {
                //Hands are close, so can start movement
                if ( handsDistance < 0.2)
                {
                    State = 1;
                    Output.Debug("OpenArmsGesture","Hands are close.");
                }
                return false;
            }

            if (State == 1)
            {
                if (handsDistance > 0.8)
                {
                    Output.Debug("OpenArmsGesture", "Arms are open.");
                    State = 2;
                    return true;
                }
            }

            return false;
        }
Пример #7
0
 public SkeletonStateRepository()
 {
     FirstUser = new UserSkeletonState();
 }
Пример #8
0
        private void trackRightHandState(UserSkeletonState skeletonState, InteractionHandPointer handPointer)
        {
            if (handPointer.IsPressed)
            {
                //Do not repeat output
                //if (pressState != 2)
                    //Output.Debug("KinectControl", "Hand Pressed " + handPointer.PressExtent.ToString());

                pressState = 2;
            }
            else
                if (handPointer.PressExtent > 0.5d)
                {
                    //Do not repeat output
                    //if (pressState != 1)
                        //Output.Debug("KinectControl", "Hand Almost Pressed " + handPointer.PressExtent.ToString());

                    pressState = 1;
                }

            if (handPointer.HandEventType == InteractionHandEventType.Grip)
            {
                skeletonState.IsRightHandGripped = true;
            }
            else if (handPointer.HandEventType == InteractionHandEventType.GripRelease)
            {
                skeletonState.IsRightHandGripped = false;
            }
        }
Пример #9
0
 private void trackLeftHandState(UserSkeletonState skeletonState, InteractionHandPointer handPointer)
 {
     if (handPointer.HandEventType == InteractionHandEventType.Grip)
     {
         skeletonState.IsLeftHandGripped = true;
     }
     else if (handPointer.HandEventType == InteractionHandEventType.GripRelease)
     {
         skeletonState.IsLeftHandGripped = false;
     }
 }
        public bool IdentifyGesture(UserSkeletonState userState)
        {
            ISkeleton skeleton = userState.Skeleton;
            var rightHand = skeleton.HandRight;
            var leftHand = skeleton.HandLeft;
            var rightElbow = skeleton.ElbowRight;
            var leftElbow = skeleton.ElbowLeft;
            var rightShoulder = skeleton.ShoulderRight;
            var leftShoulder = skeleton.ShoulderLeft;
            var spine = skeleton.Spine;

            Double distanceRightShoulderAndElbow = KinectUtils.DistanceBetweenSkeletonPoints(rightShoulder.Position,rightElbow.Position);
            distanceRightShoulderAndElbow = Math.Abs(distanceRightShoulderAndElbow);

            Double distanceRightElbowAndHand = KinectUtils.DistanceBetweenSkeletonPoints(rightElbow.Position, rightHand.Position);
            distanceRightElbowAndHand = Math.Abs(distanceRightElbowAndHand);

            Double distanceZRightShoulderAndElbow = rightShoulder.Position.Z - rightElbow.Position.Z;
            distanceZRightShoulderAndElbow = Math.Abs(distanceZRightShoulderAndElbow);

            Double distanceZRightElbowAndHand = rightElbow.Position.Z - rightHand.Position.Z;
            distanceZRightElbowAndHand = Math.Abs(distanceZRightElbowAndHand);

            if (distanceZRightShoulderAndElbow > distanceRightShoulderAndElbow * percentage
                && distanceZRightElbowAndHand > distanceRightElbowAndHand * percentage)
            {
                if (State != 1)
                {
                    State = 1;
                    Output.Debug("OutstretchedArmMovement", "Is Stresched");
                    initialPoint = rightHand.Position;
                    return true;
                }
            }
            else
            {
                State = 0;
                return false;
            }

            if (State == 1)
            {
                double deltaX = rightHand.Position.X - initialPoint.X;
                double deltaY = rightHand.Position.Y - initialPoint.Y;

                if (deltaX > distanceIntervalToMovement)
                {
                    Name = GestureEvents.MOVE_LEFT;
                    initialPoint.X += distanceIntervalToMovement;
                    return true;
                }
                else if (deltaX < -distanceIntervalToMovement)
                {
                    Name = GestureEvents.MOVE_RIGHT;
                    initialPoint.X -= distanceIntervalToMovement;
                    return true;
                }
                else if (deltaY > distanceIntervalToMovement)
                {
                    Name = GestureEvents.MOVE_DOWN;
                    initialPoint.Y += distanceIntervalToMovement;
                    return true;
                }
                else if (deltaY < -distanceIntervalToMovement)
                {
                    Name = GestureEvents.MOVE_UP;
                    initialPoint.Y -= distanceIntervalToMovement;
                    return true;
                }
                else
                {
                    return false;
                }
            }
            
            if (State != 0)
                Output.Debug("OutstretchedArmMovement", "Arm not stretched");

            State = 0;
            return false;
        }