/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="refUser">User data</param>
 /// <param name="hand">Hand treated</param>
 public WaveRightCondition(UserData refUser, JointType hand)
     : base(refUser)
 {
     m_nIndex = 0;
     m_refChecker = new Checker(refUser, PropertiesPluginKinect.Instance.WaveCheckerTolerance);
     m_nTryCondition = 0;
     m_handVelocity = new List<double>();
     m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
     m_refHand = hand;
     m_GestureBegin = false;
 }
        /// <summary>
        /// see description in Condition class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            // Relative position between HipCenter and HandLeft
            List<EnumKinectDirectionGesture> handLeftToHipOrientation = m_refChecker.GetRelativePosition(JointType.HipCenter, JointType.HandLeft).ToList();

            // Relative position between Head and HandLeft
            List<EnumKinectDirectionGesture> handLeftToHeadOrientation = m_refChecker.GetRelativePosition(JointType.Head, JointType.HandLeft).ToList();

            // Movement directions to HandLeft
            List<EnumKinectDirectionGesture> handLeftMovement = m_refChecker.GetAbsoluteMovement(JointType.HandLeft).ToList();

            // Relative velocity of HandLeft
            double handLeftVelocity = m_refChecker.GetRelativeVelocity(JointType.HipCenter, JointType.HandLeft);

            // Relative position between HipCenter and HandRight
            List<EnumKinectDirectionGesture> handRightToHipOrientation = m_refChecker.GetRelativePosition(JointType.HipCenter, JointType.HandRight).ToList();

            // Relative position between Head and HandRight
            List<EnumKinectDirectionGesture> handRightToHeadOrientation = m_refChecker.GetRelativePosition(JointType.Head, JointType.HandRight).ToList();

            // Movement directions to HandRight
            List<EnumKinectDirectionGesture> handRightMovement = m_refChecker.GetAbsoluteMovement(JointType.HandRight).ToList();

            //Relative velocity of HandRight
            double handRightVelocity = m_refChecker.GetRelativeVelocity(JointType.HipCenter, JointType.HandRight);

            // Speed condition
            if (handLeftVelocity < PropertiesPluginKinect.Instance.MinimizeLowerBoundForVelocity || handRightVelocity < PropertiesPluginKinect.Instance.MinimizeLowerBoundForVelocity)
            {
                Reset();
            }
            // Condition : Hand is in front of the body and between HipCenter and Head
            else if (handLeftToHipOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD)
                && handLeftToHeadOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_DOWNWARD)
                && handRightToHipOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD)
                && handRightToHeadOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_DOWNWARD))
            {
                // Movement did not start yet, initializing
                if (m_refLeftDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_NONE && m_refRightDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_NONE)
                {
                    // Condition : Movement direction hand right => left && Movement direction hand left => right
                    if (handRightMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_LEFT) && handLeftMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT))
                    {
                        m_refLeftDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT;
                        m_refRightDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_LEFT;
                        m_GestureBegin = true;
                        // Notify the gesture Minimize is begin
                        RaiseGestureBegining(this, new BeginGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_MINIMIZE,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                    }
                    else
                    {
                        // Take other direction
                        Reset();
                    }
                }
                // Movement direction hand left or right changed
                else if (!handLeftMovement.Contains(m_refLeftDirection) || !handRightMovement.Contains(m_refRightDirection))
                {
                    Reset();
                }
                else
                {
                    // Gesture Minimize is complete
                    if (m_nIndex >= PropertiesPluginKinect.Instance.MinimizeLowerBoundForSuccess)
                    {
                        // Notify gesture Minimize is detected
                        FireSucceeded(this, new SuccessGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_MINIMIZE,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                        IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Condition Maximize complete", false);

                        m_nIndex = 0;

                        m_refLeftDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
                        m_refRightDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
                    }
                    // Step successful, waiting for next
                    else
                    {
                        m_nIndex++;
                    }
                }
            }
        }
        /// <summary>
        /// Restart detecting
        /// </summary>
        private void Reset()
        {
            // If gesture begin, notify gesture is end
            if (m_GestureBegin)
            {
                m_GestureBegin = false;
                RaiseGestureEnded(this, new EndGestureEventArgs
                {
                    Gesture = EnumGesture.GESTURE_MINIMIZE,
                    Posture = EnumPosture.POSTURE_NONE
                });
            }

            m_nIndex = 0;

            m_refLeftDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
            m_refRightDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;

            FireFailed(this, new FailedGestureEventArgs
            {
                refCondition = this
            });
        }
Exemple #4
0
        /// <summary>
        /// See description in Condition class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            // Relative position between HipCenter and Hand
            List<EnumKinectDirectionGesture> handToHipOrientation = m_refChecker.GetRelativePosition(JointType.HipCenter, m_refHand).ToList();

            // Relative position between Head and Hand
            List<EnumKinectDirectionGesture> handToHeadOrientation = m_refChecker.GetRelativePosition(JointType.Head, m_refHand).ToList();

            // Movement directions to hand
            List<EnumKinectDirectionGesture> handMovement = m_refChecker.GetAbsoluteMovement(m_refHand).ToList();

            // Relative velocity of hand
            m_handVelocity.Add(m_refChecker.GetRelativeVelocity(JointType.HipCenter, m_refHand));
            double handVelocity = m_refChecker.GetRelativeVelocity(JointType.HipCenter, m_refHand);

            if (m_refHand == JointType.HandRight)
            {
                IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Swipe Left speed = " + handVelocity, false);
            }
            else if (m_refHand == JointType.HandLeft)
            {
                IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Swipe Right speed = " + handVelocity, false);
            }

            // Speed condition
            if (handVelocity < PropertiesPluginKinect.Instance.SwipeLowerBoundForVelocity)
            {
                Reset();
            }
            // Condition : Hand is in front of the body and between HipCenter and Head
            else if (handToHipOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD)
                && handToHeadOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_DOWNWARD))
            {
                // Movement did not start yet, initializing
                if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_NONE)
                {
                    // Condition : Hand is right && Movement direction hand => left
                    if (PropertiesPluginKinect.Instance.EnableGestureSwipeLeft &&
                        handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_LEFT)
                        && !handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_UPWARD))
                    {
                        m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_LEFT;
                        m_GestureBegin = true;
                        // Notify the gesture swipe left is begin
                        RaiseGestureBegining(this, new BeginGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_SWIPE_LEFT,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                    }
                    // Condition : Hand is left && Movement direction hand => right
                    else if (PropertiesPluginKinect.Instance.EnableGestureSwipeRight &&
                        handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT) &&
                        !handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_UPWARD))
                    {
                        m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT;
                        m_GestureBegin = true;
                        // Notify the gesture swipe right is begin
                        RaiseGestureBegining(this, new BeginGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_SWIPE_RIGHT,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                    }
                    else
                    {
                        // Take other direction
                        Reset();
                    }
                }
                // Movement direction hand changed
                else if (!handMovement.Contains(m_refDirection))
                {
                    Reset();
                }
                else
                {
                    // Gesture Swipe is complete
                    if (m_nIndex >= PropertiesPluginKinect.Instance.SwipeLowerBoundForSuccess)
                    {
                        // Calculate mean velocity
                        double meanVelocity = 0;
                        foreach (double velocity in m_handVelocity)
                        {
                            meanVelocity += velocity;
                        }

                        meanVelocity = meanVelocity / (double)m_handVelocity.Count;

                        IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Mean Velocity = " + meanVelocity, false);

                        if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_LEFT)
                        {
                            // Notify Gesture Swipe Left is detected
                            FireSucceeded(this, new SuccessGestureEventArgs
                            {
                                Gesture = EnumGesture.GESTURE_SWIPE_LEFT,
                                Posture = EnumPosture.POSTURE_NONE
                            });
                            IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Condition Swipe Left complete", false);
                        }
                        else if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT)
                        {
                            // Notify Gesture Swipe Right is detected
                            FireSucceeded(this, new SuccessGestureEventArgs
                            {
                                Gesture = EnumGesture.GESTURE_SWIPE_RIGHT,
                                Posture = EnumPosture.POSTURE_NONE
                            });
                            IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Condition Swipe Right complete", false);
                        }

                        m_nIndex = 0;

                        m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
                    }
                    // Step successful, waiting for next
                    else
                    {
                        m_nIndex++;
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Restart detecting
        /// </summary>
        private void Reset()
        {
            // If gesture begin, notify gesture is end
            if (m_GestureBegin)
            {
                m_GestureBegin = false;
                if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_LEFT)
                {
                    RaiseGestureEnded(this, new EndGestureEventArgs
                    {
                        Gesture = EnumGesture.GESTURE_SWIPE_LEFT,
                        Posture = EnumPosture.POSTURE_NONE
                    });
                }
                else if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT)
                {
                    RaiseGestureEnded(this, new EndGestureEventArgs
                    {
                        Gesture = EnumGesture.GESTURE_SWIPE_RIGHT,
                        Posture = EnumPosture.POSTURE_NONE
                    });
                }
            }

            m_nIndex = 0;
            m_handVelocity.Clear();
            m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
            FireFailed(this, new FailedGestureEventArgs
            {
                refCondition = this
            });
        }
        /// <summary>
        /// See description in Condition class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            // Relative position between Shoulder and hand
            List<EnumKinectDirectionGesture> handToShoulderDirections = m_refChecker.GetRelativePosition(JointType.ShoulderRight, m_refHand).ToList();

            // Relative position between HipCenter and hand
            List<EnumKinectDirectionGesture> handToHipOrientation = m_refChecker.GetRelativePosition(JointType.HipCenter, m_refHand).ToList();

            // Movement directions of hand
            List<EnumKinectDirectionGesture> handMovement = m_refChecker.GetAbsoluteMovement(m_refHand).ToList();

            // Relative velocity of hand
            m_handVelocity.Add(m_refChecker.GetRelativeVelocity(JointType.HipCenter, m_refHand));
            double handspeed = m_refChecker.GetRelativeVelocity(JointType.HipCenter, m_refHand);

            IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Wave speed = " + handspeed, false);

            // Speed condition
            if (handspeed < PropertiesPluginKinect.Instance.WaveLowerBoundForVelocity)
            {
                Reset();
            }
            // Condition : Hand is upward the shoulder
            else if (/*handToHipOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD)
                && */handToShoulderDirections.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_UPWARD))
            {
                // Movement did not start yet, initializing
                if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_NONE)
                {
                    // Condition : Movement direction hand => right
                    if (handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT) && !handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_UPWARD))
                    {
                        m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_RIGHT;
                        m_GestureBegin = true;
                        // Notify the gesture Wave is begin
                        RaiseGestureBegining(this, new BeginGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_WAVE,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                    }
                    else
                    {
                        // Take other direction
                        Reset();
                    }
                }
                // Movement direction hand changed
                else if (!handMovement.Contains(m_refDirection))
                {
                    Reset();
                }
                else
                {
                    // Gesture Wave Right is complete
                    if (m_nIndex >= PropertiesPluginKinect.Instance.WaveLowerBoundForSuccess)
                    {
                        // Calculate mean velocity
                        double meanVelocity = 0;
                        foreach (double velocity in m_handVelocity)
                        {
                            meanVelocity += velocity;
                        }

                        meanVelocity = meanVelocity / (double)m_handVelocity.Count;

                        IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Mean Velocity = " + meanVelocity, false);

                        // Notify Condition Wave right is complete
                        FireSucceeded(this, new SuccessGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_WAVE,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                        IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Condition Wave Right complete", false);

                        m_nIndex = 0;

                        m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
                    }
                    // Step succesful, waiting for next
                    else
                    {
                        m_nIndex++;
                    }
                }

            }
        }
        /// <summary>
        /// Restart detecting
        /// </summary>
        private void Reset()
        {
            // If gesture begin, notify is end
            if (m_GestureBegin)
            {
                m_GestureBegin = false;
                RaiseGestureEnded(this, new EndGestureEventArgs
                {
                    Gesture = EnumGesture.GESTURE_WAVE,
                    Posture = EnumPosture.POSTURE_NONE
                });
            }
            m_nIndex = 0;
            m_handVelocity.Clear();

            m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
            if (m_nTryCondition >= 10)
            {
                m_nTryCondition = 0;
                FireFailed(this, new FailedGestureEventArgs
                {
                    refCondition = this
                });
            }
            else
            {
                m_nTryCondition++;
            }
        }
Exemple #8
0
        /// <summary>
        /// See description in Condition class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            // Relative position between HipCenter and Hand
            List<EnumKinectDirectionGesture> handToHipOrientation = m_refChecker.GetRelativePosition(JointType.HipCenter, m_refHand).ToList();

            // Movement directions to hand
            List<EnumKinectDirectionGesture> handMovement = m_refChecker.GetAbsoluteMovement(m_refHand).ToList();

            // Relative velocity of hand
            m_handVelocity.Add(m_refChecker.GetRelativeVelocity(JointType.HipCenter, m_refHand));
            double handVelocity = m_refChecker.GetRelativeVelocity(JointType.HipCenter, m_refHand);

            if (m_refHand == JointType.HandRight)
            {
                IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Push speed = " + handVelocity, false);
            }

            // Speed condition
            if (handVelocity < PropertiesPluginKinect.Instance.PushLowerBoundForVelocity)
            {
                Reset();
            }
            // Condition : Hand is in front of the body
            else if (handToHipOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD)
                && handToHipOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_UPWARD))
            {
                // Movement did not start yet, initializing
                if (m_refDirection == EnumKinectDirectionGesture.KINECT_DIRECTION_NONE)
                {
                    // Condition : Movement direction hand => forward
                    if (handMovement.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD))
                    {
                        m_GestureBegin = true;

                        m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_FORWARD;

                        // Save the start hand position
                        m_refStartPoint = new Point3D(
                                e.m_refSkeletonData.GetJointPosition(m_refHand).X,
                                e.m_refSkeletonData.GetJointPosition(m_refHand).Y,
                                e.m_refSkeletonData.GetJointPosition(m_refHand).Z);

                        // Notify the gesture Push is begin
                        RaiseGestureBegining(this, new BeginGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_PUSH,
                            Posture = EnumPosture.POSTURE_NONE
                        });
                    }
                    else
                    {
                        // Take other direction
                        Reset();
                    }
                }
                // Movement direction hand changed
                else if (!handMovement.Contains(m_refDirection))
                {
                    Reset();
                }
                else
                {
                    // Gesture Push is complete
                    if (m_nIndex >= PropertiesPluginKinect.Instance.PushLowerBoundForSuccess)
                    {
                        // Get the end hand position
                        Point3D endPoint = new Point3D(
                                e.m_refSkeletonData.GetJointPosition(m_refHand).X,
                                e.m_refSkeletonData.GetJointPosition(m_refHand).Y,
                                e.m_refSkeletonData.GetJointPosition(m_refHand).Z);

                        // difference between the start and end point
                        double dx = endPoint.X - m_refStartPoint.X;
                        double dy = endPoint.Y - m_refStartPoint.Y;
                        double dz = endPoint.Z - m_refStartPoint.Z;

                        // Condition : Square 15cm aroud the start position in X-Axis and Y-Axis && the hand forward at least 10cm in Z-Axis
                        if (Math.Abs(dx) < 0.15 && Math.Abs(dy) < 0.15 && Math.Abs(dz) > 0.1)
                        {
                            // Calculate mean velocity
                            double meanVelocity = 0;
                            foreach (double velocity in m_handVelocity)
                            {
                                meanVelocity += velocity;
                            }

                            meanVelocity = meanVelocity / (double)m_handVelocity.Count;

                            IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Mean Velocity = " + meanVelocity, false);

                            // Notify Gesture Push is detected
                            FireSucceeded(this, new SuccessGestureEventArgs
                            {
                                Gesture = EnumGesture.GESTURE_PUSH,
                                Posture = EnumPosture.POSTURE_NONE
                            });

                            IntuiLab.Kinect.Utils.DebugLog.DebugTraceLog("Condition Push complete", false);

                            m_nIndex = 0;
                            m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;
                        }
                        else
                        {
                            Reset();
                        }
                    }
                    // Step successful, waiting for next
                    else
                    {
                        m_nIndex++;
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Restart detecting
        /// </summary>
        private void Reset()
        {
            // If gesture begin, notify gesture is end
            if (m_GestureBegin)
            {
                m_GestureBegin = false;
                RaiseGestureEnded(this, new EndGestureEventArgs
                {
                    Gesture = EnumGesture.GESTURE_PUSH,
                    Posture = EnumPosture.POSTURE_NONE
                });
            }

            m_nIndex = 0;
            m_refDirection = EnumKinectDirectionGesture.KINECT_DIRECTION_NONE;

            m_refStartPoint = new Point3D();
            m_handVelocity.Clear();

            FireFailed(this, new FailedGestureEventArgs
            {
                refCondition = this
            });
        }