예제 #1
0
 protected override void Check(object src, NewSkeletonEventArgs e)
 {
     if ((Math.Abs(_last.X - 0.0) < EPSILON && Math.Abs(_last.Y - 0.0) < EPSILON && Math.Abs(_last.Z - 0.0) < EPSILON) ||
         (!_dyn && _checker.GetRelativePosition(JointType.Head, JointType.HandLeft).Contains(Direction.Upward)))
     {
         _last = e.Skeleton.GetPosition(JointType.HandRight);
     }
     else
     {
         double xDiff = e.Skeleton.GetPosition(JointType.HandRight).X - _last.X;
         double yDiff = _last.Y - e.Skeleton.GetPosition(JointType.HandRight).Y;
         double zDiff = _last.Z - e.Skeleton.GetPosition(JointType.HandRight).Z;//e.Skeleton.GetPosition(JointType.ShoulderRight).Z - e.Skeleton.GetPosition(JointType.HandRight).Z;
         if (_dyn)
         {
             if ((_last.X < e.Skeleton.GetPosition(JointType.ShoulderRight).X - 0.2 && xDiff > 0.0) ||
                 (_last.X > e.Skeleton.GetPosition(JointType.ShoulderRight).X + 0.4 && xDiff < 0.0))
             {
                 _last.X += (float)(xDiff / ApproximationValue);
             }
             if ((_last.Y < e.Skeleton.GetPosition(JointType.ShoulderRight).Y - 0.3 && yDiff > 0.0) ||
                 (_last.Y > e.Skeleton.GetPosition(JointType.ShoulderRight).Y + 0.3 && yDiff < 0.0))
             {
                 _last.Y += (float)(yDiff / ApproximationValue);
             }
         }
         FireSucceeded(this, new JoystickGestureEventArgs {
             X = xDiff, Y = yDiff, DistToShoulderZ = zDiff
         });
     }
 }
예제 #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, new WaveGestureEventArgs());
                //Debug.WriteLine("triggered");
                _index = 0;
                //if (index >= LOWER_BOUND_FOR_SUCCESS)
                //{
                //    fireSucceeded(this, null);
                //}
            }
        }
예제 #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);

            //Debug.WriteLine(handVelocity);
            //min speed is maintained
            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++;
                    }
                }
            }
        }
        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);
                //}
            }
        }
        protected override void Check(object src, NewSkeletonEventArgs e)
        {
            double dist = person.CurrentSkeleton.GetPosition(JointType.ShoulderCenter).Z - person.CurrentSkeleton.GetPosition(JointType.HandRight).Z;

            FireSucceeded(this, new ThrustGestureEventArgs {
                DistanceToShoulder = dist
            });
        }
예제 #6
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
                    });
                }
            }
        }
예제 #7
0
 protected override void Check(object src, NewSkeletonEventArgs e) // überprüfung bei jedem neuen Skelett
 {
     if (c.GetAbsoluteMovement(JointType.HipCenter)                // Bewegung der Hüfte
         .Contains(Direction.Upward))                              // nach oben?
     {
         FireSucceeded(this, new JumpGestureEventArgs());          // Condition erfolgreich
     }
     else
     {
         FireFailed(this, new FailedGestureEventArgs {
             Condition = this
         });                                                             // nicht erfolgreich
     }
 }
예제 #8
0
        protected override void Check(object src, NewSkeletonEventArgs e)
        {
            double dist = _person.CurrentSkeleton.GetPosition(JointType.FootLeft).Z -
                          _person.CurrentSkeleton.GetPosition(JointType.FootRight).Z;

            if (dist > 0.2)
            {
                FireSucceeded(this, new FootEventArgs {
                    Distance = dist, Foot = Direction.Left
                });
            }
            if (dist < -0.2)
            {
                FireSucceeded(this, new FootEventArgs {
                    Distance = -dist, Foot = Direction.Right
                });
            }
        }
예제 #9
0
        protected override void Check(object src, NewSkeletonEventArgs e)
        {
            List <Direction> leftToRightHand =
                checker.GetRelativePosition(JointType.HandLeft, JointType.HandRight).ToList();
            int dir = 0;

            if (leftToRightHand.Contains(Direction.Upward))
            {
                dir = -1;
            }
            else if (leftToRightHand.Contains(Direction.Downward))
            {
                dir = 1;
            }
            if (!(leftToRightHand.Contains(Direction.Right)))
            {
                dir *= 2;
            }
            FireSucceeded(this, new SteeringGestureEventArgs {
                Direction = dir
            });
        }
예제 #10
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());
 }
예제 #11
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);