Exemplo n.º 1
0
        //method to detect hand and creates the frame object
        public void detectGesture(Leap.Frame frame)
        {
            // creates an object
            GestureList gestures = frame.Gestures(); //returns list of gestures

            for (int i = 0; i < gestures.Count(); i++)
            {
                Gesture gesture = gestures[i];

                //switch using gesture.type as a flag, when it gets the type of gesture it will go to its respective case
                switch (gesture.Type)
                {
                //these are the cases and prints out the detected gesture

                case Gesture.GestureType.TYPE_CIRCLE:
                    Debug.WriteLine("Circle");
                    break;

                case Gesture.GestureType.TYPE_KEY_TAP:
                    Debug.WriteLine("Key Tap");
                    break;

                case Gesture.GestureType.TYPE_SWIPE:
                    Debug.WriteLine("Swipe");
                    break;

                case Gesture.GestureType.TYPE_SCREEN_TAP:
                    Debug.WriteLine("Screen Tap");
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public void detectGesture(Leap.Frame frame)                                    //Función publica de detección de gesto con los frames recibidos del Leap Motion
        {
            GestureList gestures = frame.Gestures();                                   //Intanciación del objeto gestos con la llamada de frames

            for (int i = 0; i < gestures.Count(); i++)                                 //Bucle for para recorrer la cantidad de gestos recibidos
            {
                Gesture gesture = gestures[i];                                         //Aignación de las posiciones del array segun se recorre el array de  gestos
                switch (gesture.Type)                                                  //Switch de caos del tipo de gesto
                {
                case Gesture.GestureType.TYPE_CIRCLE:                                  //Si se recibe el gesto de circulo
                    richTextBox1.AppendText("Circle detected!" + Environment.NewLine); //Se muestra el texto por pantalla y se pasa a la siguiente linea del cuadro de muestras de texto por pantalla
                    break;                                                             //Salida

                case Gesture.GestureType.TYPE_SCREEN_TAP:                              //Si se recibe el gesto de screen tap
                    richTextBox1.AppendText("Screen tap!" + Environment.NewLine);      //Se muestra el texto por pantalla y se pasa a la siguiente linea del cuadro de muestras de texto por pantalla
                    break;                                                             //Salida

                case Gesture.GestureType.TYPE_KEY_TAP:                                 //Si se recibe el gesto de key tap
                    richTextBox1.AppendText("Key tap!" + Environment.NewLine);         //Se muestra el texto por pantalla y se pasa a la siguiente linea del cuadro de muestras de texto por pantalla
                    break;                                                             //Salida

                case Gesture.GestureType.TYPE_SWIPE:                                   //Si se recibe el gesto de swipe
                    richTextBox1.AppendText("Swipe detected!" + Environment.NewLine);  //Se muestra el texto por pantalla y se pasa a la siguiente linea del cuadro de muestras de texto por pantalla
                    break;                                                             //Salida
                }
            }
        }
Exemplo n.º 3
0
        public void detectGesture(Leap.Frame frame)
        {
            GestureList gestures = frame.Gestures();   //Return a list of gestures

            for (int i = 0; i < gestures.Count(); i++) // enumerate all the gestures detected in a frame
            {
                Gesture gesture = gestures[i];
                switch (gesture.Type)
                {
                case Gesture.GestureType.TYPE_CIRCLE:
                    richTextBox1.AppendText("Circle detected!" + Environment.NewLine);
                    break;

                case Gesture.GestureType.TYPE_KEY_TAP:
                    richTextBox1.AppendText("Key Tap detected!" + Environment.NewLine);
                    break;

                case Gesture.GestureType.TYPE_SWIPE:
                    richTextBox1.AppendText("Swipe detected!" + Environment.NewLine);
                    break;

                case Gesture.GestureType.TYPE_SCREEN_TAP:
                    richTextBox1.AppendText("Screen Tap detected!" + Environment.NewLine);
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public void detectGesture(Leap.Frame frame)
        {
            GestureList gestures = frame.Gestures();   //Return a list of gestures

            for (int i = 0; i < gestures.Count(); i++) // enumerate all the gestures detected in a frame
            {
                Gesture gesture = gestures[i];
                switch (gesture.Type)
                {
                case Gesture.GestureType.TYPE_CIRCLE:
                    richTextBox1.AppendText("Circle detected!" + Environment.NewLine);
                    this.Unlocked = true;
                    this.UnlockGestureTimer.Stop();
                    this.UnlockGestureTimer.Start();
                    break;

                case Gesture.GestureType.TYPE_KEY_TAP:
                    FanController.WindLevel();
                    richTextBox1.AppendText("Key Tap detected!" + Environment.NewLine);
                    break;

                case Gesture.GestureType.TYPE_SWIPE:
                    FanController.PowerOff();
                    richTextBox1.AppendText("Swipe detected!" + Environment.NewLine);
                    break;

                case Gesture.GestureType.TYPE_SCREEN_TAP:
                    FanController.LightOn();
                    richTextBox1.AppendText("Screen Tap detected!" + Environment.NewLine);
                    break;
                }
            }
        }
Exemplo n.º 5
0
      private void detectGesture(Leap.Frame frame)
      {
          GestureList gestures = frame.Gestures();

          for (int i = 0; i < gestures.Count(); i++)
          {
              Gesture gesture = gestures[i];
              switch (gesture.Type)
              {
              case Gesture.GestureType.TYPE_CIRCLE:
                  //richTextBox1.AppendText("Movement detected!" + Environment.NewLine);
                  break;

              case Gesture.GestureType.TYPE_KEY_TAP:
                  //richTextBox1.AppendText("Movement detected!" + Environment.NewLine);

                  break;

              case Gesture.GestureType.TYPE_SWIPE:
                  // richTextBox1.AppendText("Translation detected!" + Environment.NewLine);

                  break;

              case Gesture.GestureType.TYPE_INVALID:
                  //richTextBox1.AppendText("NO MOVEMENT ");
                  break;
              }
          }
      }
Exemplo n.º 6
0
        private void newFrameHandler(Leap.Frame currentFrame)
        {
            if (slideShowActive)
            {
                deltaTime = currentFrame.Timestamp - timestamp;
                timestamp = currentFrame.Timestamp;
                slideSwitchCooldownTimer -= deltaTime;
                modeSwitchTimer          -= deltaTime;
                if (slideSwitchCooldownTimer < 0)
                {
                    slideSwitchCooldownTimer = 0;
                }
                if (modeSwitchTimer < 0)
                {
                    modeSwitchTimer = 0;
                }

                if (!currentFrame.Hands.IsEmpty)
                {
                    FingerList indexList  = currentFrame.Fingers.FingerType(Finger.FingerType.TYPE_INDEX);
                    FingerList thumbList  = currentFrame.Fingers.FingerType(Finger.FingerType.TYPE_THUMB);
                    FingerList middleList = currentFrame.Fingers.FingerType(Finger.FingerType.TYPE_MIDDLE);
                    FingerList ringList   = currentFrame.Fingers.FingerType(Finger.FingerType.TYPE_RING);
                    FingerList pinkyList  = currentFrame.Fingers.FingerType(Finger.FingerType.TYPE_PINKY);

                    // Get the first finger in the list of fingers
                    Finger index  = indexList[0];
                    Finger thumb  = thumbList[0];
                    Finger middle = middleList[0];
                    Finger ring   = ringList[0];
                    Finger pinky  = pinkyList[0];

                    updateCursor(index, ring, pinky);


                    if (thumbUpGestureActivated == false && thumb.IsExtended && !index.IsExtended && !middle.IsExtended && !ring.IsExtended && !pinky.IsExtended)
                    {
                        modeSwitchTimer         = modeSwitchTime;
                        thumbUpGestureActivated = true;
                    }
                    if (thumbUpGestureActivated == true && modeSwitchTimer > 0 && !thumb.IsExtended && !index.IsExtended && !middle.IsExtended && !ring.IsExtended && !pinky.IsExtended)
                    {
                        thumbUpGestureActivated = false;

                        //set the next mode
                        if (mode == Mode.Cursor)
                        {
                            mode = Mode.Pen;
                        }
                        else if (mode == Mode.Pen)
                        {
                            mode = Mode.Highlighter;
                        }
                        else if (mode == Mode.Highlighter)
                        {
                            mode = Mode.Eraser;
                        }
                        else if (mode == Mode.Eraser)
                        {
                            mode = Mode.Cursor;
                        }
                        updateIcons();
                    }

                    //ignore the gesture if left halfway while triggering time runs out
                    if (modeSwitchTimer == 0)
                    {
                        thumbUpGestureActivated = false;
                    }

                    //ignore the gesture if invalidated halfway
                    if (thumbUpGestureActivated == true && !(thumb.IsExtended && !index.IsExtended && !middle.IsExtended && !ring.IsExtended && !pinky.IsExtended))
                    {
                        thumbUpGestureActivated = false;
                    }

                    if (index.IsExtended && thumb.IsExtended)
                    {
                        if (mode == Mode.Pen)
                        {
                            setPenMode();
                        }
                        if (mode == Mode.Highlighter)
                        {
                            setHighlighterMode();
                        }
                        if (mode == Mode.Eraser)
                        {
                            setEraserMode();
                        }
                    }
                    else
                    {
                        setCursorMode();
                    }


                    GestureList gestures = currentFrame.Gestures();

                    for (int i = 0; i < gestures.Count(); i++)
                    {
                        Gesture gesture = gestures[i];

                        if (slideSwitchCooldownTimer == 0)
                        {
                            //gesture - action -mapping
                            if (horizontalSwipeToRight(gesture))
                            {
                                slideSwitchCooldownTimer = slideSwitchCooldownTime;
                                nextSlide();
                            }
                            else if (horizontalSwipeToLeft(gesture))
                            {
                                slideSwitchCooldownTimer = slideSwitchCooldownTime;
                                previousSlide();
                            }
                        }
                    }
                }
                else
                {
                    setCursorMode();
                }
            }
        }