public void SwipeAction(FingerList fingers, SwipeDirection sd)
        {
            switch (sd)
            {
            case SwipeDirection.Left:
                if (LeapSwipe != null)
                {
                    LeapSwipe(SwipeDirection.Left);
                }
                break;

            case SwipeDirection.Right:
                if (LeapSwipe != null)
                {
                    LeapSwipe(SwipeDirection.Right);
                }
                break;

            case SwipeDirection.Up:
                if (LeapSwipe != null)
                {
                    LeapSwipe(SwipeDirection.Up);
                }
                break;

            case SwipeDirection.Down:
                if (LeapSwipe != null)
                {
                    LeapSwipe(SwipeDirection.Down);
                }
                break;
            }
        }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Seleccionado.elegido == true && yapaso == false)
        {
            Proxim.GetComponent <UnityEngine.UI.Image> ().color = Color.green;
        }
        frameActual = controller.Frame();         //obtengo la informacion del leap de un frame



        if (frameActual.Hands.Count > 0)
        {
            HandList hands = frameActual.Hands;
            firstHand = hands[0];
        }

        FingerList dedos = frameActual.Fingers;         //obtengo todos los dedos detectados en un frame

        dedos_extendidos = 0;

        for (int i = 0; i < dedos.Extended().Count; i++)
        {
            dedos_extendidos++;            //cuento todos los dedos que estan extendidos de la FingerList dedos
        }
    }
예제 #3
0
    //Geometry creation methods

    private void createSpheres()
    {
        //Create spheres for finger joints
        FingerList fingers = hand_.Fingers;

        for (int i = 0; i < fingers.Count; i++)
        {
            Finger finger = fingers[i];
            for (int j = 0; j < 4; j++)
            {
                int key = getFingerJointIndex((int)finger.Type, j);
                _jointSpheres[key] = createSphere("Joint", SPHERE_RADIUS);

                if (j == 3 && i == 1)   // make the pointer finger tip black
                {
                    _jointSpheres[key].GetComponent <MeshRenderer> ().material.color = Color.black;
                    pointerTip = _jointSpheres [key];
                }
            }
        }

        mockThumbJointSphere = createSphere("MockJoint", SPHERE_RADIUS);
        palmPositionSphere   = createSphere("PalmPosition", PALM_RADIUS);
        wristPositionSphere  = createSphere("WristPosition", SPHERE_RADIUS);

        armFrontLeft  = createSphere("ArmFrontLeft", SPHERE_RADIUS, true);
        armFrontRight = createSphere("ArmFrontRight", SPHERE_RADIUS, true);
        armBackLeft   = createSphere("ArmBackLeft", SPHERE_RADIUS, true);
        armBackRight  = createSphere("ArmBackRight", SPHERE_RADIUS, true);
    }
예제 #4
0
        public override void OnFrame(Controller controller)
        {
            Frame frame = controller.Frame();
            // Get the first hand
            Hand hand = frame.Hands[0];

            // Check if the hand has any fingers
            FingerList fingers = hand.Fingers;
            if (!fingers.Empty)
            {
                // Calculate the hand's average finger tip position
                Vector avgPos = Vector.Zero;
                Vector avgVelocity = Vector.Zero;
                foreach (Finger finger in fingers)
                {
                    avgPos += finger.TipPosition;
                    avgVelocity += finger.TipVelocity;
                }
                avgPos /= fingers.Count;
                avgVelocity /= fingers.Count;
                List<Gesture.Direction> directions = new List<Gesture.Direction>();

                if (avgVelocity.y > sensitivity)
                {
                    directions.Add(Gesture.Direction.Up);
                }
                else if (avgVelocity.y < -sensitivity)
                {
                    directions.Add(Gesture.Direction.Down);
                }

                if (avgVelocity.x > sensitivity)
                {
                    directions.Add(Gesture.Direction.Right);
                }
                else if (avgVelocity.x < -sensitivity)
                {
                    directions.Add(Gesture.Direction.Left);
                }


                if (avgVelocity.z > sensitivity)
                {
                    directions.Add(Gesture.Direction.Backward);
                }
                else if (avgVelocity.z < -sensitivity)
                {
                    directions.Add(Gesture.Direction.Forward);
                }

                if (directions.Count > 0)
                {
                    Gesture gesture = new Gesture(directions.ToArray(), fingers.Count);
                    onGesture(gesture);
                }

                //Console.WriteLine("Hand has " + fingers.Count
                //            + " fingers, average finger tip Velocity: " + avgVelocity);
            }
        }
예제 #5
0
        private void handDetect(Frame frame)
        {
            Hand hand = frame.Hands[0];

            // Check if the hand has any fingers
            FingerList fingers = hand.Fingers;

            if (!fingers.IsEmpty)
            {
                // Calculate the hand's average finger tip position
                Vector avgPos = Vector.Zero;
                foreach (Finger finger in fingers)
                {
                    avgPos += finger.TipPosition;
                }
                avgPos /= fingers.Count;

                InteractionBox iBox = controller.Frame().InteractionBox;
                Vector         normalizedPosition = iBox.NormalizePoint(avgPos);
                var            screen             = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
                var            width  = screen.Width;
                var            height = screen.Height;
                float          x      = normalizedPosition.x * width;
                float          y      = normalizedPosition.y * height;


                int xCoordinate = (int)Math.Round(x);
                int yCoordinate = (int)Math.Round(y);

                Cursor.Position = new Point(xCoordinate, height - yCoordinate);
            }
        }
예제 #6
0
    //Transform updating methods

    private void updateSpheres()
    {
        //Update all spheres
        FingerList fingers = hand_.Fingers;

        for (int i = 0; i < fingers.Count; i++)
        {
            Finger finger = fingers[i];
            for (int j = 0; j < 4; j++)
            {
                int       key    = getFingerJointIndex((int)finger.Type, j);
                Transform sphere = _jointSpheres[key];
                sphere.position = finger.JointPosition((Finger.FingerJoint)j).ToUnityScaled();
            }
        }

        palmPositionSphere.position = hand_.PalmPosition.ToUnity();

        Vector3 wristPos = hand_.PalmPosition.ToUnity();

        wristPositionSphere.position = wristPos;

        Transform thumbBase = _jointSpheres[THUMB_BASE_INDEX];

        Vector3 thumbBaseToPalm = thumbBase.position - hand_.PalmPosition.ToUnity();

        mockThumbJointSphere.position = hand_.PalmPosition.ToUnity() + Vector3.Reflect(thumbBaseToPalm, hand_.Basis.xBasis.ToUnity().normalized);
    }
예제 #7
0
    public void CheckGesture()
    {
        _lastFrame = _leap_controller.Frame(0);
        tFrame     = _leap_controller.Frame(5);
        Hands      = _lastFrame.Hands;

        foreach (Hand hand in Hands)
        {
            tempHand = hand;
            Fingers  = hand.Fingers;
            if (WhichSide.IsEnableGestureHand(this) && WhichSide.IsEnableGestureHand(this) && WhichSide.capturedSide(hand, _useArea, _mountType))
            {
                this._isChecked = GestureCondition();
                if (this._isChecked)
                {
                    break;
                }
            }
        }



        if (_isChecked)
        {
            DoAction();
        }
    }
예제 #8
0
        public static Sign HandToSign(Hand hand, Frame prevFrame)
        {
            if (!hand.IsValid)
            {
                return(null);
            }

            FingerList fingers = hand.Fingers;

            List <double> values = new List <double>();

            double[] palmDir = Array.ConvertAll(hand.PalmNormal.ToFloatArray(), x => System.Convert.ToDouble(x));
            values.AddRange(palmDir);

            /*Vector handMov = new Vector();
             * if (prevFrame != null) {
             *  handMov = hand.Translation(prevFrame);
             * }
             * values.AddRange(Array.ConvertAll(handMov.ToFloatArray(), x => System.Convert.ToDouble(x)));*/

            for (int i = 0; i < fingers.Count; i++)
            {
                Finger   finger     = fingers[i];
                double[] fingerDirs = Array.ConvertAll(finger.Direction.ToFloatArray(), x => System.Convert.ToDouble(x));
                values.AddRange(fingerDirs);
            }

            return(new Sign(values.ToArray()));
        }
예제 #9
0
        protected void DrawLeapLine(Controller leap, Leap.Frame frame)
        {
            FingerList allFingers = frame.Fingers.Extended();

            if (allFingers.Count != 2 || leap.Frame(10).Fingers.Extended().Count != 2)
            {
                return;
            }

            Finger finger1 = allFingers.Leftmost;
            Finger finger2 = allFingers.Rightmost;

            InteractionBox interactionBox = frame.InteractionBox;

            Leap.Vector normalizedPosition1 = interactionBox.NormalizePoint(finger1.StabilizedTipPosition);
            Leap.Vector normalizedPosition2 = interactionBox.NormalizePoint(finger2.StabilizedTipPosition);

            double tx1 = normalizedPosition1.x * windowWidth;
            double ty1 = windowHeight - normalizedPosition1.y * windowHeight;
            double tx2 = normalizedPosition2.x * windowWidth;
            double ty2 = windowHeight - normalizedPosition2.y * windowHeight;

            StylusPointCollection tips = new StylusPointCollection();

            tips.Add(new StylusPoint(tx1, ty1));
            tips.Add(new StylusPoint(tx2, ty2));
            Stroke stroke = new Stroke(tips, lineIndicator);

            this.InkCanvas_LeapPaint.Strokes.Add(stroke);
        }
예제 #10
0
파일: _Test2.cs 프로젝트: nastajus/LeapTry
    private void drawCylindars(FingerList fingers, Vector3 cylindarScale)
    {
        int whichFinger = 0;

        foreach (Finger finger in fingers)
        {
            //create just once for now
            if (drawingCylindars.Count < fingers.Count)
            {
                GameObject cylindar = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                drawingCylindars.Add(cylindar);
                drawingCylindars[whichFinger].transform.localScale = cylindarScale;
            }

            //Vector3 pos = Nastajus.Util.getVector3(finger.TipPosition);
            //Vector3 pos = finger.TipPosition.ToUnityScaled();
            //drawingCylindars[whichFinger].transform.position = pos;

            //Vector3 dir = Nastajus.Util.getVector3(finger.Direction);
            //drawingCylindars[whichFinger].transform.rotation = Quaternion.Euler(dir);
            //drawingCylindars[whichFinger].transform.eulerAngles = finger.Direction.ToUnity();

            whichFinger++;
        }
    }
예제 #11
0
    public void CheckGesture()
    {
        _lastFrame = _leap_controller.Frame(0);
        tFrame = _leap_controller.Frame(5);
        Hands = _lastFrame.Hands;

        foreach(Hand hand in Hands)
        {
            tempHand = hand;
            Fingers = hand.Fingers;
            if (WhichSide.IsEnableGestureHand(this) && WhichSide.IsEnableGestureHand(this) && WhichSide.capturedSide(hand, _useArea, _mountType))
            {
                this._isChecked = GestureCondition();
                if (this._isChecked)
                    break;
            }
        }
       
       

        if(_isChecked)
        {
            DoAction();
        }
    }
예제 #12
0
    //return true if the player is making a gun with his fingers (only two finger: one finger directed up and the other forward)
    bool FingersLikeGun(FingerList pointingFingers)
    {
        //check if there are only 2 fingers
        if (pointingFingers.Count != 2)
        {
            return(false);
        }
        //check if the 2 fingers are thumb and index
        Finger thumb, index;

        thumb = index = null;
        if (pointingFingers[0].Type == Finger.FingerType.TYPE_THUMB)
        {
            thumb = pointingFingers[0];
        }
        else if (pointingFingers[1].Type == Finger.FingerType.TYPE_THUMB)
        {
            thumb = pointingFingers[1];
        }
        if (pointingFingers[0].Type == Finger.FingerType.TYPE_INDEX)
        {
            index = pointingFingers[0];
        }
        else if (pointingFingers[1].Type == Finger.FingerType.TYPE_INDEX)
        {
            index = pointingFingers[1];
        }
        if (thumb == null || index == null)
        {
            return(false);
        }
        return(true);
    }
예제 #13
0
 public void SwipeAction(FingerList fingers, MotionSwipeGestureRecognizerDirection sd)
 {
     /*
      * fingersCount = fingers.Count();
      * if (fingersCount == 5)
      * {
      *  switch (sd)
      *  {
      *      case SwipeDirection.Left:
      *          if (LeapSwipe != null)
      *          {
      *              LeapSwipe(SwipeDirection.Left);
      *          }
      *          break;
      *      case SwipeDirection.Right:
      *          if (LeapSwipe != null)
      *          {
      *              LeapSwipe(SwipeDirection.Right);
      *          }
      *          break;
      *      case SwipeDirection.Up:
      *          if (LeapSwipe != null)
      *          {
      *              LeapSwipe(SwipeDirection.Up);
      *          }
      *          break;
      *      case SwipeDirection.Down:
      *          if (LeapSwipe != null)
      *          {
      *              LeapSwipe(SwipeDirection.Down);
      *          }
      *          break;
      *  }
      * }*/
 }
예제 #14
0
    void Update()
    {
        // Create Frame
        Frame frame = controller.Frame();

        if (!frame.Hands.Empty)
        {
            // Get the first hand
            Hand hand = frame.Hands[0];

            // Check if the hand has any fingers
            FingerList fingers = hand.Fingers;
            if (!fingers.Empty)
            {
                // Calculate the hand's average finger tip position
                Vector avgPos = Vector.Zero;
                foreach (Finger finger in fingers)
                {
                    avgPos += finger.TipPosition;
                }
                avgPos /= fingers.Count;

                // transform.position =  Vector3(avgPos.x,avgPos.y,avgPos.z);
                transform.position = new Vector3(avgPos.x / 50, avgPos.z / 50, avgPos.y / 50 - 5);
            }
        }
    }
예제 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>A normalized coordinate to be multiplied with the actual width and height of the screen</returns>
        public float[] getCoordinate()
        {
            float[] coordinates = new float[2];
            Frame   frame       = _controller.Frame();

            if (!frame.Hands.IsEmpty)
            {
                // Get the first hand
                Hand hand = frame.Hands[0];

                // Check if the hand has any fingers
                FingerList fingers = hand.Fingers;
                if (!fingers.IsEmpty)
                {
                    // Calculate the hand's average finger tip position
                    Vector avgPos = Vector.Zero;
                    foreach (Finger finger in fingers)
                    {
                        avgPos += finger.TipPosition;
                    }
                    avgPos /= fingers.Count;

                    InteractionBox iBox = _controller.Frame().InteractionBox;
                    Vector         normalizedPosition = iBox.NormalizePoint(avgPos);

                    coordinates[0] = normalizedPosition.x;
                    coordinates[1] = normalizedPosition.y;

                    return(coordinates);
                }
            }
            return(null);
        }
예제 #16
0
    // Update is called once per frame
    void Update()
    {
        Frame          frame          = controller.Frame();
        FingerList     fingers        = frame.Fingers;
        PointableList  pointables     = frame.Pointables;
        InteractionBox interactionBox = frame.InteractionBox;

        foreach (var pointable in frame.Pointables)
        {
            foreach (var finger in frame.Fingers)
            {
                Leap.Vector normalizedPosition = interactionBox.NormalizePoint(pointable.StabilizedTipPosition);
                float       tx = normalizedPosition.x * UnityEngine.Screen.width;
                float       ty = UnityEngine.Screen.height - normalizedPosition.y * UnityEngine.Screen.height;

                // 末端骨(指先の骨)
                var bone = finger.Bone(Bone.BoneType.TYPE_METACARPAL);
                if (finger.Type() == Finger.FingerType.TYPE_THUMB)
                {
                    Debug.Log("tx : " + tx + " ty : " + ty + " 距離 : " + pointable.TouchDistance + " 種類 : " + bone.Type);
                }
                int alpha = 255;
                // ホバー状態
                if (pointable.TouchDistance > 0 && pointable.TouchZone != Pointable.Zone.ZONENONE)
                {
                    alpha = 255 - (int)(255 * pointable.TouchDistance);
                    //			touchIndicator.Color = Color.FromArgb((byte)alpha, 0x0, 0xff, 0x0);
                }
            }
        }
    }
예제 #17
0
    // Update is called once per frame
    void Update()
    {
        if (tiempoentregestos == 350)
        {
            cerrarapp         = 0;
            tiempoentregestos = 0;
        }
        frameActual = controller.Frame();         //obtengo la informacion del leap de un frame


        GestureList gestos = frameActual.Gestures();

        if (frameActual.Hands.Count > 0)
        {
            HandList hands = frameActual.Hands;
            firstHand = hands[0];
        }

        FingerList dedos            = frameActual.Fingers; //obtengo todos los dedos detectados en un frame
        int        dedos_extendidos = 0;

        for (int i = 0; i < dedos.Extended().Count; i++)
        {
            dedos_extendidos++;            //cuento todos los dedos que estan extendidos de la FingerList dedos
        }
        if (dedos_extendidos == 5)
        {
            switch (boton)
            {
            case "BodyMotion":
                break;

            case "EarthMotion":
                SceneManager.LoadScene(0);
                break;

            case "VisualMotion":
                SceneManager.LoadScene(1);
                break;

            case "RollingRoshakazu":
                SceneManager.LoadScene(4);
                break;
            }
        }
        for (int i = 0; i < gestos.Count; i++)
        {
            if (gestos [i].Type == Gesture.GestureType.TYPECIRCLE && dedos_extendidos == 1)
            {
                if (cerrarapp == 5)
                {
                    UnityEditor.EditorApplication.isPlaying = false;
                }
                cerrarapp++;
                tiempoentregestos = 0;
            }
        }
        tiempoentregestos++;
    }
예제 #18
0
    // Update is called once per frame
    void Update()
    {
        frameActual = controller.Frame();         //obtengo la informacion del leap de un frame
        if (frameActual.Hands.Count > 0)
        {
            HandList hands = frameActual.Hands;
            firstHand = hands[0];
        }

        FingerList dedos            = frameActual.Fingers; //obtengo todos los dedos detectados en un frame
        int        dedos_extendidos = 0;

        for (int i = 0; i < dedos.Extended().Count; i++)
        {
            dedos_extendidos++;            //cuento todos los dedos que estan extendidos de la FingerList dedos
        }
        if (dedos_extendidos == 2)
        {
            if (fuetocado == true)
            {
                fuetocado = false;
                HabilitarDes(Princi, false);             //Esconde el boton Principiante
                HabilitarDes(Inter, false);              //Esconde el boton Intermedio
                HabilitarDes(Avan, false);               //Esconde el boton Avanzado
                HabilitarDes(Nave, true);                //Muestra El boton Navegar
                HabilitarDes(Qui, true);                 //Muestra El boton Quiz
                if (Listo3 == true)
                {
                    Listo3 = false;
                    if (Listo3 == false)
                    {
                        SceneManager.LoadScene(3);
                    }
                }
            }
        }
        if (dedos_extendidos == 5)
        {
            if (Listo1 == true)
            {
                Listo1 = false;
                if (Listo1 == false)
                {
                    SceneManager.LoadScene(1);
                }
            }
            else
            {
                if (Listo2 == true)
                {
                    Listo2 = false;
                    if (Listo2 == false)
                    {
                        SceneManager.LoadScene(2);
                    }
                }
            }
        }
    }
예제 #19
0
            public override void OnFrame(Controller leap)
            {
                var frame = leap.Frame();

#if true
                // 今回のフレームで検出したすべての手、指、ツール
                HandList      hands      = frame.Hands;
                FingerList    fingers    = frame.Fingers;
                ToolList      tools      = frame.Tools;
                PointableList pointables = frame.Pointables;

                Console.WriteLine(string.Format("手 : {0} 指 : {1} ツール : {2} ポインタ : {3}",
                                                hands.Count, fingers.Count, tools.Count, pointables.Count));
#endif

#if false
                // 手のIDから、同じ手を追跡し続ける
                if (handId == -1)
                {
                    handId = frame.Hands[0].Id;
                }
                else
                {
                    Hand hand = frame.Hand(handId);
                    handId = hand.Id;

                    // 手の情報を表示する
                    Console.WriteLine(string.Format("ID : {0} 位置 : {1} 速度 : {2} 法線 : {3} 向き : {4}",
                                                    hand.Id, hand.PalmPosition, hand.PalmVelocity, hand.PalmNormal, hand.Direction));
                }
#endif

#if false
                // 一番左、右、手前の手を取得する
                HandList hands     = frame.Hands;
                Hand     leftMost  = hands.Leftmost;
                Hand     rightMost = hands.Rightmost;
                Hand     frontMost = hands.Frontmost;

                Console.WriteLine(string.Format("左 : {0} 右 : {1} 手前 : {2}",
                                                leftMost.PalmPosition, rightMost.PalmPosition, frontMost.PalmPosition));
#endif

#if false
                // 手に属している指とツールを取得する
                foreach (var hand in frame.Hands)
                {
                    Console.WriteLine(string.Format("ID : {0} ポインタ : {1} 指: {2} ツール : {3}",
                                                    hand.Id, hand.Pointables.Count, hand.Fingers.Count, hand.Fingers.Count));
                }
#endif

#if false
                // 指の情報を表示する
                Finger finger = frame.Fingers[0];
                Console.WriteLine(string.Format("ID : {0} 位置 : {1} 速度 : {2} 向き : {3}",
                                                finger.Id, finger.TipPosition, finger.TipVelocity, finger.Direction));
#endif
            }
 private void FixedUpdate()
 {
     currentFrame = leapMotionController.Frame();
     gestures = currentFrame.Gestures();
     hands = currentFrame.Hands;
     fingers = currentFrame.Fingers;
     tools = currentFrame.Tools;
 }
예제 #21
0
 static void EnableLeapAsCursor(Point coordinate, FingerList fingers)
 {
     if ((int)fingers[0].TipVelocity.Magnitude <= 25)
     {
         return;
     }
     LeapAsMouse.SetCursorPos((int)coordinate.X, (int)coordinate.Y);
 }
 protected Finger GetThumbFinger(FingerList fingers)
 {
     foreach (var finger in fingers)
     {
         if (finger.Type() == Finger.FingerType.TYPE_THUMB) return finger;
     }
     return null;
 }
예제 #23
0
 static void EnableClickWithLeap(Point coordinate, FingerList fingers)
 {
     if (fingers.Count != 2)
     {
         return;
     }
     LeapAsMouse.mouse_event(0x0002 | 0x0004, 0, (int)coordinate.X, (int)coordinate.Y, 0);
 }
예제 #24
0
    public override void OnFrame(Controller controller)
    {
        Frame currentFrame = controller.Frame();

        currentTime = currentFrame.Timestamp;
        changeTime  = currentTime - prevTime;
        if (changeTime > 5000)
        {
            Hand        hand          = currentFrame.Hands[0];
            FingerList  fingers       = hand.Fingers;
            Pointable   pointable     = currentFrame.Pointables[0];
            Leap.Screen screen        = controller.LocatedScreens.ClosestScreenHit(pointable);
            Frame       prevFrame     = controller.Frame(10);
            Hand        prevhand      = prevFrame.Hands[0];
            FingerList  prevfingers   = prevhand.Fingers;
            Pointable   prevpointable = prevFrame.Pointables[0];
            ScreenList  screenList    = controller.LocatedScreens;
            Leap.Screen prevscreen    = screenList.ClosestScreenHit(prevpointable);

            if (!fingers.IsEmpty)
            {
                float prevwidth  = prevscreen.Intersect(prevpointable, true, 1.0F).x *prevscreen.WidthPixels;
                float prevheight = prevscreen.Intersect(prevpointable, true, 1.0F).y *prevscreen.HeightPixels;
                float width      = screen.Intersect(pointable, true, 1.0F).x *screen.WidthPixels;
                float height     = screen.Intersect(pointable, true, 1.0F).y *screen.HeightPixels;
                float tranX      = currentFrame.Translation(prevFrame).x;
                float tranY      = currentFrame.Translation(prevFrame).y;
                int   fwidth     = (int)((width * 0.2) + (prevwidth * (1.0 - 0.2)));
                int   fheight    = (int)((height * 0.2) + (prevheight * (1.0 - 0.2)));
                fheight = screen.HeightPixels - fheight;
                if (fingers.Count == 2 || fingers.Count == 3)
                {
                    if (changeTime > 5000)
                    {
                        if (fingers.Count == 2)
                        {
                            mouse_event(0x0002 | 0x0004, 0, fwidth, fheight, 0);
                        }
                        else
                        {
                            mouse_event(0x0008 | 0x0010, 0, fwidth, fheight, 0);
                        }

                        Console.Write("Clicked At " + fwidth + " " + fheight);
                    }
                }
                else
                {
                    if (fingers.Count == 1)
                    {
                        Console.Write("TipPosition: " + fingers[0].TipPosition + " Width: " + width + " height: " + height + " tranX: " + tranX + " tranY: " + tranY + "\n");
                        SetCursorPos(fwidth, fheight);
                    }
                }
            }
            prevTime = currentTime;
        }
    }
예제 #25
0
파일: _Test2.cs 프로젝트: nastajus/LeapTry
 private static void drawRays(FingerList fingers, float length, float durationSeconds)
 {
     foreach (Finger finger in fingers)
     {
         Vector3 pos = finger.TipPosition.ToUnityScaled(); //Nastajus.Util.getVector3(finger.TipPosition);
         Vector3 dir = finger.Direction.ToUnityScaled();   //Nastajus.Util.getVector3(finger.Direction);
         Debug.DrawRay(pos, dir * length, Color.green, durationSeconds, true);
     }
 }
예제 #26
0
    // Update is called once per frame
    void Update()
    {
        Frame      frame   = controller.Frame();
        HandList   hands   = frame.Hands;
        FingerList fingers = frame.Fingers;
//		PointableList pointables = frame.Pointables;
        Hand rHand = frame.Hands[0];

//		Debug.Log("Hands : " + hands.Count + " Fingers : " + fingers.Count + " Extended Fingers : " + fingers.Extended().Count);
//		Debug.Log("左 : " + hands.Leftmost.PalmPosition + " 右 : " + hands.Rightmost.PalmPosition);
//		Debug.Log("右手 : " + rHand.IsRight + " ピンチ : " + rHand.PinchStrength + " グラブ : " + rHand.GrabStrength + " 信頼性 : " + rHand.Confidence);

        if (handId == -1)
        {
            handId = frame.Hands[0].Id;
        }
        else
        {
            Hand hand = frame.Hand(handId);
            handId = hand.Id;

//			Debug.Log(handId + " " + hand.PalmPosition);

            /*
             *      速度は	hand.PalmVelocity
             *      法線は	hand.PalmNormal
             *      向きは	hand.Direction
             *      で表示される
             */
        }

/*
 *              // 手に属している指を取得する
 *              foreach (var hand in frame.Hands) {
 *                      Debug.Log("ID : " + hand.Id + " 指 : " + hand.Fingers.Count);
 *              }
 */
/*
 *              // 指の情報を表示する
 *              foreach (var finger in frame.Fingers) {
 *                      if (finger.Type() == Finger.FingerType.TYPE_INDEX) {
 *                              Debug.Log("ID : " + finger.Id + " 種類 : " + finger.Type() + " 位置 : " + finger.TipPosition);
 *                      }
 *              }
 */

        // 指の関節情報を取得する
        foreach (var finger in frame.Fingers)
        {
            // 末端骨(指先の骨)
            var bone = finger.Bone(Bone.BoneType.TYPE_METACARPAL);
            if (finger.Type() == Finger.FingerType.TYPE_THUMB)
            {
                Debug.Log("種類 : " + bone.Type + " 長さ :" + bone.Length);
            }
        }
    }
예제 #27
0
 private Finger FindFingerByType(FingerList fingers, Finger.FingerType type)
 {
     foreach (var finger in fingers)
     {
         if (finger.Type () == type)
         return finger;
     }
     return null;
 }
예제 #28
0
        public static Point GetNormalizedXAndY(FingerList fingers, Screen screen)
        {
            var xNormalized = screen.Intersect(fingers[0], true, 1.0F).x;
            var yNormalized = screen.Intersect(fingers[0], true, 1.0F).y;

            var x = (xNormalized * screen.WidthPixels);
            var y = screen.HeightPixels - (yNormalized * screen.HeightPixels);

            return new Point(){X = x, Y = y };
        }
예제 #29
0
 void InitFingers(int count)
 {
     // 每个手指数据
     fingers = new Finger[count];
     for (int i = 0; i < count; ++i)
     {
         fingers[i] = new Finger(i);
     }
     touches = new FingerList();
 }
    void SetLeapAsMouse(FingerList fingers, Vector coordinate)
    {
        var screen = controller.CalibratedScreens.ClosestScreenHit(fingers[0]);

        if (screen == null || !screen.IsValid)
        {
            return;
        }
        // EnableLeapAsCursor(coordinate, fingers);
    }
예제 #31
0
    public static void OnFrame(Controller controller)
    {
        if (controller.IsConnected)
        {
            Frame frame = controller.Frame();

            if (!frame.Hands.IsEmpty)
            {
                Hand       hand    = frame.Hands[0];
                FingerList fingers = hand.Fingers;

                /*
                 * Debug.Log("1: " + hand.Fingers[0] + " 2: "+hand.Fingers[1]+ " 3: "+hand.Fingers[2]+ " 4: "+hand.Fingers[3]+ " 5: "+hand.Fingers[4] );
                 *
                 * if(!hand.Fingers[4].IsValid)
                 * {
                 *  Debug.Log("************************************************************************************************");
                 * }
                 */
                if (!fingers.IsEmpty)
                {
                    followFingers[5].transform.position = hand.PalmPosition.ToUnityTranslated();
                    followFingers[5].renderer.enabled   = true;

                    //if(hand.Fingers[i] == 0)

                    for (int i = 0; i < fingers.Count; i++)
                    {
                        // Visualizzo a video tutte le dita GameObject
                        followFingers[i].renderer.enabled = true;
                        // Prelievo i valori dei vettori creati dalle dita
                        followVector[i] = hand.Fingers[i].TipPosition.ToUnityTranslated();
                        followFingers[i].transform.position = followVector[i];
                    }

                    for (int i = 0; i < 5; i++)
                    {
                        if (!hand.Fingers[i].IsValid)
                        {
                            followFingers[i].renderer.enabled = false;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        // Visualizzo a video tutte le dita GameObject
                        followFingers[i].renderer.enabled = false;
                    }
                }
            }
        }
    }
예제 #32
0
 private Finger getFingerByType(FingerList fingers, Finger.FingerType type)
 {
     foreach (Finger finger in fingers)
     {
         if (finger.Type().Equals(type))
         {
             return(finger);
         }
     }
     return(null);
 }
예제 #33
0
 public bool UpdateData(FingerList fingers)
 {
     try
     {
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
예제 #34
0
파일: _Test2.cs 프로젝트: nastajus/LeapTry
    /// <summary>
    /// Accepts a list of fingers, and outputs PRY: Pitch, Roll, Yaw
    /// </summary>
    private static void logAllFingerDir(FingerList fingers)
    {
        string s = "";
        string dir;

        foreach (Finger finger in fingers)
        {
            dir = Nastajus.Util.getVector3(finger.Direction).ToString();
            s  += finger.Id + ": " + dir; //Util.RoundToDec(dir, 2) ;
        }
        Debug.Log(s);
    }
예제 #35
0
파일: _Test2.cs 프로젝트: nastajus/LeapTry
    private static void logAllFingerEulers(FingerList fingers)
    {
        string     s = "";
        Quaternion dir;

        foreach (Finger finger in fingers)
        {
            dir = Quaternion.Euler(Nastajus.Util.getVector3(finger.Direction));
            s  += finger.Id + ": " + dir; //Util.RoundToDec(dir, 2) ;
        }
        Debug.Log(s);
    }
예제 #36
0
파일: _Test2.cs 프로젝트: nastajus/LeapTry
    private static void logAllFingerPos(FingerList fingers)
    {
        string s = "";
        string dir;

        foreach (Finger finger in fingers)
        {
            dir = finger.Direction.ToUnityScaled().ToString();
            s  += finger.Id + ": " + dir; //Util.RoundToDec(dir, 2) ;
        }
        Debug.Log(s);
    }
예제 #37
0
        void OnFingersRegistered(FingerList fingers)
        {
            var screen = _controller.CalibratedScreens.ClosestScreenHit(fingers[0]);
            var coordinate = CalculationsHelper.GetNormalizedXAndY(fingers, screen);

            _dispatcher.Invoke(new Action(() =>
                                              {
                                                  GameModel.Fingers = fingers.Count;
                                                  MaintainScore(coordinate);
                                                  UpdateUIProperties(coordinate);
                                              }));
            SetLeapAsMouse(fingers,coordinate);
        }
예제 #38
0
파일: LeapMath.cs 프로젝트: intuilab/LeapIA
 /// <summary>
 /// Test if at least one finger is above the Leap. Permits to reduce the Leap's field of detection and to avoid untimely detection of hands (for HandPresent/HandLost events).
 /// </summary>
 /// <param name="fingers">The list of finger to test</param>
 /// <returns>If at least one finger is above the Leap</returns>
 public static bool IsAboveTheLeap(FingerList fingers)
 {
     foreach (Finger finger in fingers)
     {
         if (finger.TipPosition.x > -ParametersOther.Instance.LeapMath_xBoundaryForHandDetection
             && finger.TipPosition.x < ParametersOther.Instance.LeapMath_xBoundaryForHandDetection
             && finger.TipPosition.z > -ParametersOther.Instance.LeapMath_zBoundaryForHandDetection
             && finger.TipPosition.z < ParametersOther.Instance.LeapMath_zBoundaryForHandDetection)
         {
             return true;
         }
     }
     return false;
 }
예제 #39
0
        // Return true if the ring finger and pinky finger are folded.
        // This code checks it by calculating their angle from the index finger instead of checking
        // IsExtended property of the fingers.
        //
        // This is because the indexFinger's IsExtended property often becomes false
        // when you make this sushi gesture.
        // The IsExtended property bacomes false if you bend your finger only slightly.
        private bool IsProperFingersFolded(FingerList fingers)
        {
            Vector indexDirection =
                FindFingerByType(fingers, Finger.FingerType.TYPE_INDEX).Direction;
            Vector ringDirection =
                FindFingerByType(fingers, Finger.FingerType.TYPE_RING).Direction;
            Vector pinkyDirection =
                FindFingerByType(fingers, Finger.FingerType.TYPE_PINKY).Direction;

            float threshold = 0.6F;

            return indexDirection.Dot(ringDirection) < threshold &&
                   indexDirection.Dot(pinkyDirection) < threshold &&
                   indexDirection.Cross(ringDirection).Magnitude > 0 &&
                   indexDirection.Cross(pinkyDirection).Magnitude > 0;
        }
예제 #40
0
 private void RecordData(Frame frame, HandList hands, FingerList fingers)
 {
     if (CsvRecordingActivated)
     {
         lock (this)
         {
             foreach (Hand hand in hands)
             {
                 m_CSVWriter.RecordHand(frame.Id, hand.Id, hand.Fingers.Count, hand.PalmPosition, hand.PalmNormal, hand.PalmVelocity, hand.SphereCenter, hand.SphereRadius, frame.Timestamp);
             }
             foreach (Finger finger in fingers)
             {
                 m_CSVWriter.RecordFinger(frame.Id, finger.Id, finger.Hand.Id, fingers.Frontmost.Id == finger.Id, finger.Direction, finger.TipPosition, finger.TipVelocity, finger.Length, finger.Width, frame.Timestamp);
             }
         }
     }
 }
예제 #41
0
    public virtual void CheckGesture()
    {
        this._lastFrame = this._leap_controller.Frame(0);
        this.Hands = this._lastFrame.Hands;
        this._gestures = this._lastFrame.Gestures();

        foreach(Hand hand in Hands)
        {
            tempHand = hand;
            _fingers = hand.Fingers;

            if (WhichSide.IsEnableGestureHand(this))
            {
                this._fingers = hand.Fingers;

                foreach (Gesture gesture in _gestures)
                {

                    if ((gesture.Type == Gesture.GestureType.TYPE_KEY_TAP) && WhichSide.capturedSide(hand, _useArea, _mountType))
                    {
                        _keytab_gesture = new KeyTapGesture(gesture);
                        this.GetDirection();
                        this.GetPointable();
                        this.GestureInvokePosition();

                        this._isChecked = true;
                        break;

                    }
                }
            }

            if (this._isChecked)
                break;
        }
       
        if (this._isChecked)
        {
            DoAction();
        }
    }
        private static Leap.Vector[] MapCalibratedCameraToColor( Leap.Image image, FingerList fingers,
                                                                    int targetWidth, int targetHeight )
        {
            var colorPoints =new List<Leap.Vector>();

            float cameraXOffset = 20; //millimeters

            foreach ( Finger finger in fingers ) {
                var tip = finger.TipPosition;
                float hSlope = -(tip.x + cameraXOffset * (2 * image.Id - 1)) / tip.y;
                float vSlope = tip.z / tip.y;

                var ray = new Leap.Vector( hSlope * image.RayScaleX + image.RayOffsetX,
                                     vSlope * image.RayScaleY + image.RayOffsetY, 0 );

                //Pixel coordinates from [0..1] to [0..width/height]
                colorPoints.Add( new Leap.Vector( ray.x * targetWidth, ray.y * targetHeight, 0 ) );
            }

            return colorPoints.ToArray();
        }
예제 #43
0
        public static Hand MakeTestHand(int frameId, int handId, bool isLeft)
        {
            FingerList fingers = new FingerList(5);
            fingers.Add(MakeThumb (frameId, handId));
            fingers.Add(MakeIndexFinger (frameId, handId));
            fingers.Add(MakeMiddleFinger (frameId, handId));
            fingers.Add(MakeRingFinger (frameId, handId));
            fingers.Add( MakePinky (frameId, handId));

            Vector armWrist = new Vector(-7.05809944059f, 4.0f, 50.0f);
            Vector elbow = armWrist + 250f * Vector.Backward;
            Matrix armBasis = new Matrix(Vector.Right, Vector.Down, Vector.Forward);
            Arm arm = new Arm(elbow,armWrist,(elbow + armWrist)/2, Vector.Forward, 250f, 41f, Bone.BoneType.TYPE_DISTAL, armBasis);
            Hand testHand = new Hand(frameId,
            handId,
            1.0f,
            0.0f,
            0.0f,
            0.0f,
            0.0f,
            85f,
            isLeft,
            0.0f,
            arm,
                fingers,
                new Vector (0,0,0),
                new Vector(0,0,0),
                new Vector(0,0,0),
                Vector.Down,
                Vector.Backward,
                new Vector(-4.36385750984f, 6.5f, 31.0111342526f)
            );

            if(isLeft){
                return testHand;
            } else {
                Matrix leftToRight = new Matrix(Vector.Right, Vector.Up, Vector.Forward);
                return testHand.TransformedCopy(leftToRight);
            }
        }
예제 #44
0
 private void HandDetection(HandList hands, FingerList fingers)
 {
     /********************** HAND DETECTION ************************************/
     if ((!hands.IsEmpty && LeapMath.IsAboveTheLeap(hands)) || (!fingers.IsEmpty && LeapMath.IsAboveTheLeap(fingers))) // if there is at least one hand or one finger, and if it is more or less above the device
     {
         // and if this hand was not present in the previous frame
         if (!m_HandInPreviousFrame)
         {
             RaiseHandPresentEvent(); // we raise the HandPresent event
             m_HandInPreviousFrame = true;
         }
     }
     else
     {
         if (m_HandInPreviousFrame)
         {
             RaiseHandRemovedEvent(); // but if there is no hand or finger in this frame, but there was in the previous frame, we raise the HandRemoved event
             m_HandInPreviousFrame = false;
         }
     }
     /***************************************************************************/
 }
        /// <summary>
        /// 3次元の手の座標をカメラの2次元座標に変換する
        /// </summary>
        /// <param name="image"></param>
        /// <param name="fingers"></param>
        /// <returns></returns>
        private static Leap.Vector[] MapCameraToColor( Leap.Image image, FingerList fingers )
        {
            var colorPoints =new List<Leap.Vector>();

            float cameraOffset = 20; //x-axis offset in millimeters
            foreach ( Finger finger in fingers ) {
                // 3次元座標を2次元座標に変換する
                var tip = finger.TipPosition;
                float hSlope = -(tip.x + cameraOffset * (2 * image.Id - 1)) / tip.y;
                float vSlope = tip.z / tip.y;

                colorPoints.Add( image.Warp( new Leap.Vector( hSlope, vSlope, 0 ) ) );
            }

            return colorPoints.ToArray();
        }
예제 #46
0
        public void undateTouches(FingerList fingerlist)
        {
            ScreenList screenList = this.controllerr.CalibratedScreens;

            for(int ii = 0; ii < fingerlist.Count; ii++)
            {
                Console.Write(fingerlist[ii].Id+"  ");
            }

            Console.WriteLine();

            for (int i = 0; i < fingerlist.Count; i++) {
                Leap.Screen screen = screenList.ClosestScreenHit(fingerlist[i]);
                Vector intersection = screen.Intersect(fingerlist[i], true);
                float screenw = screen.WidthPixels;
                float screenh = screen.HeightPixels;

                int posx = (int)(intersection.x * screenw)  ;    // actual x position on your screen
                int posy = (int)(screenh - intersection.y * screenh) ;     // actual y position on your screen

                /*if(i == fingerlist[i].Id)
                {
                    if(hiren[i] == 0)
                    {
                        if(fingerlist[i].TipPosition.z < 0)
                        {
                            touchPoints[i] = MakePointerTouchInfo(posx, posy, 20, (uint)(i+1));
                            touchPoints[i].PointerInfo.PointerFlags = PointerFlags.DOWN | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                            hiren[i] = 1;
                        }
                        else
                        {
                            for(int ii = 0; ii < fingerlist.Count; ii++)
                            {
                                Console.Write(fingerlist[ii].Id+"  ");
                            }
                            drawCircle(posx, posy);
                        }
                    }
                    else
                    {
                        if(fingerlist[i].TipPosition.z > 0)
                        {
                            touchPoints[i].PointerInfo.PointerFlags = PointerFlags.UP;
                            hiren[i] = 0;
                        }
                        else
                        {
                            touchPoints[i].PointerInfo.PointerFlags = PointerFlags.UPDATE | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                            int moveX = posx - touchPoints[0].PointerInfo.PtPixelLocation.X;
                            int moveY = posy - touchPoints[0].PointerInfo.PtPixelLocation.Y;
                            touchPoints[0].Move((int)(moveX), (int)(moveY));
                        }
                    }
                }
                else
                {
                    touchPoints[i].PointerInfo.PointerFlags = PointerFlags.UPDATE | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                    touchPoints[i].Move(0, 0);
                }*/
                bool s = TouchInjector.InjectTouchInput(noOfTouch, touchPoints);
            }
        }
예제 #47
0
 static void EnableLeapAsCursor(Point coordinate, FingerList fingers)
 {
     if ((int) fingers[0].TipVelocity.Magnitude <= 25) return;
     LeapAsMouse.SetCursorPos((int)coordinate.X, (int)coordinate.Y);
 }
예제 #48
0
 static void EnableClickWithLeap(Point coordinate,FingerList fingers)
 {
     if (fingers.Count != 2) return;
      LeapAsMouse.mouse_event(0x0002 | 0x0004, 0, (int) coordinate.X, (int) coordinate.Y, 0);
 }
예제 #49
0
 void SetLeapAsMouse(FingerList fingers, Point coordinate)
 {
     if (!_enableMouse) return;
     var screen = _controller.CalibratedScreens.ClosestScreenHit(fingers[0]);
     if (screen == null || !screen.IsValid) return;
     EnableLeapAsCursor(coordinate, fingers);
     EnableClickWithLeap(coordinate, fingers);
 }
예제 #50
0
    //-----------------------------------------------------
    // Function for check gesture occur every frame.
    public virtual void CheckGesture()
    {
        _lastFrame = _leap_controller.Frame();
        Hands = _lastFrame.Hands;
        _gestures = _lastFrame.Gestures();


        foreach(Hand hand in Hands)
        {
            tempHand = hand;
            _fingers = hand.Fingers;
            
            if (WhichSide.IsEnableGestureHand(this))
            {
                foreach (Gesture gesture in _gestures)
                {

                    if (gesture.Type == Gesture.GestureType.TYPE_SWIPE)
                    {
                        _swipe_gestrue = new SwipeGesture(gesture);

                        if (!_isPlaying && gesture.State == Gesture.GestureState.STATE_START && WhichSide.capturedSide(hand, _useArea, this._mountType))
                        {
                            _isPlaying = true;
                            _startPoint = hand.PalmPosition;
                        }

                        if (_isPlaying && gesture.State == Gesture.GestureState.STATE_STOP)
                        {
                            _endPoint = hand.PalmPosition;
                            switch (UseAxis)
                            {
                                case 'x':
                                    if (((_endPoint.x - _startPoint.x) * _useDirection) > Sensitivity)
                                    {
                                        this._isChecked = true;
                                        _isPlaying = !_isPlaying;
                                        break;
                                    }
                                    _state = gesture.State;
                                    break;
                                case 'y':
                                    if (((_endPoint.y - _startPoint.y) * _useDirection) > Sensitivity)
                                    {

                                        this._isChecked = true;
                                        _isPlaying = !_isPlaying;
                                        break;
                                    }
                                    _state = gesture.State;
                                    break;
                                case 'z':
                                    if (_startPoint.y < this._maxY && _endPoint.y < this._maxY &&
                                        ((_endPoint.z - _startPoint.z) * _useDirection) > Sensitivity)
                                    {
                                        this._isChecked = true;
                                        _isPlaying = !_isPlaying;
                                        _state = gesture.State;
                                        break;
                                    }
                                    _state = gesture.State;
                                    break;
                                default:
                                    break;
                            }
                        }

                        if (!this._isPlaying || this._isChecked)
                        {
                            break;
                        }

                        _state = gesture.State;
                    }

                }

                if (_isPlaying && _state == Gesture.GestureState.STATE_UPDATE && WhichSide.capturedSide(hand, _useArea, this.MountType))
                {
                    _endPoint = hand.PalmPosition;
                    switch (UseAxis)
                    {
                        case 'x':
                            if (((_endPoint.x - _startPoint.x) * _useDirection) > Sensitivity)
                            {

                                this._isChecked = true;
                                _isPlaying = !_isPlaying;
                                break;
                            }
                            break;
                        case 'y':
                            if (((_endPoint.y - _startPoint.y) * _useDirection) > Sensitivity)
                            {

                                this._isChecked = true;
                                _isPlaying = !_isPlaying;
                                break;
                            }
                            break;
                        case 'z':
                            if (_startPoint.y < this._maxY && _endPoint.y < this._maxY &&
                                ((_endPoint.z - _startPoint.z) * _useDirection) > Sensitivity)
                            {
                                this._isChecked = true;
                                _isPlaying = !_isPlaying;
                                break;
                            }
                            else
                            {
                                _isPlaying = !_isPlaying;
                            }
                            break;
                        default:
                            break;
                    }

                }


            }
        }
       

        // -------------------- 
        // If Gesture is captured, call the handler function 'DoAction()'
        if (_isChecked)
        {
            DoAction();
        }
        //---------------------
    }
 public void SwipeAction(FingerList fingers, MotionSwipeGestureRecognizerDirection sd)
 {
     /*
     fingersCount = fingers.Count();
     if (fingersCount == 5)
     {
         switch (sd)
         {
             case SwipeDirection.Left:
                 if (LeapSwipe != null)
                 {
                     LeapSwipe(SwipeDirection.Left);
                 }
                 break;
             case SwipeDirection.Right:
                 if (LeapSwipe != null)
                 {
                     LeapSwipe(SwipeDirection.Right);
                 }
                 break;
             case SwipeDirection.Up:
                 if (LeapSwipe != null)
                 {
                     LeapSwipe(SwipeDirection.Up);
                 }
                 break;
             case SwipeDirection.Down:
                 if (LeapSwipe != null)
                 {
                     LeapSwipe(SwipeDirection.Down);
                 }
                 break;
         }
     }*/
 }
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            if (controller.IsConnected)
            {
                //clear fingers
                fingerPoints.Clear();
                var frame = controller.Frame();

                debugLine = "";

                SafeWriteLine("Frame id: " + frame.Id
                        + ", timestamp: " + frame.Timestamp
                        + ", hands: " + frame.Hands.Count
                        + ", fingers: " + frame.Fingers.Count
                        + ", tools: " + frame.Tools.Count
                        + ", gestures: " + frame.Gestures().Count);

                if (!(frame.Hands.Count() == 0 ))
                {
                    // Get the first hand
                    hand = frame.Hands[0];

                    firstHandLoc = new Vector2(NormalizeWidth(hand.SphereCenter.x), NormalizeHeight( hand.SphereCenter.y));
                    // Check if the hand has any fingers
                    fingers = hand.Fingers;
                    if (!(fingers.Count() == 0))
                    {
                        // Calculate the hand's average finger tip position
                        Vector avgPos = Vector.Zero;
                        foreach (Finger finger in fingers)
                        {
                            fingerPoints.Add(new Vector2(
                                NormalizeWidth(finger.TipPosition.x),
                                NormalizeHeight(finger.TipPosition.y)
                                )
                            );
                            avgPos += finger.TipPosition;
                        }
                        avgPos /= fingers.Count;

                        SafeWriteLine("Hand has " + fingers.Count
                                    + " fingers, average finger tip position: " + avgPos);

                    }

                    // Get the hand's sphere radius and palm position

                    SafeWriteLine("Hand sphere radius: " + hand.SphereRadius.ToString("n2")
                                + " mm, palm position: " + hand.PalmPosition);

                    // Get the hand's normal vector and direction
                    Vector normal = hand.PalmNormal;
                    Vector direction = hand.Direction;

                    // Calculate the hand's pitch, roll, and yaw angles

                    SafeWriteLine("Hand pitch: " + direction.Pitch * 180.0f / (float)Math.PI + " degrees, "
                                + "roll: " + normal.Roll * 180.0f / (float)Math.PI + " degrees, "
                                + "yaw: " + direction.Yaw * 180.0f / (float)Math.PI + " degrees");

                }

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

                    switch (gesture.Type)
                    {
                        case Gesture.GestureType.TYPECIRCLE:
                            CircleGesture circle = new CircleGesture(gesture);

                            // Calculate clock direction using the angle between circle normal and pointable
                            String clockwiseness;
                            if (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4)
                            {
                                //Clockwise if angle is less than 90 degrees
                                clockwiseness = "clockwise";
                            }
                            else
                            {
                                clockwiseness = "counterclockwise";
                            }

                            float sweptAngle = 0;

                            // Calculate angle swept since last frame
                            if (circle.State != Gesture.GestureState.STATESTART)
                            {
                                CircleGesture previousUpdate = new CircleGesture(controller.Frame(1).Gesture(circle.Id));
                                sweptAngle = (circle.Progress - previousUpdate.Progress) * 360;
                            }

                            SafeWriteLine("Circle id: " + circle.Id
                                           + ", " + circle.State
                                           + ", progress: " + circle.Progress
                                           + ", radius: " + circle.Radius
                                           + ", angle: " + sweptAngle
                                           + ", " + clockwiseness);

                            break;
                        case Gesture.GestureType.TYPESWIPE:
                            SwipeGesture swipe = new SwipeGesture(gesture);

                            SafeWriteLine("Swipe id: " + swipe.Id
                                           + ", " + swipe.State
                                           + ", position: " + swipe.Position
                                           + ", direction: " + swipe.Direction
                                           + ", speed: " + swipe.Speed);

                            break;
                        case Gesture.GestureType.TYPEKEYTAP:
                            KeyTapGesture keytap = new KeyTapGesture(gesture);

                            SafeWriteLine("Tap id: " + keytap.Id
                                           + ", " + keytap.State
                                           + ", position: " + keytap.Position
                                           + ", direction: " + keytap.Direction);

                            break;
                        case Gesture.GestureType.TYPESCREENTAP:
                            ScreenTapGesture screentap = new ScreenTapGesture(gesture);

                            SafeWriteLine("Tap id: " + screentap.Id
                                           + ", " + screentap.State
                                           + ", position: " + screentap.Position
                                           + ", direction: " + screentap.Direction);

                            break;
                        default:
                            SafeWriteLine("Unknown gesture type.");
                            break;
                    }
                }

                if (!(frame.Hands.Count() == 0) || !(frame.Gestures().Count ==0))
                {
                    //SafeWriteLine("");
                }
            }
            base.Update(gameTime);
        }
예제 #53
0
        public ArrayList leftHandFingers(FingerList fingers, Finger cursor_finger)
        {
            ArrayList fingers_on_left_hand = new ArrayList();

            foreach(Finger finger in fingers)
            {
                if (!finger.Equals(cursor_finger))
                {
                    float x_diff = cursor_finger.TipPosition.x - finger.TipPosition.x;
                    if (x_diff > 5)
                    {
                        fingers_on_left_hand.Add(finger);
                    }
                }
            }

            return fingers_on_left_hand;
        }
예제 #54
0
    void Update()
    {
		// Label variables
		GameObject taggedText = GameObject.FindWithTag ("CurrAction");

		// Rotate variables
        rightHand = controller.Frame().Hands.Rightmost;
		leftHand = controller.Frame ().Hands.Leftmost;
		extendedR = rightHand.Fingers.Extended ();
		extendedL = leftHand.Fingers.Extended ();
		indexFinger = controller.Frame().Hands.Rightmost.Fingers [(int)Finger.FingerType.TYPE_INDEX];
		thumbFinger = controller.Frame().Hands.Rightmost.Fingers [(int)Finger.FingerType.TYPE_THUMB];
		pinchDistance = (indexFinger.TipPosition - thumbFinger.TipPosition).ToUnityScaled();
		tipDistance = pinchDistance.magnitude;
		currPosition = rightHand.PalmPosition.ToUnityScaled();

		// Zoom variables
		currMainPosition = rightHand.PalmPosition.ToUnityScaled();
		currOffPosition = leftHand.PalmPosition.ToUnityScaled();
		currDistance = currMainPosition - currOffPosition;

	//////////////////////////////////////////////////////////////////////////////////////////

		// USING CURSOR
		if (extendedR.Count == 1 && rightHand.IsRight && selectMode == 1) {
			if (!showingConnections)
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Using Cursor";
			else
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Selected. Pausing Cursor";
			cursor.transform.position = new Vector3 (indexFinger.TipPosition.ToUnityScaled ().x * 150, 
				(indexFinger.TipPosition.ToUnityScaled ().y * 90) - 25,
				camera.transform.position.z + 10);

			Ray ray = new Ray (camera.transform.position, cursor.transform.position - camera.transform.position);
			RaycastHit raycastInfo;					
			Color c = new Color (255 / 255f, 116 / 255f, 26 / 255f, 255 / 255f);
			if (Physics.Raycast (ray, out raycastInfo, 1000) && !showingConnections) {
				if (hoveredNode != null && hoveredNode.name.CompareTo (raycastInfo.transform.gameObject.name) != 0) {
					// if the node selected is different from the last one
					hoveredNode.GetComponent<Renderer> ().material.SetColor ("_Color", c);
					deselect = false;
				}

				// assign the new node on both cases
				hoveredNode = raycastInfo.transform.gameObject;
				if (!deselect) {
					hoveredNode.GetComponent<Renderer> ().material.SetColor ("_Color", Color.blue);
					int x = 0;
					Int32.TryParse (hoveredNode.name, out x);
					string dolphinName = graph.nodes [x].label;
					GameObject.FindWithTag ("DolphinName").GetComponent<UnityEngine.UI.Text> ().text = dolphinName;
				}
				if (deselect) {
					// un-assign the node if the new node is the same as the old one
					hoveredNode.GetComponent<Renderer> ().material.SetColor ("_Color", c);
					GameObject.FindWithTag ("DolphinName").GetComponent<UnityEngine.UI.Text> ().text = "";
					hoveredNode = null;
				}
			} else if(!showingConnections) {
				if (hoveredNode != null) {
					deselect = true;
				} else {
					deselect = false;
				}
			}

			// DETECT A LEFT HAND SWIPE TO DELETE A NODE
			GestureList maybeGestures = controller.Frame ().Gestures ();
			for (int i = 0; i < maybeGestures.Count; i++) {
				Gesture gesture = maybeGestures [i];
				// check if the gesture is invalid which can happen
				if (gesture.IsValid && gesture.Type == Gesture.GestureType.TYPE_SWIPE) {
					HandList involvedHands = gesture.Hands;
					if (involvedHands.Count == 1 && involvedHands [0].IsLeft) {
						// call DestroyNode()
						DestroyNode (hoveredNode); // always destroys input node
					}
				}
			}

			// DETECT A LEFT HAND CIRCLE TO SHOW CONNECTIONS
			for (int i = 0; i < maybeGestures.Count; i++) {
				Gesture gesture = maybeGestures [i];
				// check if gesture is invalid
				if (gesture.IsValid && gesture.Type == Gesture.GestureType.TYPE_KEY_TAP) {
					HandList involvedHands = gesture.Hands;
					if (involvedHands.Count == 1 && involvedHands [0].IsLeft) {
						//toggle showConnections
						showingConnections = !showingConnections;
						ShowConnect (hoveredNode);
					}
				}
			}

			// DETECT A HELD FIST IN LEFT HAND
			if (controller.Frame ().Hands.Count == 2 && leftHand.GrabStrength == 1.0 && leftHand.IsLeft) {
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Centering Object...";
				if (startLeftClench == false) {
					startLeftClench = true;
					lastTimeLeftClench = Time.time;
					timeDiffLeftClench = 0;
				} else {
					timeDiffLeftClench = Time.time - lastTimeLeftClench;
					if (timeDiffLeftClench > 3) {
						startLeftClench = false;
						// do action here
						Vector3 fromDir = hoveredNode.transform.position;
						Vector3 toDir = new Vector3 (0, 0, -5);
						transform.rotation = Quaternion.FromToRotation (fromDir, toDir) * transform.rotation;
					}
				}
			}

		} // end Using Cursor for mode 1 ///////////////////////////////////////////////////////////////////

		else if (extendedR.Count == 1 && rightHand.IsRight && selectMode == 3) {
			if(!showingConnections)
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Using Cursor";
			else
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Selected. Pausing Cursor";
			cursor.transform.position = new Vector3 (indexFinger.TipPosition.ToUnityScaled ().x * 150, 
				(indexFinger.TipPosition.ToUnityScaled ().y * 90) - 25,
				camera.transform.position.z + 10);

			Ray ray = new Ray (camera.transform.position, cursor.transform.position - camera.transform.position);
			RaycastHit raycastInfo;					
			Color c = new Color (255 / 255f, 116 / 255f, 26 / 255f, 255 / 255f);
			if (Physics.Raycast (ray, out raycastInfo, 1000) && !showingConnections) {
				if (selectedNodes.Contains (raycastInfo.transform.gameObject) && !cursOnNode) {
					// reset node color if the node is already selected
					selectedNodes [selectedNodes.IndexOf (raycastInfo.transform.gameObject)].GetComponent<Renderer> ().material.SetColor ("_Color", c);
					selectedNodes.RemoveAt (selectedNodes.IndexOf (raycastInfo.transform.gameObject));
				} 
				else if(!cursOnNode) {
					raycastInfo.transform.gameObject.GetComponent<Renderer> ().material.SetColor ("_Color", Color.blue);
					selectedNodes.Add (raycastInfo.transform.gameObject);
				}
				cursOnNode = true;
			} 
			else {
				cursOnNode = false;
			}

			// DETECT A LEFT HAND SWIPE TO DELETE A NODE
			GestureList maybeGestures = controller.Frame ().Gestures ();
			for (int i = 0; i < maybeGestures.Count; i++) {
				Gesture gesture = maybeGestures [i];
				// check if the gesture is invalid which can happen
				if (gesture.IsValid && gesture.Type == Gesture.GestureType.TYPE_SWIPE) {
					HandList involvedHands = gesture.Hands;
					if (involvedHands.Count == 1 && involvedHands [0].IsLeft) {
						// call DestroyNode()
						while(selectedNodes.Count > 0) {
							DestroyNode (selectedNodes[0]);
							selectedNodes.RemoveAt (0);
						}
					}
				}
			}

			// DETECT A LEFT HAND CIRCLE TO SHOW CONNECTIONS
			for (int i = 0; i < maybeGestures.Count; i++) {
				Gesture gesture = maybeGestures [i];
				// check if gesture is invalid
				if (gesture.IsValid && gesture.Type == Gesture.GestureType.TYPE_KEY_TAP) {
					HandList involvedHands = gesture.Hands;
					if (involvedHands.Count == 1 && involvedHands [0].IsLeft) {
						//toggle showConnections
						showingConnections = !showingConnections;
						for (int n = 0; n < selectedNodes.Count; n++) {
							ShowConnect (selectedNodes[n]);
						}
					}
				}
			}
		} /////// end of Sequential Select mode ///////////////////////////////////////////////


		else if (extendedR.Count == 1 && rightHand.IsRight && selectMode == 2) {
			if(!showingConnections)
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Using Cursor";
			else
				taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Selected. Pausing Cursor";
			wideCursor.transform.position = new Vector3 (indexFinger.TipPosition.ToUnityScaled ().x * 200, 
				(indexFinger.TipPosition.ToUnityScaled ().y * 130) - 42,
				0);

			Color c = new Color (255 / 255f, 116 / 255f, 26 / 255f, 255 / 255f);

			if (!showingConnections) {
				// clear all selection
				while (selectedNodes.Count > 0) {
					selectedNodes [0].GetComponent<Renderer> ().material.SetColor ("_Color", c);
					selectedNodes.RemoveAt (0);
				}

				// choose all selected
				for (int n = 0; n < ForceDirected.nodeList.Count; n++) {
					GameObject node = ForceDirected.nodeList [n].gameObject;
					float znode = node.transform.position.z - camera.transform.position.z;
					float zcursor = wideCursor.transform.position.z - camera.transform.position.z;
					float xmin = znode * (wideCursor.transform.position.x - 10) / (zcursor);
					float xmax = znode * (wideCursor.transform.position.x + 10) / (zcursor);
					float ymin = znode * (wideCursor.transform.position.y - 10) / (zcursor);
					float ymax = znode * (wideCursor.transform.position.y + 10) / (zcursor);

					if (node.transform.position.x >= xmin &&
					  node.transform.position.x <= xmax &&
					  node.transform.position.y >= ymin &&
					  node.transform.position.y <= ymax) {
						node.GetComponent<Renderer> ().material.SetColor ("_Color", Color.blue);
						selectedNodes.Add (node);
					}
				}
			}

			// DETECT A LEFT HAND SWIPE TO DELETE A NODE
			GestureList maybeGestures = controller.Frame ().Gestures ();
			for (int i = 0; i < maybeGestures.Count; i++) {
				Gesture gesture = maybeGestures [i];
				// check if the gesture is invalid which can happen
				if (gesture.IsValid && gesture.Type == Gesture.GestureType.TYPE_SWIPE) {
					HandList involvedHands = gesture.Hands;
					if (involvedHands.Count == 1 && involvedHands [0].IsLeft) {
						// call DestroyNode()
						while(selectedNodes.Count > 0) {
							DestroyNode (selectedNodes[0]);
							selectedNodes.RemoveAt (0);
						}
					}
				}
			}

			// DETECT A LEFT HAND CIRCLE TO SHOW CONNECTIONS
			for (int i = 0; i < maybeGestures.Count; i++) {
				Gesture gesture = maybeGestures [i];
				// check if gesture is invalid
				if (gesture.IsValid && gesture.Type == Gesture.GestureType.TYPE_KEY_TAP) {
					HandList involvedHands = gesture.Hands;
					if (involvedHands.Count == 1 && involvedHands [0].IsLeft) {
						//toggle showConnections
						showingConnections = !showingConnections;
						for (int n = 0; n < selectedNodes.Count; n++) {
							ShowConnect (selectedNodes[n]);
						}
					}
				}
			}
		} /////// end of Volume Select mode /////////////////////////////////////


		// CHANGE SELECT MODE (LEFT HAND): 1 FINGER = NORMAL SELECT; 2 FINGER = VOLUME SELECT; 3 FINGER = SEQUENTIAL SELECT
		else if(controller.Frame().Hands.Count == 1 && rightHand.IsLeft) {
			if (extendedL.Count >= 1 && extendedL.Count <= 3 && !showingConnections) {
				selectMode = extendedL.Count;
				GameObject modeText = GameObject.FindWithTag ("Mode");
				switch (extendedL.Count) {
					case 2:
						modeText.GetComponent<UnityEngine.UI.Text> ().text = "Volume";
						cursor.SetActive (false);
						wideCursor.SetActive (true);
						break;
					case 3:
						modeText.GetComponent<UnityEngine.UI.Text> ().text = "Sequential";
						cursor.SetActive (true);
						wideCursor.SetActive (false);
						break;
					case 1:
						modeText.GetComponent<UnityEngine.UI.Text> ().text = "Single";
						cursor.SetActive (true);
						wideCursor.SetActive (false);
						break;
					default:
						break;
				}

				// When switching modes, deselect everything!
				Color c = new Color (255 / 255f, 116 / 255f, 26 / 255f, 255 / 255f);
				if(hoveredNode != null)
					hoveredNode.GetComponent<Renderer> ().material.SetColor ("_Color", c);
				hoveredNode = null;
				deselect = false;

				while (selectedNodes.Count > 0) {
					selectedNodes [0].GetComponent<Renderer> ().material.SetColor ("_Color", c);
					selectedNodes.RemoveAt (0);
					cursOnNode = false;
				}
			}
		}

		// ROTATE GRAPH
		else if (controller.Frame().Hands.Count == 1 && leftHand.IsRight && tipDistance < 0.02 && rightHand.PinchStrength == 1.0 
			&& rightHand.GrabStrength != 1.0 && extendedR.Count > 1)
        {
            handDelta = currPosition - prevPosition;
            handDelta *= 1000;

            transform.rotation = Quaternion.Euler(handDelta.y, -handDelta.x, 0) * transform.rotation;
			taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Rotating";
        }

		// ZOOM GRAPH
		else if (controller.Frame().Hands.Count == 2 && (rightHand.PinchStrength == 1.0 && leftHand.PinchStrength == 1.0))
		{
			magnitude = currDistance.magnitude - prevDistance.magnitude;
			magnitude *= 300;
			/*
			if (camera.fieldOfView + magnitude > 180)
				camera.fieldOfView = 179;

			else if (camera.fieldOfView + magnitude < 0)
				camera.fieldOfView = 1;

			else
				camera.fieldOfView += magnitude;*/

			camera.transform.position = new Vector3(camera.transform.position.x, camera.transform.position.y, 
				camera.transform.position.z + magnitude);
			cursor.transform.position = new Vector3(cursor.transform.position.x, cursor.transform.position.y, 
				camera.transform.position.z + 10);

			taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Zooming";
		}

		// RESET ZOOM
		else if (controller.Frame ().Hands.Count == 1 && rightHand.GrabStrength == 1.0 && rightHand.IsRight) {
			taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Resetting view...";
			if(startAction == false) {
				startAction = true;
				lastTime = Time.time;
				timeDiff = 0;
			}
			else {
				timeDiff = Time.time - lastTime;
				if(timeDiff > 2) {
					startAction = false;
					// do action here
					float maxNewZ = 1000;
					for (int n = 0; n < ForceDirected.nodeList.Count; n++) {
						GameObject node = ForceDirected.nodeList [n].gameObject;
						float maxOfXY = Mathf.Abs(node.transform.position.x) > Mathf.Abs(node.transform.position.y) ? Mathf.Abs(node.transform.position.x) : Mathf.Abs(node.transform.position.y);
						// float zDist = Mathf.Abs(node.transform.position.z - camera.transform.position.z);
						// positive max distance the camera needs to be away from this node's z value
						float zNew = (maxOfXY / (float) Math.Tan (65.0f * 3.1415926f / 360.0f));

						// get the absolute position for the camera
						zNew = node.transform.position.z - zNew;
						maxNewZ = maxNewZ < zNew ? maxNewZ : zNew;
					}
					camera.transform.position = new Vector3(0, 0, maxNewZ - 10);
				}
			}
		}

		// STANDING BY
		else {
			taggedText.GetComponent<UnityEngine.UI.Text> ().text = "Standing By";
		}
			
	//////////////////////////////////////////////////////////////////////////////////////////

		// RESET ZOOM CONTROL
		if (controller.Frame ().Hands.Count != 1 || rightHand.GrabStrength != 1.0) {
			startAction = false;

		}


		prevDistance = currDistance;




		// used for rotate
        prevPosition = currPosition;
	} // end Update()
예제 #55
0
    //Function to check if only the index finger is extended and the other fingers are not
    bool onlyIndexFingerExtended(FingerList fingerList)
    {
        if (indexFinger.IsExtended &&
            !fingerList.FingerType(Finger.FingerType.TYPE_THUMB)[0].IsExtended &&
            !fingerList.FingerType(Finger.FingerType.TYPE_MIDDLE)[0].IsExtended &&
            !fingerList.FingerType(Finger.FingerType.TYPE_RING)[0].IsExtended &&
            !fingerList.FingerType(Finger.FingerType.TYPE_PINKY)[0].IsExtended)
            return true;

        return false;
    }
        /// <summary>
        /// Returns the list of fingers which exceed a certain minimum
        /// length. This provides a best guess of which fingers the user
        /// intended to be visible.
        /// </summary>
        /// 
        /// <param name="fingers">List of fingers detected in a Leap frame.</param>
        /// <param name="limitSpace">If true, only accept fingers in the gesture space.</param> 
        protected List<Finger> ExtendedFingers(FingerList fingers, bool limitSpace)
        {
            List<Finger> extended = new List<Finger>();

            foreach (Finger finger in fingers)
            {
                Vector tip = finger.TipPosition;

                if (finger.Length >= MIN_FINGER_LENGTH &&
                    tip.y >= MIN_HEIGHT &&
                    (limitSpace == false && Math.Abs(finger.Direction.y) < Y_THRESHOLD ||
                    (tip.z < GestureSpace.Bottom + SPACE_PADDING &&
                    tip.x > GestureSpace.Left - SPACE_PADDING &&
                    tip.x < GestureSpace.Right + SPACE_PADDING)))
                {
                    extended.Add(finger);
                }
            }

            return extended;
        }
예제 #57
0
 public Hand(int frameID,
             int id,
             float confidence,
             float grabStrength,
             float grabAngle,
             float pinchStrength,
             float pinchDistance,
             float palmWidth,
             bool isLeft,
             float timeVisible,
             Arm arm,
             FingerList fingers,
             Vector palmPosition,
             Vector stabilizedPalmPosition,
             Vector palmVelocity,
             Vector palmNormal,
             Vector direction,
             Vector wristPosition)
 {
     _frameId = frameID;
     _id = id;
     _confidence = confidence;
     _grabStrength = grabStrength;
     _grabAngle = grabAngle;
     _pinchStrength = pinchStrength;
     _pinchDistance = pinchDistance;
     _palmWidth = palmWidth;
     _isLeft = isLeft;
     _isRight = !isLeft;
     _timeVisible = timeVisible;
     _arm = arm;
     _fingers = fingers;
     _palmPosition = palmPosition;
     _stabilizedPalmPosition = stabilizedPalmPosition;
     _palmVelocity = palmVelocity;
     _palmNormal = palmNormal;
     _direction = direction;
     _wristPosition = wristPosition;
 }
예제 #58
0
        public Hand TransformedCopy(Matrix trs)
        {
            FingerList transformedFingers = new FingerList(5);
            for(int f = 0; f < this.Fingers.Count; f++)
                transformedFingers.Add(Fingers[f].TransformedCopy(trs));

            float hScale = trs.xBasis.Magnitude;
            return new Hand(_frameId,
                _id,
                _confidence,
                _grabStrength,
                _grabAngle,
                _pinchStrength,
                _pinchDistance,
                _palmWidth * hScale,
                _isLeft,
                _timeVisible,
                _arm.TransformedCopy(trs),
                transformedFingers,
                trs.TransformPoint(_palmPosition),
                trs.TransformPoint(_stabilizedPalmPosition),
                trs.TransformPoint(_palmVelocity),
                trs.TransformDirection(_palmNormal).Normalized,
                trs.TransformDirection(_direction).Normalized,
                trs.TransformPoint(_wristPosition)
            );
        }
예제 #59
0
    //Virtual method for gesture checking.
    public virtual void CheckGesture()
    {
        _lastFrame = _leap_controller.Frame(0);
        Hands = _lastFrame.Hands;
        _gestures = _lastFrame.Gestures();

        foreach(Hand hand in Hands)
        {
            tempHand = hand;
            _fingers = hand.Fingers;
            if (WhichSide.IsEnableGestureHand(this))
            {
                foreach (Gesture gesture in _gestures)
                {
                    _fingers = hand.Fingers;
                    if (gesture.Type == Gesture.GestureType.TYPE_CIRCLE)
                    {


                        _circle_gesture = new CircleGesture(gesture);
                        if (!_isPlaying && (gesture.State == Gesture.GestureState.STATE_START) && WhichSide.capturedSide(hand, _useArea, _mountType))
                        {
                            _isPlaying = !_isPlaying;
                            this._startProgress = _circle_gesture.Progress;
                        }

                        if (_isPlaying && gesture.State == Gesture.GestureState.STATE_STOP)
                        {
                            int direc = PropertyGetter.IsClockWise(this);
                            this._endProgress = _circle_gesture.Progress;
                            if (this._endProgress >= this.MinProgress && direc == _useDirection)
                            {
                                this._isChecked = true;
                                this._isPlaying = !this._isPlaying;
                            }
                            this._state = gesture.State;

                            break;
                        }
                        this._state = gesture.State;
                    }
                }

                if (_isPlaying && _state == Gesture.GestureState.STATE_UPDATE)
                {
                    int direc = this.IsClockWise();
                    this._endProgress = _circle_gesture.Progress;
                    if (this._endProgress >= this.MinProgress && direc == _useDirection)
                    {
                        this._isChecked = true;
                        this._isPlaying = !this._isPlaying;
                    }
                }

            }
            if (this._isChecked)
                break;
        }
        


        if (_isChecked)
        {

            DoAction();
        }

    }