Пример #1
0
        /// <summary>
        /// Callback when a gesture state is modified during operation of the engine 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSynchronizeGesturesState(object sender, SynchronizeGesturesStateEventArgs e)
        {
            switch (e.GestureName)
            {
                case "SwipeLeft":
                    if (!PropertiesPluginKinect.Instance.EnableGestureSwipeLeft)
                    {
                        if (!PropertiesPluginKinect.Instance.EnableGestureSwipeRight && m_refSwipeHandLeftChecker != null && m_refSwipeHandRightChecker != null)
                        {
                            DisableGestureChecker(m_refSwipeHandLeftChecker);
                            DisableGestureChecker(m_refSwipeHandRightChecker);
                        }
                    }
                    else
                    {
                        if (!PropertiesPluginKinect.Instance.EnableGestureSwipeRight)
                        {
                            m_refSwipeHandRightChecker = new SwipeGestureChecker(m_refUser, JointType.HandRight);
                            EnableGestureChecker(m_refSwipeHandRightChecker);

                            m_refSwipeHandLeftChecker = new SwipeGestureChecker(m_refUser, JointType.HandLeft);
                            EnableGestureChecker(m_refSwipeHandLeftChecker);
                        }
                    }
                    break;

                case "SwipeRight":
                    if (!PropertiesPluginKinect.Instance.EnableGestureSwipeRight)
                    {
                        if (!PropertiesPluginKinect.Instance.EnableGestureSwipeLeft && m_refSwipeHandLeftChecker != null && m_refSwipeHandRightChecker != null)
                        {
                            DisableGestureChecker(m_refSwipeHandLeftChecker);
                            DisableGestureChecker(m_refSwipeHandRightChecker);
                        }
                    }
                    else
                    {
                        if (!PropertiesPluginKinect.Instance.EnableGestureSwipeLeft)
                        {
                            m_refSwipeHandRightChecker = new SwipeGestureChecker(m_refUser, JointType.HandRight);
                            EnableGestureChecker(m_refSwipeHandRightChecker);

                            m_refSwipeHandLeftChecker = new SwipeGestureChecker(m_refUser, JointType.HandLeft);
                            EnableGestureChecker(m_refSwipeHandLeftChecker);
                        }
                    }
                    break;

                case "Wave":
                    if (!PropertiesPluginKinect.Instance.EnableGestureWave)
                    {
                        DisableGestureChecker(m_refHandLeftWaveChecker);
                        DisableGestureChecker(m_refHandRightWaveChecker);
                    }
                    else
                    {
                        m_refHandRightWaveChecker = new WaveGestureChecker(m_refUser, JointType.HandRight);
                        EnableGestureChecker(m_refHandLeftWaveChecker);

                        m_refHandLeftWaveChecker = new WaveGestureChecker(m_refUser, JointType.HandLeft);
                        EnableGestureChecker(m_refHandRightWaveChecker);
                    }
                    break;

                case "Grip":
                    if (!PropertiesPluginKinect.Instance.EnableGestureGrip)
                    {
                        // Nothing to do ?
                    }
                    break;
                case "Push":
                    if (!PropertiesPluginKinect.Instance.EnableGesturePush)
                    {
                        DisableGestureChecker(m_refPushLeftHandGestureChecker);
                        DisableGestureChecker(m_refPushRightHandGestureChecker);
                    }
                    else
                    {
                        m_refPushRightHandGestureChecker = new PushGestureChecker(m_refUser, JointType.HandRight);
                        EnableGestureChecker(m_refPushRightHandGestureChecker);

                        m_refPushLeftHandGestureChecker = new PushGestureChecker(m_refUser, JointType.HandLeft);
                        EnableGestureChecker(m_refPushLeftHandGestureChecker);
                    }
                    break;

                case "Maximize":
                    if (!PropertiesPluginKinect.Instance.EnableGestureMaximize)
                    {
                        DisableGestureChecker(m_refMaximizeGestureChecker);
                    }
                    else
                    {
                        m_refMaximizeGestureChecker = new MaximizeGestureChecker(m_refUser);
                        EnableGestureChecker(m_refMaximizeGestureChecker);
                    }
                    break;

                case "Minimize":
                    if (!PropertiesPluginKinect.Instance.EnableGestureMinimize)
                    {
                        DisableGestureChecker(m_refMinimizeGestureChecker);
                    }
                    else
                    {
                        m_refMinimizeGestureChecker = new MinimizeGestureChecker(m_refUser);
                        EnableGestureChecker(m_refMinimizeGestureChecker);
                    }
                    break;

                case "A":
                    if (!PropertiesPluginKinect.Instance.EnablePostureA)
                    {
                        DisablePostureChecker(m_refPostureAChecker);
                    }
                    else
                    {
                        m_refPostureAChecker = new PostureAChecker(m_refUser);
                        EnablePostureChecker(m_refPostureAChecker);
                    }
                    break;

                case "Home":
                    if (!PropertiesPluginKinect.Instance.EnablePostureHome)
                    {
                        DisableGestureChecker(m_refPostureHomeChecker);
                    }
                    else
                    {
                        m_refPostureHomeChecker = new PostureHomeChecker(m_refUser);
                        EnablePostureChecker(m_refPostureHomeChecker);
                    }
                    break;

                case "Stay":
                    if (!PropertiesPluginKinect.Instance.EnablePostureStay)
                    {
                        DisablePostureChecker(m_refPostureHomeChecker);
                    }
                    else
                    {
                        m_refPostureHomeChecker = new PostureHomeChecker(m_refUser);
                        EnablePostureChecker(m_refPostureHomeChecker);
                    }
                    break;

                case "T":
                    if (!PropertiesPluginKinect.Instance.EnablePostureT)
                    {
                        DisablePostureChecker(m_refPostureTChecker);
                    }
                    else
                    {
                        m_refPostureTChecker = new PostureTChecker(m_refUser);
                        EnablePostureChecker(m_refPostureTChecker);
                    }
                    break;

                case "U":
                    if (!PropertiesPluginKinect.Instance.EnablePostureU)
                    {
                        DisablePostureChecker(m_refPostureUChecker);
                    }
                    else
                    {
                        m_refPostureUChecker = new PostureUChecker(m_refUser);
                        EnablePostureChecker(m_refPostureUChecker);
                    }
                    break;

                case "V":
                    if (!PropertiesPluginKinect.Instance.EnablePostureV)
                    {
                        DisablePostureChecker(m_refPostureVChecker);
                    }
                    else
                    {
                        m_refPostureVChecker = new PostureVChecker(m_refUser);
                        EnablePostureChecker(m_refPostureVChecker);
                    }
                    break;

                case "Wait":
                    if (!PropertiesPluginKinect.Instance.EnablePostureWait)
                    {
                        DisablePostureChecker(m_refPostureWaitChecker);
                    }
                    else
                    {
                        m_refPostureWaitChecker = new PostureWaitChecker(m_refUser);
                        EnablePostureChecker(m_refPostureWaitChecker);
                    }
                    break;
            }
        }
Пример #2
0
        public GestureRecognizerManager(UserData user)
        {
            //m_InstanceGestureRecognizerManager = this;

            m_refUser = user;

            #region Variables initialisation

            // Instantiate timer for manage gesture recognize
            m_refTimerGestureManager = new Timer();
            m_refTimerGestureManager.Interval = PropertiesPluginKinect.Instance.GestureRecognizedTime;
            m_refTimerGestureManager.Elapsed += OnTimeOutGesture;

            // Initialize buffer gesture recognition
            m_refGestureRecognized = new List<EnumGesture>();

            // Initialize gesture begin flags
            var ValueGestureAsList = System.Enum.GetValues(typeof(EnumGesture));
            m_refFlagGesturesBegin = new Dictionary<EnumGesture, bool>();
            foreach (EnumGesture gesture in ValueGestureAsList)
            {
                m_refFlagGesturesBegin.Add(gesture, false);
            }

            m_refAuthorizedGesture = true;

            // Instantiate timer for manage when a posture is recognized
            m_refTimerPostureManager = new Timer();
            m_refTimerPostureManager.Interval = PropertiesPluginKinect.Instance.PostureRecognizedTime;
            m_refTimerPostureManager.Elapsed += OnTimeOutPosture;

            m_refPostureRecognized = PropertiesPluginKinect.Instance.SavePosturerecognize;

            if (PropertiesPluginKinect.Instance.SavePosturerecognize != EnumPosture.POSTURE_NONE)
            {
                m_refTimerPostureManager.Start();
            }

            // Initialize posture begin flags
            var ValuePostureAsList = System.Enum.GetValues(typeof(EnumPosture));
            m_refFlagPostureBegin = new Dictionary<EnumPosture, bool>();
            foreach (EnumPosture posture in ValuePostureAsList)
            {
                m_refFlagPostureBegin.Add(posture, false);
            }

            // Listen the Gestures enable changement
            PropertiesPluginKinect.Instance.SynchronizeGesturesState += OnSynchronizeGesturesState;

            #endregion

            #region Gesture Checker initialisation

            if(!PropertiesPluginKinect.Instance.KinectPointingModeEnabled)
            {
                if (PropertiesPluginKinect.Instance.EnableGestureSwipeRight || PropertiesPluginKinect.Instance.EnableGestureSwipeLeft)
                {
                    m_refSwipeHandRightChecker = new SwipeGestureChecker(user, JointType.HandRight);
                    EnableGestureChecker(m_refSwipeHandRightChecker);

                    m_refSwipeHandLeftChecker = new SwipeGestureChecker(user, JointType.HandLeft);
                    EnableGestureChecker(m_refSwipeHandLeftChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGestureWave)
                {
                    m_refHandRightWaveChecker = new WaveGestureChecker(user, JointType.HandRight);
                    EnableGestureChecker(m_refHandRightWaveChecker);

                    m_refHandLeftWaveChecker = new WaveGestureChecker(user, JointType.HandLeft);
                    EnableGestureChecker(m_refHandLeftWaveChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGesturePush)
                {
                    m_refPushRightHandGestureChecker = new PushGestureChecker(user, JointType.HandRight);
                    EnableGestureChecker(m_refPushRightHandGestureChecker);

                    m_refPushLeftHandGestureChecker = new PushGestureChecker(user, JointType.HandLeft);
                    EnableGestureChecker(m_refPushLeftHandGestureChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGestureMaximize)
                {
                    m_refMaximizeGestureChecker = new MaximizeGestureChecker(user);
                    EnableGestureChecker(m_refMaximizeGestureChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGestureMinimize)
                {
                    m_refMinimizeGestureChecker = new MinimizeGestureChecker(user);
                    EnableGestureChecker(m_refMinimizeGestureChecker);
                }
            }

            if (PropertiesPluginKinect.Instance.EnablePostureA)
            {
                m_refPostureAChecker = new PostureAChecker(user);
                EnablePostureChecker(m_refPostureAChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureHome)
            {
                m_refPostureHomeChecker = new PostureHomeChecker(user);
                EnablePostureChecker(m_refPostureHomeChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureStay)
            {
                m_refPostureStayChecker = new PostureStayChecker(user);
                EnablePostureChecker(m_refPostureStayChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureT)
            {
                m_refPostureTChecker = new PostureTChecker(user);
                EnablePostureChecker(m_refPostureTChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureU)
            {
                m_refPostureUChecker = new PostureUChecker(user);
                EnablePostureChecker(m_refPostureUChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureV)
            {
                m_refPostureVChecker = new PostureVChecker(user);
                EnablePostureChecker(m_refPostureVChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureWait)
            {
                m_refPostureWaitChecker = new PostureWaitChecker(user);
                EnablePostureChecker(m_refPostureWaitChecker);
            }
            #endregion
        }