Esempio n. 1
0
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            checker.GetAbsoluteMovement(JointType.HandRight);
            _handToHeadDirections = checker.GetRelativePosition(JointType.ShoulderCenter, JointType.HandRight).ToList();
            // Prüfe ob Handbewegung nach links abläuft und ob sich die Hand über dem Kopf befindet
            double handspeed = checker.GetAbsoluteVelocity(JointType.HandRight);
            //Debug.WriteLine(handspeed);
            // min required speed
            if (handspeed < 2)
            {
                _index = 0;
            }
            // hand must be right
            if (_index == 0 && _handToHeadDirections.Contains(Direction.Right))
            {
                _index = 1;
            }
            // hand is on top
            else if (_index == 1 && _handToHeadDirections.Contains(Direction.Upward))
            {
                _index = 2;
            }
            //hand is left
            else if (_index == 2 && _handToHeadDirections.Contains(Direction.Left))
            {
                FireSucceeded(this, null);
                //Debug.WriteLine("triggered" + e.Skeleton.Timestamp);
                _index = 0;
                //if (index >= LOWER_BOUND_FOR_SUCCESS)
                //{
                //    fireSucceeded(this, null);
                //}

            }
        }
Esempio n. 2
0
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            //rightHandDirections = checker.GetAbsoluteMovement(JointType.HandRight);
            _handToHeadDirections = checker.GetRelativePosition(JointType.ShoulderCenter, JointType.HandRight).ToList();
            double handspeed = checker.GetAbsoluteVelocity(JointType.HandRight);
            //Debug.WriteLine(handspeed);
            // min required speed
            if (handspeed < 2)
            {
                _index = 0;
            }
            // hand must be left
            if (_index == 0 && _handToHeadDirections.Contains(Direction.Right))
            {
                _index = 1;
            }
                // hand is on top
            else if (_index == 1 && _handToHeadDirections.Contains(Direction.Upward))
            {
                _index = 2;
            }
                //hand is right
            else if (_index == 2 && _handToHeadDirections.Contains(Direction.Right))
            {
                FireSucceeded(this, null);
                //Debug.WriteLine("triggered");
                _index = 0;
                //if (index >= LOWER_BOUND_FOR_SUCCESS)
                //{
                //    fireSucceeded(this, null);
                //}

            }
        }
Esempio n. 3
0
 protected override void Check(object sender, NewSkeletonEventArgs e)
 {
     List<Direction> handToHipOrientation = _checker.GetRelativePosition(JointType.HipCenter, _hand).ToList();
     List<Direction> handToShoulderOrientation = _checker.GetRelativePosition(JointType.ShoulderCenter, _hand).ToList();
     List<Direction> handMovement = _checker.GetAbsoluteMovement(_hand).ToList();
     double handVelocity = _checker.GetRelativeVelocity(JointType.HipCenter,_hand);
     if (handVelocity < LowerBoundForVelocity)
     {
         Reset();
     }
         // hand is in front of the body and between hip and shoulders
     else if (handToHipOrientation.Contains(Direction.Forward)
        // && handToHipOrientation.Contains(Direction.Upward)
         && handToShoulderOrientation.Contains(Direction.Downward))
     {
         // movement did not start yet, initializing
         if (_direction == Direction.None)
         {
             // left or right movement is prefered
             if (handMovement.Contains(Direction.Left))
             {
                 _direction = Direction.Left;
             }
             else if (handMovement.Contains(Direction.Right))
             {
                 _direction = Direction.Right;
             }
             else
             {
                 // take other direction
                 //direction = handMovement.FirstOrDefault();
             }
         }
         else if (!handMovement.Contains(_direction))
         {
             // direction changed
             Reset();
         }
         else
         {
             if (_index >= LowerBoundForSuccess)
             {
                 _index = 0;
                 FireSucceeded(this, new SwipeGestureEventArgs
                     {
                     Direction = _direction
                 });
                 _direction = Direction.None;
             }
             else
             {
                 // step successful, waiting for next
                 _index++;
             }
         }
     }
 }
Esempio n. 4
0
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            _rightHandToHipOrientation = checker.GetRelativePosition(JointType.HipLeft, JointType.HandRight).ToList();
            _leftHandToHipOrientation = checker.GetRelativePosition(JointType.HipRight, JointType.HandLeft).ToList();
            _rightHandToHeadOrientation = checker.GetRelativePosition(JointType.Head, JointType.HandRight).ToList();
            _leftHandToHeadOrientation = checker.GetRelativePosition(JointType.Head, JointType.HandLeft).ToList();
            _leftHandToRightHandDirection = checker.GetRelativePosition(JointType.HandRight, JointType.HandLeft).ToList();
            _rightHandVelocity = checker.GetRelativeVelocity(JointType.HipCenter, JointType.HandRight);
            _leftHandVelocity = checker.GetRelativeVelocity(JointType.HipCenter, JointType.HandLeft);

            // Both Hands have to be in front of the body, between head and hip, and on their corresponding side
            // but not together or crossed
            if (_rightHandToHipOrientation.Contains(Direction.Forward)
                && _leftHandToHipOrientation.Contains(Direction.Forward)
                && _rightHandToHipOrientation.Contains(Direction.Upward)
                && _leftHandToHipOrientation.Contains(Direction.Upward)
                && _rightHandToHipOrientation.Contains(Direction.Right)
                && _leftHandToHipOrientation.Contains(Direction.Left)
                && _rightHandToHeadOrientation.Contains(Direction.Downward)
                && _leftHandToHeadOrientation.Contains(Direction.Downward)
                && _leftHandToRightHandDirection.Contains(Direction.Left)
                && (_rightHandVelocity <= UpperBoundForVelocity)
                && (_leftHandVelocity <= UpperBoundForVelocity))
            {

                if (_index >= LowerBoundToBegin)
                {
                    FireSucceeded(this, new InternalZoomGestureEventArgs
                        {
                        Gauge = checker.GetDistanceMedian(JointType.HandRight, JointType.HandLeft)
                    });
                    //Console.WriteLine("Success! Velocity: right " + rightHandVelocity + ", left " + leftHandVelocity);
                }
                else
                {
                    _index++;
                    FireTriggered(this, new InternalZoomGestureEventArgs
                    {
                        Gauge = checker.GetDistanceMedian(JointType.HandRight, JointType.HandLeft)
                    });
                }
            }
            else
            {
                _index -= 11;
                if (_index < 0)
                {
                    _index = 0;
                    FireFailed(this, new FailedGestureEventArgs
                        {
                            Condition = this
                        });
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Implement this to check for the fullfillment of a gesture part.
 /// This method is called every time when a person gets a new skeleton.
 /// It is good practice to fire success or fail in the implementation
 /// of this method. For the checking itself you can use information
 /// about the persons skeletons.</summary>
 /// <param name="src">
 /// The object which fired the event. (This is probably the Device class.)</param>
 /// <param name="e">
 /// NewSkeletonEventArgs contains the person which got a new skeleton.</param>
 protected abstract void Check(object src, NewSkeletonEventArgs e);
Esempio n. 6
0
 /// <summary>
 /// Since it's up to the user to override "check" correctly, there's the
 /// possibility that he never triggered an event to make the GestureChecker proceed. 
 /// Therefore we publish that we performed a "check" and consumed time in the 
 /// GestureChecker state machine.</summary>
 /// <param name="src">
 /// The object which fired the event. (This is probably the Device class.)</param>
 /// <param name="args">
 /// NewSkeletonEventArgs contains the person which got a new skeleton.</param>
 private void ExtendedCheck(object src, NewSkeletonEventArgs args)
 {
     Check(src, args);
     OnCheck(this, new EventArgs());
 }