/// <summary>
        /// Extracts data from a frame and forward subsets to the correct class
        /// </summary>
        /// <param name="controller">LeapMotion controller data</param>
        /// <returns>true when successful, otherwise false</returns>
        public bool UpdateData(Leap.Controller controller)
        {
            Frame frame = controller.Frame();

            HandList hands = frame.Hands;
            FingerList fingers = frame.Fingers;
            ToolList tools = frame.Tools;
            GestureList gestures = frame.Gestures();

            //float fps = frame.CurrentFramesPerSecond;
            //long timestamp = frame.Timestamp;
            //BugReport bugReport = controller.BugReport;
            //Config config = controller.Config;
            //DeviceList devices = controller.Devices;
            //ImageList images = controller.Images;
            //bool hasFocus = controller.HasFocus;
            //bool isConnected = controller.IsConnected;

            try
            {
                this.Hands.UpdateData(hands);
                this.Fingers.UpdateData(fingers);
                this.Tools.UpdateData(tools);
                this.Gestures.UpdateData(gestures);

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
Esempio n. 2
0
        protected void DetectLeapGesture(Controller leap, Leap.Frame frame)
        {
            GestureList gestures = frame.Gestures();

            foreach (Gesture gesture in gestures)
            {
                if (gesture.State != Gesture.GestureState.STATESTOP)
                {
                    continue;
                }

                switch (gesture.Type)
                {
                    case Gesture.GestureType.TYPESWIPE:
                        SwipeGesture swipe = new SwipeGesture(gesture);

                        if (swipe.StartPosition.x < 0 && swipe.Direction.x > 0)
                        {
                            TurnSlide(-1);
                        }
                        else if (swipe.StartPosition.x > 0 && swipe.Direction.x < 0)
                        {
                            TurnSlide(+1);
                        }
                        break;
                    default: break;
                }
            }
        }
Esempio n. 3
0
        public override HandRepresentation MakeHandRepresentation(Leap.Hand hand, ModelType modelType)
        {
            HandRepresentation handRep = null;
              for (int i = 0; i < ModelPool.Count; i++) {
            IHandModel model = ModelPool[i];

            bool isCorrectHandedness;
            if(model.Handedness == Chirality.Either) {
              isCorrectHandedness = true;
            } else {
              Chirality handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
              isCorrectHandedness = model.Handedness == handChirality;
            }

            bool isCorrectModelType;
            isCorrectModelType = model.HandModelType == modelType;

            if(isCorrectHandedness && isCorrectModelType) {
              ModelPool.RemoveAt(i);
              handRep = new HandProxy(this, model, hand);
              break;
            }
              }
              return handRep;
        }
 /// <summary>
 /// Sets the settings for the leapMotion on first connection
 /// </summary>
 /// <param name="controller"></param>
 public override void OnConnect(Leap.Controller controller)
 {
     // SOURCE: LeapMotion Sample Example
     controller.EnableGesture(Gesture.GestureType.TYPE_CIRCLE);
     controller.EnableGesture(Gesture.GestureType.TYPE_KEY_TAP);
     controller.EnableGesture(Gesture.GestureType.TYPE_SCREEN_TAP);
     controller.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
 }
Esempio n. 5
0
    public HandProxy(HandPool parent, IHandModel handModel, Leap.Hand hand) :
      base(hand.Id)
    {
      this.parent = parent;
      this.handModel = handModel;

      // Check to see if the hand model has been initialized yet
      if (handModel.GetLeapHand() == null) {
        handModel.SetLeapHand(hand);
        handModel.InitHand();
      } else {
        handModel.SetLeapHand(hand);
      }
      handModel.BeginHand();
    }
 public byte[] Serialize(Leap.Frame frame)
 {
     var f = new SerializableFrame
     {
         id = frame.Id,
         timestamp = frame.Timestamp,
         fps = frame.CurrentFramesPerSecond,
         hands = frame.Hands.Select(ToSerializableHand).ToList()
     };
     var bf = new BinaryFormatter();
     using (var ms = new MemoryStream())
     {
         bf.Serialize(ms, f);
         return ms.ToArray();
     }
 }
Esempio n. 7
0
        void listener_FrameArrived(Leap.Frame frame)
        {
            FrameRate = frame.CurrentFramesPerSecond;

            TipPositions = frame.Pointables
                .Where(p => p.IsValid)
                .Where(p => p.TipPosition.IsValid())
                .Select(p => ToScreenPoint(p.TipPosition))
                .ToArray();

            StabilizedTipPositions = frame.Pointables
                .Where(p => p.IsValid)
                .Where(p => p.StabilizedTipPosition.IsValid())
                .Select(p => ToScreenPoint(p.StabilizedTipPosition))
                .ToArray();
        }
Esempio n. 8
0
        public HandProxy(HandPool parent, IHandModel handModel, Leap.Hand hand)
            : base(hand.Id)
        {
            this.parent = parent;
              this.handModel = handModel;

              // Check to see if the hand model has been initialized yet
              if (handModel.GetLeapHand() == null) {
            handModel.SetLeapHand(hand);
            handModel.InitHand();
              } else {
            handModel.SetLeapHand(hand);
              }

              handFinishBehavior = handModel.GetComponent<HandTransitionBehavior>();
              if (handFinishBehavior) {
            handFinishBehavior.Reset();
              }
        }
        /// <summary>
        /// 点を描画する
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="leftPoints"></param>
        private static void DrawPoints( Canvas canvas, Leap.Vector[] leftPoints )
        {
            int R = 5;

            canvas.Children.Clear();
            foreach ( var point in leftPoints ) {
                // Canvasに表示する
                var ellipse = new Ellipse()
                {
                    Width = R * 2,
                    Height = R * 2,
                    Fill = Brushes.White,
                };

                Canvas.SetLeft( ellipse, point.x - R );
                Canvas.SetTop( ellipse, point.y - R );

                canvas.Children.Add( ellipse );
            }
        }
        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();
        }
        public override void positionDidUpdate(Leap.HandList hands)
        {
            this.hands = hands;

            if (this.hands.Count == this.NumberOfHandsRequired)
            {
                if (isDesiredNumberOfFingersPerHand())
                {
                    MotionAverages averages = averageVectorForHands();

                    if (averages != null)
                    {
                        centerPoint = averages.positionAverage;
                        processTouchVector();
                    }
                    else
                    {
                        processNonTouch();
                    }
                }
            }
        }
Esempio n. 12
0
 static Point3D ToScreenPoint(Leap.Vector v)
 {
     return new Point3D(ScreenWidth / 2 + MappingScale * v.x, ScreenHeight - MappingScale * v.y, MappingScale * v.z);
 }
 public LeapGestureViewModel(Leap.Gesture.GestureType gestureType)
 {
     _Type = gestureType;
 }
Esempio n. 14
0
 static void Main(string[] args)
 {
     Console.WriteLine(Leap.IsLeapYear(2020));
     Console.ReadKey();
 }
Esempio n. 15
0
 void newFrameHandler(Leap.Frame frame)
 {
     /*switch (frame.Gesture(frame.Gestures().Count).Type)*/
     for (int g = 0; g < frame.Gestures().Count; g++)
     {
         Gesture gesture = frame.Gestures()[g];
         switch (gesture.Type)
             {
              case Gesture.GestureType.TYPE_SWIPE:
                 swipeDetected(frame.Gestures()[g], frame.Gestures()[g + 1]);
                 break;
             case Gesture.GestureType.TYPE_CIRCLE:
                 circleDetected();
                 break;
             case Gesture.GestureType.TYPE_SCREEN_TAP:
                 screenTapDetected();
                 break;
         }
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Notifies the representation that a hand information update is available
 /// </summary>
 /// <param name="hand">The current Leap.Hand</param>
 public abstract void UpdateRepresentation(Leap.Hand hand, ModelType modelType);
Esempio n. 17
0
 private void TransformModulationFrequency(Leap.Frame frameData)
 {
 }
        void newFrameHandler(Leap.Frame frame)
        {
            this.lblID.Content = "ID: " + frame.Id.ToString();
            this.lblTimestamp.Content = "Timestamp: " + frame.Timestamp.ToString();
            this.lblFPS.Content = "FPS: " + frame.CurrentFramesPerSecond.ToString();
            this.lblIsValid.Content = "IsFrameValid: " + frame.IsValid.ToString();
            this.lblGestureCount.Content = "Gesture Count: " + frame.Gestures().Count.ToString();
            this.lblImageCount.Content = "Image Count: " + frame.Images.Count.ToString();

            if (recordMode)
            {
                //write the recived frame to file
                writeFrameToFile(frame); //stimcode read from global

                //process image data from the frame
                Leap.Image image = frame.Images[0];
                if (image.Width != 0 && image.Height != 0)
                {
                    Bitmap bitmap = new Bitmap(image.Width, image.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
                    //set palette
                    ColorPalette grayscale = bitmap.Palette;
                    for (int i = 0; i < 256; i++)
                    {
                        grayscale.Entries[i] = System.Drawing.Color.FromArgb((int)255, i, i, i);
                    }
                    bitmap.Palette = grayscale;
                    Rectangle lockArea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
                    BitmapData bitmapData = bitmap.LockBits(lockArea, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
                    byte[] rawImageData = image.Data;
                    System.Runtime.InteropServices.Marshal.Copy(rawImageData, 0, bitmapData.Scan0, image.Width * image.Height);
                    bitmap.UnlockBits(bitmapData);

                    imgFrame.Source = ConvertBitmap.BitmapToBitmapSource(bitmap);
                }

            }
        }
Esempio n. 19
0
 /// <summary>
 /// Creates a hand representation object that can receive updates from LeapHandController
 /// </summary>
 /// <param name="hand">The hand for which a repersentation is to be generaetd</param>
 /// <returns>A hand representation for the given hand</returns>
 
 public abstract HandRepresentation MakeHandRepresentation(Leap.Hand hand, ModelType modelType);
        void writeFrameToFile(Leap.Frame frame)
        {
            //specific write method --> stores data in format: 64 bit serialised datetime object then 32 bit stimcode then 32 bit integer specifying size of frame, then serialised frame bytes of length (size of frame read before this) itself

            long binaryDate = DateTime.Now.ToBinary();

            Leap.Frame frameToSerialize = frame;
            byte[] serialized = frameToSerialize.Serialize;
            Int32 length = serialized.Length;

            Console.WriteLine(frame.Timestamp.ToString());
            writer.Write(binaryDate);
            writer.Write(curStimCode);
            writer.Write(length);
            writer.Write(serialized);

            //reset stim code to prevent multiple occurences of the stim event
            curStimCode = 0;
        }
        void newFrameHandler(Leap.Frame frame)
        {
            int rot_on = 0;
            currentTime = frame.Timestamp;
            timeChange = currentTime - previousTime;
            this.displayTimestamp.Content = timeChange;
            HandList hands = frame.Hands;
            Hand firstHand = hands[0];
            Hand secondHand = hands[1];
            if (timeChange > 100000)
            {
                if (hands[0].IsValid)
                {
                    if (hands[0].IsRight)
                    {
                        this.displayID.Content = "오른손 작동";
                    }
                    else
                    {
                        this.displayID.Content = "왼손 작동";
                    }

                    if (hands[0].GrabStrength > 0.5)
                    {

                        if (hands[0].IsRight)
                        {
                           // this.displayFPS.Content = "오른손 주먹";
                        }
                        else
                        {
                         //   this.displayFPS.Content = "왼손 주먹";
                        }

                    }
                    else
                    {
                     //   this.displayFPS.Content = "손 펴져있음";

                    }

                    //양손일때
                    if (hands[1].IsValid)
                    {
                        this.displayID.Content = "양손 작동";

                        //Console.WriteLine(hands[1].PinchStrength);
                        if (hands[1].GrabStrength > 0.5)
                        {
                            if (hands[0].GrabStrength == 0)
                            {

                                if (hands[1].IsRight)
                                {
                                //    this.displayFPS.Content = "오른손 주먹";
                                }
                                else
                                {
                                //    this.displayFPS.Content = "왼손 주먹";
                                    rot_on = 1;
                                }
                            }
                            else
                            {
                              //  this.displayFPS.Content = "양손 주먹";
                            }

                        }
                    }
                }
                else
                {
                    this.displayID.Content = "손 없음";

                }

                var handVelocity = (int)firstHand.PalmVelocity.Magnitude;
                if (handVelocity < 200)//1500
                {
                   // Console.WriteLine(handVelocity);
                    //this.displayImageCount.Content = "손빠르기";
                    this.displayGestureCount.Content = " ";
                }
                else
                {

                    for (int g = 0; g < frame.Gestures().Count; g++)
                    {
                        //switch(frame.Gesture(0).Type)
                        Gesture gesture = frame.Gestures()[g];

                        if (swipe_d == 1)
                        {

                        }
                        else if (swipe_d == -1)
                        {

                        }
                        else if (swipe_d == 0)
                        {
                            switch (gesture.Type)
                            {

                                case Gesture.GestureType.TYPE_CIRCLE:
                                    CircleGesture cir = new CircleGesture(frame.Gesture(g));
                                    // CircleGesture cir = new CircleGesture(frame.Gesture(0));

                                    String clockwiseness;
                                    if (cir.Pointable.Direction.AngleTo(cir.Normal) <= Math.PI / 2)
                                    {

                                        clockwiseness = "clockwise";

                                    }
                                    else
                                    {

                                        clockwiseness = "counterclockwise";
                                    }

                                    //this.displayImageCount.Content = frame.Gesture(g).ToString() + "의 지름은 " + cir.Radius + "그리고 상태는 " + frame.Gesture(g).State + "=" + frame.Gestures()[g].State;

                                    this.displayGestureCount.Content = "원방향" + clockwiseness;
                                    Console.WriteLine("원방향" + clockwiseness);
                                    break;
                                /* case Gesture.GestureType.TYPE_KEY_TAP:
                                     //Handle key tap gestures
                                     KeyTapGesture keytapGesture = new KeyTapGesture(frame.Gesture(g));
                                  //   this.displayImageCount.Content = "키탭";
                                     Console.WriteLine(frame.Gesture(g).ToString() + "의 방향은 " + keytapGesture.Direction + "그리고 상태는 " + frame.Gesture(g).State + "=" + frame.Gestures()[g].State);
                                     Console.WriteLine(frame.Gesture(g).ToString() + "의 포인터은 " + keytapGesture.Pointable + "그리고" + keytapGesture.Position);

                                     break;
                                 case Gesture.GestureType.TYPE_SCREEN_TAP:
                                     //Handle screen tap gestures
                                  //   this.displayImageCount.Content = "스크린탭";
                                     ScreenTapGesture screentapGesture = new ScreenTapGesture(frame.Gesture(g));
                                     Console.WriteLine(screentapGesture.Direction);
                                     break;
                                 */
                                case Gesture.GestureType.TYPE_SWIPE:
                                    // this.displayImageCount.Content = "쓸기";
                                    SwipeGesture swipeGesture = new SwipeGesture(gesture);
                                    //1. start position위치 확인
                                    Leap.Vector start = iBox.NormalizePoint(swipeGesture.StartPosition);
                                    //  if (start.x > 0.9 || start.x < 0.1 ) return;
                                    //2. swipe speed 확인
                                    float speed = swipeGesture.Speed;
                                    //  if (speed < 1500.0) return;
                                    //3. 방향 확인
                                    this.displayFPS.Content = swipeGesture.Direction;//y < 0 ? "Swipe to left" : "Swipe to right";

                                    Console.WriteLine(swipeGesture.Direction.y < 0 ? "Swipe to left" : "Swipe to right");
                                    break;

                                default:
                                    this.displayGestureCount.Content = " ";//this.displayImageCount.Content = 0;
                                    break;
                            }
                        }

                        //  }

                        Finger finger = frame.Fingers[0];
                        // Get the closest screen intercepting a ray projecting from the finger
                        Screen screen = controller.LocatedScreens.ClosestScreenHit(finger);

                        if (screen != null && screen.IsValid)
                        {
                            // Get the velocity of the finger tip
                            var tipVelocity = (int)finger.TipVelocity.Magnitude;

                            // Use tipVelocity to reduce jitters when attempting to hold
                            // the cursor steady
                            if (tipVelocity > 25)
                            {
                                var xScreenIntersect = screen.Intersect(finger, true).x;
                                var yScreenIntersect = screen.Intersect(finger, true).y;

                                if (xScreenIntersect.ToString() != "NaN")
                                {
                                    var x = (int)(xScreenIntersect * screen.WidthPixels);
                                    var y = (int)(screen.HeightPixels - (yScreenIntersect * screen.HeightPixels));

                                 /*   Console.WriteLine("Screen intersect X: " + xScreenIntersect.ToString());
                                    Console.WriteLine("Screen intersect Y: " + yScreenIntersect.ToString());
                                    Console.WriteLine("Width pixels: " + screen.WidthPixels.ToString());
                                    Console.WriteLine("Height pixels: " + screen.HeightPixels.ToString());

                                    Console.WriteLine("\n");

                                    Console.WriteLine("x: " + x.ToString());
                                    Console.WriteLine("y: " + y.ToString());

                                    Console.WriteLine("\n");

                                    Console.WriteLine("Tip velocity: " + tipVelocity.ToString());

                                    // Move the cursor
                                    //MouseCursor.MoveCursor(x, y);

                                    Console.WriteLine("\n" + new String('=', 40) + "\n");*/

                                    if (rot_on == 1)
                                    {
                                        this.displayGestureCount.Content = "x,y 좌표는 : " + x.ToString() + "," + y.ToString();
                                    }
                                }

                            }
                        }

                        //this.displayID.Content = frame.Id.ToString();
                        //this.displayTimestamp.Content = frame.Timestamp.ToString();
                        //this.displayFPS.Content = frame.CurrentFramesPerSecond.ToString();
                        //this.displayIsValid.Content = frame.IsValid.ToString();
                        // this.displayGestureCount.Content = frame.Gestures().Count.ToString();
                        //this.displayImageCount.Content = frame.Images.Count.ToString();
                    }

                }
                previousTime = currentTime;
            }
        }
        void newFrameHandler(Leap.Frame frame)
        {
            currentTime = frame.Timestamp;
            timeChange = currentTime - previousTime;

            HandList hands = frame.Hands;
            Hand firstHand = hands[0];
            Hand secondHand = hands[1];
            if (timeChange > 100000)
            {
                if (hands[0].IsValid)
                {
                    if (hands[1].IsValid)
                    {
                        //Console.WriteLine(hands[1].PinchStrength);

                    }else{
                       // Console.WriteLine("only 0");
                    }
                }

                var handVelocity = (int)firstHand.PalmVelocity.Magnitude;
                if (handVelocity > 10000)//1500
                {
                    Console.WriteLine(handVelocity);
                    this.displayImageCount.Content = "손빠르기";
                }
                else
                {

                    for (int g = 0; g < frame.Gestures().Count; g++)
                    {
                        switch (frame.Gestures()[g].Type)
                        {
                            case Gesture.GestureType.TYPE_CIRCLE:
                                CircleGesture cir = new CircleGesture(frame.Gesture(g));

                                //this.displayImageCount.Content = frame.Gesture(g).ToString() + "의 지름은 " + cir.Radius + "그리고 상태는 " + frame.Gesture(g).State + "=" + frame.Gestures()[g].State;
                                this.displayImageCount.Content = "원" +frame.Gesture(g).ToString() + "의 지름은 " + cir.Radius + "그리고 상태는 " + frame.Gesture(g).State;
                                break;
                            case Gesture.GestureType.TYPE_KEY_TAP:
                                //Handle key tap gestures
                                KeyTapGesture keytapGesture = new KeyTapGesture(frame.Gesture(g));
                                this.displayImageCount.Content = "키탭";
                                Console.WriteLine(frame.Gesture(g).ToString() + "의 방향은 " + keytapGesture.Direction + "그리고 상태는 " + frame.Gesture(g).State + "=" + frame.Gestures()[g].State);
                                Console.WriteLine(frame.Gesture(g).ToString() + "의 포인터은 " + keytapGesture.Pointable + "그리고" + keytapGesture.Position);

                                break;
                            case Gesture.GestureType.TYPE_SCREEN_TAP:
                                //Handle screen tap gestures
                                this.displayImageCount.Content = "스크린탭";
                                ScreenTapGesture screentapGesture = new ScreenTapGesture(frame.Gesture(g));
                                Console.WriteLine(screentapGesture.Direction);
                                break;
                            case Gesture.GestureType.TYPE_SWIPE:
                                this.displayImageCount.Content = "쓸기";

                                break;
                            default:
                                //this.displayImageCount.Content = 0;
                                break;
                        }
                    }

                    this.displayID.Content = frame.Id.ToString();
                    this.displayTimestamp.Content = frame.Timestamp.ToString();
                    this.displayFPS.Content = frame.CurrentFramesPerSecond.ToString();
                    this.displayIsValid.Content = frame.IsValid.ToString();
                    this.displayGestureCount.Content = frame.Gestures().Count.ToString();
                    //this.displayImageCount.Content = frame.Images.Count.ToString();
                }
                previousTime = currentTime;

            }
        }
Esempio n. 23
0
        protected void DrawLeapTouch(Leap.Frame frame)
        {
            InteractionBox interactionBox = frame.InteractionBox;

            if (frame.Pointables.Extended().Count != 1)
            {
                return;
            }

            Pointable pointable = frame.Pointables.Extended()[0];

            // InteractionBox を利用した座標変換
            Leap.Vector normalizedPosition = interactionBox.NormalizePoint(pointable.StabilizedTipPosition);

            double tx = normalizedPosition.x * windowWidth;
            double ty = windowHeight - normalizedPosition.y * windowHeight;
            StylusPoint touchPoint = new StylusPoint(tx, ty);
            StylusPointCollection tips = new StylusPointCollection(new StylusPoint[] { touchPoint });

            // タッチ状態
            if (normalizedPosition.z <= TouchBorder)
            {
                Stroke touchStroke = new Stroke(tips, touchIndicator);
                this.InkCanvas_LeapPaintLine.Strokes.Add(touchStroke.Clone());
            }
        }
Esempio n. 24
0
        protected void DrawLeapPoint(Leap.Frame frame)
        {
            this.InkCanvas_LeapPaint.Strokes.Clear();
            windowHeight = (float)this.MainWindow1.Height;
            windowWidth = (float)this.MainWindow1.Width;

            InteractionBox interactionBox = frame.InteractionBox;

            foreach (Pointable pointable in frame.Pointables.Extended())
            {
                // InteractionBox を利用した座標変換
                Leap.Vector normalizedPosition = interactionBox.NormalizePoint(pointable.StabilizedTipPosition);

                double tx = normalizedPosition.x * windowWidth;
                double ty = windowHeight - normalizedPosition.y * windowHeight;
                StylusPoint touchPoint = new StylusPoint(tx, ty);
                StylusPointCollection tips = new StylusPointCollection(new StylusPoint[] { touchPoint });

                // ホバー状態
                if (normalizedPosition.z > TouchBorder)
                {
                    Stroke touchStroke = new Stroke(tips, pointIndicator);
                    this.InkCanvas_LeapPaint.Strokes.Add(touchStroke);
                }
            }
        }
Esempio n. 25
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);
        }
Esempio n. 26
0
 void _listener_OnHandMoveOn(Leap.Vector obj)
 {
     HandMoveVector = string.Format("x:{0} y:{1} z:{2}{3}x:{4} y:{5} z:{6}", obj.x, obj.y, obj.z, Environment.NewLine, obj.x * 10, obj.y * 10, obj.z * 100);
 }
Esempio n. 27
0
 public bool Update(Leap.Frame frame)
 {
     var s = _HandManager.Dump();
     if (!String.IsNullOrWhiteSpace(s))
     {
         if (frame.Timestamp > _LastLogTime + 0)
         {
             _LastLogTime = frame.Timestamp;
             _LogAction(s);
         }
     }
     return true;
 }
Esempio n. 28
0
        private void TransformModulationFraction(Leap.Frame frameData)
        {
            foreach (var hand in frameData.Hands)
            {
                if (hand.IsLeft)
                {
                    float yPosition = hand.PalmPosition.y;

                    if (yPosition < 500 && yPosition >= 0)
                    {
                        for (int i = 0; i < yPartition.Length; ++i)
                        {
                            if (i < yPartition.Length - 1)
                            {
                                if (yPosition >= yPartition[i] && yPosition < yPartition[i + 1])
                                {
                                    pmProvider.LerpModulationFraction(modulationFractions[i], InterpolationSpeed);
                                    return;
                                }
                            }
                            else
                            {
                                pmProvider.CarrierFrequency = noteFrequencies[yPartition.Length - 1];
                            }
                        }
                    }
                }
            }
        }
Esempio n. 29
0
 public override void UpdateRepresentation(Leap.Hand hand, ModelType modelType)
 {
     handModel.SetLeapHand(hand);
       handModel.UpdateHand();
 }
Esempio n. 30
0
        private void TransformModulationIndex(Leap.Frame frameData)
        {
            foreach (var hand in frameData.Hands)
            {
                if (hand.IsRight)
                {
                    float xPosition = hand.PalmPosition.x;

                    if (xPosition >= xMin && xPosition <= xMax)
                    {
                        for (int i = 0; i < xPartition.Length; ++i)
                        {
                            if (i < xPartition.Length - 1)
                            {
                                if (xPosition >= xPartition[i] && xPosition < xPartition[i + 1])
                                {
                                    pmProvider.LerpModulationIndex(modulationIndices[i], InterpolationSpeed);
                                    return;
                                }
                            }
                            else
                            {
                                pmProvider.LerpModulationIndex(modulationIndices[xPartition.Length - 1], InterpolationSpeed);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 31
0
 void newFrameHandler(Leap.Frame frame)
 {
     LeapInfo.X = (int)frame.Pointables.Frontmost.TipPosition.x;
     LeapInfo.Y = (int)frame.Pointables.Frontmost.TipPosition.y;
     LeapInfo.Z = (int)frame.Pointables.Frontmost.TipPosition.z;
 }