pxcmStatus OnModuleProcessedFrame(
      int mid,
      PXCMBase module,
      PXCMCapture.Sample sample)
        {
            // is it our module?
              if (mid == PXCMFaceModule.CUID)
              {
            this.faceData.Update();

            // Any faces?
            var firstFace = this.faceData.QueryFaces().FirstOrDefault();

            if (firstFace != null)
            {
              // face detection - the bounding rectangle of the face.
              var localFaceBox = default(PXCMRectI32);

              if (firstFace.QueryDetection()?.QueryBoundingRect(out localFaceBox) == true)
              {
            this.faceBox = localFaceBox;
              }
              var landmarks = firstFace.QueryLandmarks()?.QueryPoints(
            out this.landmarks);
            }
            else
            {
              this.faceBox = null;
              this.landmarks = null;
            }
              }
              this.Dispatcher.Invoke(this.DrawFaceFrameUIThread);

              return (pxcmStatus.PXCM_STATUS_NO_ERROR);
        }
Esempio n. 2
0
        /// <summary>
        /// Called when a module has processed a frame.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="module">The module.</param>
        /// <param name="sample">The sample.</param>
        /// <returns>pxcmStatus.</returns>
        /// <exception cref="System.NotImplementedException">Unknown type.</exception>
        pxcmStatus OnModuleProcessedFrame(int type, PXCMBase module, PXCMCapture.Sample sample) 
        {
            // Process the frame using the appropriate callback.
            switch(type)
            {
                case PXCMFaceModule.CUID:
                    OnFaceCallback(module as PXCMFaceModule);
                    break;

                case PXCMEmotion.CUID:
                    OnEmotionCallback(module as PXCMEmotion);
                    break;

                default:
                    throw new NotImplementedException("Unknown type.");
            }

            // Handle graphics.
            if (sample.color != null)
                OnColourImage(this, new EventArgs<PXCMImage>(sample.color));
            if (sample.depth != null)
                OnDepthImage(this, new EventArgs<PXCMImage>(sample.depth));
            if (sample.ir != null)
                OnInfraredImage(this, new EventArgs<PXCMImage>(sample.ir));

           // return NO_ERROR to continue, or any error to abort.
           return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 3
0
 public pxcmStatus OnModuleQueryProfile(Int32 mid, PXCMBase obj, Int32 pidx)
 {
     return pidx == profileIndex ? pxcmStatus.PXCM_STATUS_NO_ERROR : pxcmStatus.PXCM_STATUS_PARAM_UNSUPPORTED;
 }
Esempio n. 4
0
 public static pxcmStatus OnNewFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
 {
     return pxcmStatus.PXCM_STATUS_NO_ERROR;
 }
Esempio n. 5
0
        //  System.Windows.Forms.Timer _timer;
        pxcmStatus OnModuleProcessedFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            thread.Wait();
            if (mid == PXCMHandModule.CUID)
            {
                PXCMHandModule hand = module.QueryInstance<PXCMHandModule>();
                PXCMHandData handData = hand.CreateOutput();
                handData.Update();
                if (handData == null)
                {
                    Console.WriteLine("Failed Create Output");
                    Console.WriteLine("That`s all...");
                    Console.ReadKey();
                    return 0;
                }
                PXCMHandData.JointData[][] nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
                int numOfHands = handData.QueryNumberOfHands();
                for (int i = 0; i < numOfHands; i++)
                {
                    //Get hand by time of appearence
                    PXCMHandData.IHand IhandData;
                    if (handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out IhandData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        if (handData != null)
                        {
                            //Iterate Joints
                            for (int j = 0; j < 0x20; j++)
                            {
                                PXCMHandData.JointData jointData;
                                IhandData.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData);
                                nodes[i][j] = jointData;
                            } // end iterating over joints
                        }
                    }
                } // end itrating over hands
                int numOfGestures = handData.QueryFiredGesturesNumber();
                if (numOfGestures > 0)
                {
                    for (int i = 0; i < numOfGestures; i++)
                    {
                        PXCMHandData.GestureData gestureData;
                        if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            switch (gestureData.name)
                            {
                                case "wave":
                                    string[] response = GET("http://168.63.82.20/api/login", "login=sbst&password=ebc1628c26f8515f81a5178a5abfcbd9").Split('\"');
                                    response = GET("http://168.63.82.20/api/thing", @"user_id=" + response[7] + @"&token=" + response[3] + @"&did=yk5ynj69aw7z").Split('\"'); ;
                                    label1.Invoke(new Inform((s) => label1.Text = s), response[15] + " C");
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text + WindState.ToString()), "GETDATA Temperature:" + response[15] + " C" + "\n");
                                    break;

                                case "tap":
                                    flagLight++;
                                    if (flagLight == 2)
                                    {
                                        if (LightState == 0)
                                            LightState = 1;
                                        else
                                            LightState = 0;
                                        flagLight = 0;
                                        logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), "MAKEDATA LightState:" + LightState + " WindState:" + WindState + "\n");
                                    }

                                    break;

                                case "swipe_up":
                                    flagWind++;
                                    if (flagWind == 2)
                                    {
                                        if (WindState == 0)
                                            WindState = 1;
                                        else
                                            WindState = 0;
                                        flagWind = 0;
                                        logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text + WindState.ToString()), "MAKEDATA LightState:" + LightState + " WindState:" + WindState + "\n");
                                    }
                                    break;

                                case "thumb_up":
                                    SendState++;
                                    if (SendState == 2)
                                    {
                                        if (LightState == 0)
                                            ChangeSwitch(DidLight, "501");
                                        else
                                            ChangeSwitch(DidLight, "498");

                                        if (WindState == 0)
                                            ChangeSwitch(DidWind, "501");
                                        else
                                            ChangeSwitch(DidWind, "498");
                                        logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), "SENDDATA LightState:" + LightState + " WindState:" + WindState + "\n");
                                        //SendState = 0;
                                    }
                                    break;
                                    //textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    //textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    //textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    //logTextBox.Invoke(new Inform((s) =>  logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: V sign" + "\n");
                            }
                        }

                    }
                }
            }
            //Thread.Sleep(100);
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 6
0
        private pxcmStatus onModuleProcessedFrame(int mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            if (mid == PXCMHandModule.CUID)
            {
                this._handData.Update();
            }

            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 7
0
File: Form1.cs Progetto: sbst/code
        pxcmStatus OnModuleProcessedFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            // check if the callback is from the hand tracking module.
            if (mid == PXCMHandModule.CUID)
            {
                PXCMHandModule hand = module.QueryInstance<PXCMHandModule>();
                PXCMHandData handData = hand.CreateOutput();
                handData.Update();
                if (handData == null)
                {
                    Console.WriteLine("Failed Create Output");
                    Console.WriteLine("That`s all...");
                    Console.ReadKey();
                    return 0;
                }
                PXCMHandData.JointData[][] nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
                int numOfHands = handData.QueryNumberOfHands();
                for (int i = 0; i < numOfHands; i++)
                {
                    //Get hand by time of appearence
                    PXCMHandData.IHand IhandData;
                    if (handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out IhandData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        if (handData != null)
                        {
                            //Iterate Joints
                            for (int j = 0; j < 0x20; j++)
                            {
                                PXCMHandData.JointData jointData;
                                IhandData.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData);
                                nodes[i][j] = jointData;
                            } // end iterating over joints
                        }
                    }
                } // end itrating over hands
                int numOfGestures = handData.QueryFiredGesturesNumber();
                if (numOfGestures > 0)
                {
                    for (int i = 0; i < numOfGestures; i++)
                    {
                        PXCMHandData.GestureData gestureData;
                        if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            switch (gestureData.name)
                            {
                                case "thumb_up":
                                    if (vol[3] > 10F)
                                        break;
                                    vol[3] += 0.4F;
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Thumb up" + "\n");
                                    Send("/vol4", vol[3]);
                                    break;

                                case "thumb_down":
                                    vol[3] -= 0.4F;
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Thumb down" + "\n");
                                    Send("/vol4", vol[3]);
                                    break;

                                case "fist":
                                    if (vol[0] < 1.6F)
                                        vol[0] += 0.1F;
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Fist" + "\n");
                                    Send("/vol1", vol[0]);
                                    break;

                                case "spreadfingers":
                                    if (vol[0] > 0.4F)
                                        vol[0] -= 0.1F;
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Spreadfingers" + "\n");
                                //    Send("/vol1", vol[0]);
                                    break;

                                case "full_pinch":
                                    if (vol[4] > 0.9F)
                                        flag3 = 1;

                                    if (vol[4] < 0.1F)
                                        flag3 = 0;

                                    if (flag3 == 0)
                                        vol[4] += 0.1F;
                                    else
                                        vol[4] -= 0.1F;
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Full pinch" + "\n");
                                    Send("/vol2", vol[4]);
                                    break;

                                case "v_sign":
                                    vol[0] = 1F;
                                    Send("/vol1", vol[0]);
                                    vol[4] = 1F;
                                    Send("/vol2", vol[4]);
                                    //vol[2] = 0F;
                                    //Send("/vol3", vol[2]);
                                    vol[3] = 2F;
                                    Send("/vol4", vol[3]);
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) =>  logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: V sign" + "\n");
                                    //vol[4] = 0.5F;
                                    //Send("/vol5", vol[4]);
                                    //vol[5] = 0F;
                                    //Send("/vol6", vol[5]);
                                    break;
                            }
                            Thread.Sleep(500);//100
                        }

                    }
                }

            }
            // return NO_ERROR to continue, or any error to abort.
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 8
0
 public pxcmStatus OnModuleSetProfile(Int32 mid, PXCMBase obj)
 {
     //PXCMBase m = this.sm.QueryModule(mid);
     //Console.WriteLine("RSSDK(ModuleSetProfile): " + " - "+ mid.ToString());
     return pxcmStatus.PXCM_STATUS_NO_ERROR;
 }
Esempio n. 9
0
        public pxcmStatus OnModuleProcessFrame(int mid, PXCMBase obj, PXCMCapture.Sample sample)
        {
            if(mid == PXCMHandModule.CUID)
            {
                if(HandEnabled && (handData != null))
                {
                    handData.Update();
                    numHands = handData.QueryNumberOfHands();
                }
            }

            if(BlobEnabled && (blobData != null))
            {
                blobData.Update();
            }

            //PXCMBase m = this.sm.QueryModule(mid);
            //Console.WriteLine("RSSDK(ModuleProcessFrame): " + " - " +  mid.ToString());
               			return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 10
0
 public static pxcmStatus OnNewFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
 {
     return(pxcmStatus.PXCM_STATUS_NO_ERROR);
 }
Esempio n. 11
0
 public pxcmStatus OnModuleQueryProfile(Int32 mid, PXCMBase obj, Int32 pidx)
 {
     return(pidx == profileIndex ? pxcmStatus.PXCM_STATUS_NO_ERROR : pxcmStatus.PXCM_STATUS_PARAM_UNSUPPORTED);
 }
Esempio n. 12
0
        private pxcmStatus OnModuleProcessedFrame(int mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            // use this sample to work on the hand data.
            if (calibrated)
            {
                frameCounter++;
                if (frameCounter % 100 == 0)
                {
                    this.Dispatcher.Invoke((() =>
                    {
                        var position = _movementController.GetHandPosition();
                        outputbox.Text = AppendOutputboxText(position);
                    }));
                    _movementController.AssertArmMovement();
                    frameCounter = 0;                                                   
                }
            }

            
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 13
0
File: source.cs Progetto: sbst/code
        pxcmStatus OnModuleProcessedFrame(Int32 mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            thread.Wait();
            if (mid == PXCMHandModule.CUID)
            {
                PXCMHandModule hand = module.QueryInstance<PXCMHandModule>();
                PXCMHandData handData = hand.CreateOutput();
                handData.Update();
                if (handData == null)
                {
                    Console.WriteLine("Failed Create Output");
                    Console.WriteLine("That`s all...");
                    Console.ReadKey();
                    return 0;
                }
                PXCMHandData.JointData[][] nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
                int numOfHands = handData.QueryNumberOfHands();
                for (int i = 0; i < numOfHands; i++)
                {
                    //Get hand by time of appearence
                    PXCMHandData.IHand IhandData;
                    if (handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, i, out IhandData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        if (handData != null)
                        {
                            //Iterate Joints
                            for (int j = 0; j < 0x20; j++)
                            {
                                PXCMHandData.JointData jointData;
                                IhandData.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData);
                                nodes[i][j] = jointData;
                            } // end iterating over joints
                        }
                    }
                } // end itrating over hands
                int numOfGestures = handData.QueryFiredGesturesNumber();
                if (numOfGestures > 0)
                {
                    for (int i = 0; i < numOfGestures; i++)
                    {
                        PXCMHandData.GestureData gestureData;
                        if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR)
                        {
                            switch (gestureData.name)
                            {
                                case "thumb_up":
                                    break;

                                case "thumb_down":
                                    break;

                                case "fist":
                                    break;

                                case "spreadfingers":
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Spreadfingers" + "\n");
                                    break;

                                case "full_pinch":
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) => logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: Full pinch" + "\n");
                                    break;

                                case "v_sign":
                                    textVolume.Invoke(new Inform((s) => textVolume.Text = s), vol[3].ToString("F"));
                                    textSpeed.Invoke(new Inform((s) => textSpeed.Text = s), vol[0].ToString("F"));
                                    textPanorama.Invoke(new Inform((s) => textPanorama.Text = s), vol[4].ToString("0.##"));
                                    logTextBox.Invoke(new Inform((s) =>  logTextBox.Text = s + logTextBox.Text), DateTime.Now.ToString("hh:mm:ss") + " Gesture: V sign" + "\n");
                                    break;
                            }
                        }

                    }
                }

            }
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }
Esempio n. 14
0
 public pxcmStatus OnModuleProcessFrame(int mid, PXCMBase obj, PXCMCapture.Sample sample)
 {
     //PXCMBase m = this.sm.QueryModule(mid);
     //Console.WriteLine("RSSDK(ModuleProcessFrame): " + " - " +  mid.ToString());
        			return pxcmStatus.PXCM_STATUS_NO_ERROR;
 }
Esempio n. 15
0
        private pxcmStatus OnFrameProcessed(int mid, PXCMBase module, PXCMCapture.Sample sample)
        {
            if (mid == PXCMHandModule.CUID)
            {
                this.handData.Update();
                int handnum = this.handData.QueryNumberOfHands();
                //
                // Handle zoom
                if (handnum > 1)
                {
                    int x1 = 0, x2 = 0;
                    bool everythingIsGood = true;
                    for (int i = 0; i < handnum; i++)
                    {
                        PXCMHandData.IHand hand;
                        handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR, i, out hand);
                        if (hand != null)
                        {
                            var pos = hand.QueryMassCenterImage();
                            if (hand.QueryBodySide() == PXCMHandData.BodySideType.BODY_SIDE_LEFT)
                            {
                                x1 = (int)pos.x;
                            }
                            else
                            {
                                x2 = (int)pos.x;
                            }
                        }
                        else
                        {
                            everythingIsGood = false;
                        }
                    }
                    if (everythingIsGood)
                    {
                        if (zoomStarted)
                        {
                            int distance = Math.Abs(x1 - x2);
                            if (Math.Abs(distance - zoomDistance) > 10)
                            {
                                bool tempInZDirection = distance < zoomDistance;
                                if (isInZoomDirection.HasValue && tempInZDirection != isInZoomDirection.Value)
                                {
                                    TouchInjection.ReleaseTwoZoomContacts();
                                    TouchInjection.ReserveTwoZoomContacts(LeftZoomPx, CenterPy, RightZoomPx, CenterPy);
                                }
                                isInZoomDirection = tempInZDirection;
                                TouchInjection.Zoom(zoomSensitivity, tempInZDirection);
                                zoomDistance = distance;
                            }
                        }
                        else
                        {
                            TouchInjectionCore.TouchInjector.InitializeTouchInjection();
                            zoomDistance = Math.Abs(x1 - x2);
                            TouchInjection.ReserveTwoZoomContacts(LeftZoomPx, CenterPy, RightZoomPx, CenterPy);
                            zoomStarted = true;
                        }
                    }
                }
                else // It is not zoom
                {
                    if (zoomStarted)
                    {
                        TouchInjection.ReleaseTwoZoomContacts();
                        MouseInjection.ReturnPointer(AreaWidth, AreaHeight);
                        zoomStarted = false;
                    }
                    PXCMHandData.IHand hand;
                    handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR, 0, out hand);

                    if (hand != null && !touchReserved && !scrollStarted)
                    {
                        int openns = hand.QueryOpenness();
                        var center = hand.QueryMassCenterImage();
                        PXCMHandData.FingerData thumbFinger, indexFinger, middleFinger, ringFinger, pinkyFinger;
                        hand.QueryFingerData(PXCMHandData.FingerType.FINGER_THUMB, out thumbFinger);
                        hand.QueryFingerData(PXCMHandData.FingerType.FINGER_INDEX, out indexFinger);
                        hand.QueryFingerData(PXCMHandData.FingerType.FINGER_MIDDLE, out middleFinger);
                        hand.QueryFingerData(PXCMHandData.FingerType.FINGER_RING, out ringFinger);
                        hand.QueryFingerData(PXCMHandData.FingerType.FINGER_PINKY, out pinkyFinger);

                        PXCMHandData.JointData thumbJoint;
                        PXCMHandData.JointData pinkyJoint;
                        hand.QueryTrackedJoint(PXCMHandData.JointType.JOINT_THUMB_TIP, out thumbJoint);
                        hand.QueryTrackedJoint(PXCMHandData.JointType.JOINT_PINKY_BASE, out pinkyJoint);

                        //MessageBox.Show(
                        //    thumbFinger.foldedness + Environment.NewLine
                        //    + indexFinger.foldedness + Environment.NewLine
                        //    + middleFinger.foldedness + Environment.NewLine
                        //    + ringFinger.foldedness + Environment.NewLine
                        //    + pinkyFinger.foldedness + Environment.NewLine
                        //    + (thumbJoint.positionImage.y > pinkyJoint.positionImage.y).ToString());

                        // Handle close event
                        int fistSens = fistSensitivity - 40;
                        if (fistSens < 0)
                        {
                            fistSens = 0;
                        }
                        if (canClose && handInsideBorders && openns == 0
                            && thumbFinger.foldedness <= fistSensitivity
                            && indexFinger.foldedness <= fistSens
                            && middleFinger.foldedness <= fistSens
                            && ringFinger.foldedness <= fistSens
                            && pinkyFinger.foldedness <= fistSens
                            && Math.Abs(center.x - sceneXCenter) < 150  //
                            && Math.Abs(center.y - sceneYCenter) < 120) // Is hand near center of a screen?
                        {
                            canClose = false;
                            Task.Factory.StartNew(() => WinPInvoke.CloseWindow());

                            // Block repeatable
                            Task.Factory.StartNew(() =>
                            {
                                Thread.Sleep(1500);
                                canClose = true;
                            });
                        }
                        // Handle WinStart menu event
                        else if (canOpenWinMenu && openns > 40 && openns < 50
                            && thumbFinger.foldedness == 0
                            && indexFinger.foldedness > 95
                            && middleFinger.foldedness > 95
                            && ringFinger.foldedness == 0
                            && pinkyFinger.foldedness == 0)
                        {
                            canOpenWinMenu = false;
                            WinPInvoke.KeyDown(Keys.LWin);
                            WinPInvoke.KeyUp(Keys.LWin);

                            // Block repeatable
                            Task.Factory.StartNew(() =>
                            {
                                Thread.Sleep(2000);
                                canOpenWinMenu = true;
                            });
                        }
                        // Handle Volume up event
                        else if (thumbFinger.foldedness > 95
                            && indexFinger.foldedness < 5
                            && middleFinger.foldedness < 5
                            && ringFinger.foldedness < 5
                            && pinkyFinger.foldedness < 5
                            && thumbJoint.positionImage.y < pinkyJoint.positionImage.y)
                        {
                            WinPInvoke.VolumeUp(IntPtr.Zero);
                            Thread.Sleep(5);
                        }
                        else if (thumbFinger.foldedness > 95
                            && indexFinger.foldedness < 5
                            && middleFinger.foldedness < 5
                            && ringFinger.foldedness < 5
                            && pinkyFinger.foldedness < 5
                            && thumbJoint.positionImage.y > pinkyJoint.positionImage.y)
                        {
                            WinPInvoke.VolumeDown(IntPtr.Zero);
                            Thread.Sleep(5);
                        }
                        // Handle cursor click
                        else if(canClick && thumbFinger.foldedness < 50 && pinkyFinger.foldedness > 70)
                        {
                            if (indexFinger.foldedness > 70 && middleFinger.foldedness < 50)
                            {
                                canClick = false;
                                MouseInjection.ClickRightMouseButton();
                                Task.Factory.StartNew(() =>
                                {
                                    Thread.Sleep(clickDelay);
                                    canClick = true;
                                });
                            }
                            else if (enableDragging && indexFinger.foldedness < 50 && middleFinger.foldedness < 50)
                            {
                                TouchInjection.TouchDown();
                                touchReserved = true;
                            }
                            else if (indexFinger.foldedness < 50 && (!enableDragging || middleFinger.foldedness > 60))
                            {
                                canClick = false;
                                if (useMouseClickOrTouch)
                                {
                                    MouseInjection.ClickLeftMouseButton();
                                }
                                else
                                {
                                    TouchInjection.Touch();
                                }
                                Task.Factory.StartNew(() =>
                                {
                                    Thread.Sleep(clickDelay);
                                    canClick = true;
                                });
                            }
                        }
                    }
                }
            }
            return pxcmStatus.PXCM_STATUS_NO_ERROR;
        }