/// <summary>
        /// See description in Condition class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            // Calculate vector between Hip center and ShoulderCenter
            Vector3D Vector_ShoulderC_HipC = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.HipCenter].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.HipCenter].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.HipCenter].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.Z);

            // Calculate vector between Shoulder center and hands
            Vector3D Vector_ShoulderC_HandR = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.Z);

            Vector3D Vector_ShoulderC_HandL = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderCenter].Position.Z);

            // Calculate vector between Shoulder, elbow and hand right
            Vector3D Vector_ElbowR_ShoulderR = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderRight].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderRight].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderRight].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Z);

            Vector3D Vector_ElbowR_HandR = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Z);

            // Calculate vector between Shoulder, elbow and hand left
            Vector3D Vector_ElbowL_ShoulderL = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderLeft].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderLeft].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderLeft].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Z);

            Vector3D Vector_ElbowL_HandL = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Z);

            // Calculate angle
            double angleBetweenShoulderC_HandL = Vector3D.AngleBetween(Vector_ShoulderC_HipC, Vector_ShoulderC_HandL);
            double angleBetweenShoulderC_HandR = Vector3D.AngleBetween(Vector_ShoulderC_HipC, Vector_ShoulderC_HandR);

            double angleBetweenShoulderR_HandR = Vector3D.AngleBetween(Vector_ElbowL_HandL, Vector_ElbowL_ShoulderL);
            double angleBetweenShoulderL_HandL = Vector3D.AngleBetween(Vector_ElbowR_HandR, Vector_ElbowR_ShoulderR);

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

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

            // Speed Condition
            if (handLeftVelocity > PropertiesPluginKinect.Instance.PostureLowerBoundForVelocity || handRightVelocity > PropertiesPluginKinect.Instance.PostureLowerBoundForVelocity)
            {
                Reset();
            }
            // Condition : Angle between HandLeft/ShoulderCenter/HipCenter = 45° && Angle between HandRight/ShoulderCenter/HipCenter < 30° && arms extended (mirror effect works)
            else if ((((angleBetweenShoulderC_HandL <= (PropertiesPluginKinect.Instance.HomeAngleShoulderCenterHandLarge + PropertiesPluginKinect.Instance.HomeAngleThreshold) && angleBetweenShoulderC_HandL >= (PropertiesPluginKinect.Instance.HomeAngleShoulderCenterHandLarge - PropertiesPluginKinect.Instance.HomeAngleThreshold))
                && (angleBetweenShoulderC_HandR <= PropertiesPluginKinect.Instance.HomeAngleShoulderCenterHandSmall))
                    || (((angleBetweenShoulderC_HandR <= (PropertiesPluginKinect.Instance.HomeAngleShoulderCenterHandLarge + PropertiesPluginKinect.Instance.HomeAngleThreshold) && angleBetweenShoulderC_HandR >= (PropertiesPluginKinect.Instance.HomeAngleShoulderCenterHandLarge - PropertiesPluginKinect.Instance.HomeAngleThreshold))
                && (angleBetweenShoulderC_HandL <= PropertiesPluginKinect.Instance.HomeAngleShoulderCenterHandSmall))))
                && (angleBetweenShoulderR_HandR <= (PropertiesPluginKinect.Instance.HomeAngleShoulderElbowHand + PropertiesPluginKinect.Instance.PostureAngleTresholdShoulderElBowHand) && angleBetweenShoulderR_HandR >= (PropertiesPluginKinect.Instance.HomeAngleShoulderElbowHand - PropertiesPluginKinect.Instance.PostureAngleTresholdShoulderElBowHand))
                && (angleBetweenShoulderL_HandL <= (PropertiesPluginKinect.Instance.HomeAngleShoulderElbowHand + PropertiesPluginKinect.Instance.PostureAngleTresholdShoulderElBowHand) && angleBetweenShoulderL_HandL >= (PropertiesPluginKinect.Instance.HomeAngleShoulderElbowHand - PropertiesPluginKinect.Instance.PostureAngleTresholdShoulderElBowHand)))
            {
                // Posture Home is complete
                if (m_nIndex > PropertiesPluginKinect.Instance.HomeLowerBoundForSuccess)
                {
                    // Notify the posture Home is detected
                    FireSucceeded(this, new SuccessGestureEventArgs
                    {
                        Gesture = EnumGesture.GESTURE_NONE,
                        Posture = EnumPosture.POSTURE_HOME
                    });
                    m_nIndex = 0;
                    m_frameInitCounter = 0;
                }
                else
                {
                    // Posture Home in initialization
                    if (m_frameInitCounter < PropertiesPluginKinect.Instance.PostureNumberFrameInitialisation)
                    {
                        m_frameInitCounter++;
                        // If initialization is complete
                        if (m_frameInitCounter == PropertiesPluginKinect.Instance.PostureNumberFrameInitialisation)
                        {
                            // Notify the posture Home is begin
                            RaiseGestureBegining(this, new BeginGestureEventArgs
                            {
                                Gesture = EnumGesture.GESTURE_NONE,
                                Posture = EnumPosture.POSTURE_HOME
                            });
                            m_GestureBegin = true;
                        }
                    }
                    // Step successful, waiting for next
                    else
                    {
                        m_nIndex++;
                        // Notify posture Home progress
                        RaiseGestureProgressed(this, new ProgressGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_NONE,
                            Posture = EnumPosture.POSTURE_HOME,
                            Percent = ((float)m_nIndex/(float)PropertiesPluginKinect.Instance.HomeLowerBoundForSuccess)*100
                        });
                    }
                }
            }
            // Posture is broken
            else
            {
                Reset();
            }
        }
Example #2
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);
Example #3
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 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++;
                    }
                }
            }
        }
Example #4
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());
 }
        /// <summary>
        /// See description in Condition class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Check(object sender, NewSkeletonEventArgs e)
        {
            // Calculate vector between Shoulder, elbow and hand right
            Vector3D Vector_ElbowR_ShoulderR = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderRight].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderRight].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderRight].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Z);

            Vector3D Vector_ElbowR_HandR = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristRight].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowRight].Position.Z);

            // Calculate vector between Shoulder, elbow and hand left
            Vector3D Vector_ElbowL_ShoulderL = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderLeft].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderLeft].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.ShoulderLeft].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Z);

            Vector3D Vector_ElbowL_HandL = new Vector3D(
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.X - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.X,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.Y - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Y,
                e.m_refSkeletonData.refSkeleton.Joints[JointType.WristLeft].Position.Z - e.m_refSkeletonData.refSkeleton.Joints[JointType.ElbowLeft].Position.Z);

            // Calculate angle
            double angleBetweenShoulderR_HandR = Vector3D.AngleBetween(Vector_ElbowL_HandL, Vector_ElbowL_ShoulderL);
            double angleBetweenShoulderL_HandL = Vector3D.AngleBetween(Vector_ElbowR_HandR, Vector_ElbowR_ShoulderR);

            // Relative position between ElbawLeft and WristLeft
            List<EnumKinectDirectionGesture> handLeftToElbowLeftOrientation = m_refChecker.GetRelativePosition(JointType.ElbowLeft, JointType.WristLeft).ToList();

            // Relative position between ElbowRight and WristRight
            List<EnumKinectDirectionGesture> handRightToElbowRightOrientation = m_refChecker.GetRelativePosition(JointType.ElbowRight, JointType.WristRight).ToList();

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

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

            // Speed Condition
            if (handLeftVelocity > PropertiesPluginKinect.Instance.PostureLowerBoundForVelocity || handRightVelocity > PropertiesPluginKinect.Instance.PostureLowerBoundForVelocity)
            {
                Reset();
            }
            // Condition : Angle between HandLeft/ElbowLeft/ShoulderLeft = 90° && Angle between HandRight/ElbowRight/ShoulderRight = 90° && hands below elbows
            else if ((angleBetweenShoulderR_HandR <= (PropertiesPluginKinect.Instance.WaitAngleShoulderElbowHand + PropertiesPluginKinect.Instance.WaitAngleThreshold) && angleBetweenShoulderR_HandR >= (PropertiesPluginKinect.Instance.WaitAngleShoulderElbowHand - PropertiesPluginKinect.Instance.WaitAngleThreshold))
                && (angleBetweenShoulderL_HandL <= (PropertiesPluginKinect.Instance.WaitAngleShoulderElbowHand + PropertiesPluginKinect.Instance.WaitAngleThreshold) && angleBetweenShoulderL_HandL >= (PropertiesPluginKinect.Instance.WaitAngleShoulderElbowHand - PropertiesPluginKinect.Instance.WaitAngleThreshold))
                && (handLeftToElbowLeftOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_DOWNWARD))
                && (handRightToElbowRightOrientation.Contains(EnumKinectDirectionGesture.KINECT_DIRECTION_DOWNWARD)))
            {
                // Posture Wait is complete
                if (m_nIndex > PropertiesPluginKinect.Instance.WaitLowerBoundForSuccess)
                {
                    // Notify the posture Wait is detected
                    FireSucceeded(this, new SuccessGestureEventArgs
                    {
                        Gesture = EnumGesture.GESTURE_NONE,
                        Posture = EnumPosture.POSTURE_WAIT
                    });
                    m_nIndex = 0;
                    m_frameInitCounter = 0;
                }
                else
                {
                    // Posture Wait in initialization
                    if (m_frameInitCounter < PropertiesPluginKinect.Instance.PostureNumberFrameInitialisation)
                    {
                        m_frameInitCounter++;
                        // If initialization  is complete
                        if (m_frameInitCounter == PropertiesPluginKinect.Instance.PostureNumberFrameInitialisation)
                        {
                            // Notify the posture Wait is begin
                            RaiseGestureBegining(this, new BeginGestureEventArgs
                            {
                                Gesture = EnumGesture.GESTURE_NONE,
                                Posture = EnumPosture.POSTURE_WAIT
                            });
                            m_GestureBegin = true;
                        }
                    }
                    // Step successful, waiting for next
                    else
                    {
                        m_nIndex++;
                        // Notify posture Wait progress
                        RaiseGestureProgressed(this, new ProgressGestureEventArgs
                        {
                            Gesture = EnumGesture.GESTURE_NONE,
                            Posture = EnumPosture.POSTURE_WAIT,
                            Percent = ((float)m_nIndex / (float)PropertiesPluginKinect.Instance.WaitLowerBoundForSuccess) * 100
                        });
                    }
                }
            }
            // Posture is broken
            else
            {
                Reset();
            }
        }
Example #6
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++;
                    }
                }
            }
        }
Example #7
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 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++;
                    }
                }

            }
        }
Example #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++;
                    }
                }
            }
        }