Esempio n. 1
0
 private void UpdateHandTrackData(HandCollection handData)
 {
     foreach (var newHand in handData.Hands.Where(h => !this.handTracks.Any(t => t.Id == h.Id)))
     {
         this.handTracks.Add(new HandTracker(newHand));
     }
     foreach (var handTrack in this.handTracks.ToList())
     {
         var newHand = handData.Hands.Where(h => h.Id == handTrack.Id).FirstOrDefault();
         if (newHand == null)
         {
             this.handTracks.Remove(handTrack);
         }
         else
         {
             if (!newHand.HasPalmPoint)
             {
                 continue;
             }
             handTrack.SetHandData(newHand);
             var hoveredImage = this.images.Where(i => this.ImageContains(i, newHand.PalmPoint.Value)).LastOrDefault();
             if (hoveredImage != null)
             {
                 MoveImageToFront(hoveredImage);
                 handTrack.HandleTranslation(hoveredImage, this.handLayer.ZoomFactor);
             }
         }
     }
 }                             
Esempio n. 2
0
 public ShapeHandDataFactory(HandDataSourceSettings settings)
 {
     this.settings            = settings;
     this.fingerPointDetector = new FingerPointDetector(settings);
     this.palmFinder          = new PalmFinder(settings);
     this.currentValue        = new HandCollection();
 }
 public ShapeHandDataFactory(HandDataSourceSettings settings)
 {
     this.settings = settings;
     this.fingerPointDetector = new FingerPointDetector(settings);
     this.palmFinder = new PalmFinder(settings);
     this.currentValue = new HandCollection();
 }
        private void handDataSource_NewDataAvailable(HandCollection data)
        {
            if (data.IsEmpty) 
            {
                ReportNoTouch(this.touchDevices.Values);
                return;
            }

            var touchedDevices = this.ReportTouches(data);
            this.ReportNoTouch(this.touchDevices.Values.Except(touchedDevices));
        }
Esempio n. 5
0
 public HandCollection Create(ShapeCollection shapes)
 {
     if (shapes.Count == 0)
     {
         this.currentValue = Clear();
     }
     else
     {
         this.currentValue = CreateHandCollection(shapes);
     }
     return(this.currentValue);
 }
 public HandCollection Create(ShapeCollection shapes)
 {
     if (shapes.Count == 0)
     {
         this.currentValue = Clear();
     }
     else
     {
         this.currentValue = CreateHandCollection(shapes);
     }
     return this.currentValue;
 }
Esempio n. 7
0
 private void handDataSource_NewDataAvailable(HandCollection data)
 {
     if (data.IsEmpty || !data.Hands.First().HasFingers)
     {
         this.Dispatcher.Invoke(new Action(() =>
         {
             foreach (var line in mainCanvas.Children.OfType<Line>().ToList())
             {
                 mainCanvas.Children.Remove(line);
             }
         }));
     }
 }
 void handDataSource_NewDataAvailable(HandCollection data)
 {
     if (data.Count == 1)
     {
         var hand = data.Hands.First();
         if (hand.FingerCount >= 4)
         {
             this.StopMode();
         }
         if (hand.FingerCount == 1)
         {
             this.Select(hand.FingerPoints.First());
         }
     }
     if (data.Count == 2)
     {
         var leftHand = data.Hands.OrderBy(h => h.Location.X).First();
         var rightHand = data.Hands.OrderBy(h => h.Location.X).Last();
         if (leftHand.FingerCount == 2 && rightHand.FingerCount == 2)
         {
             SurfaceMode(data);
         }
         else if (leftHand.FingerCount >= 4 && rightHand.FingerCount == 0)
         {
             StopMode();
         }
         else if (leftHand.FingerCount >= 4 && rightHand.FingerCount >= 1)
         {
             TimeShiftMode(rightHand);
         }
         else if (rightHand.FingerCount == 0 && leftHand.FingerCount == 0)
         {
             isNew = true;
             DisabeMoveMode();
         }
         else if (leftHand.FingerCount == 0)
         {
             DisabeMoveMode();
         }
         else if (rightHand.FingerCount >= 4 && leftHand.FingerCount == 1)
         {
             CancelMode(leftHand);
         }
     }
     else
     {
         isNew = true;                
     }
 }
 private IList<KinectTouchDevice> ReportTouches(HandCollection data)
 {
     var touchedDevices = new List<KinectTouchDevice>();
     foreach (var hand in data.Hands)
     {
         foreach (var fingerPoint in hand.FingerPoints)
         {
             var device = this.GetDevice(hand.Id * handMultiplier + fingerPoint.Id);
             var pointOnPresentationArea = this.MapToPresentationArea(fingerPoint, new Size(this.handDataSource.Size.Width, this.handDataSource.Height));
             device.Touch(pointOnPresentationArea);
             touchedDevices.Add(device);
         }
     }
     return touchedDevices;
 }
Esempio n. 10
0
 private void handDataSource_NewDataAvailable(HandCollection data)
 {
     for (int index = 0; index < data.Count; index++)
     {
         if (!ReadyForSign)
         {
             hand = data.Hands[index];
             if (hand.FingerCount == 5)
             { //Takes the area of an open hand(when five fingers are detected)
                 openHandArea = handArea();
                 openHandDistance = ClosestPoint();
                 ReadyForSign = true;
             }
         }
         else
         {
             hand = data.Hands[index];
         }
     }
 }
        private void SurfaceMode(HandCollection data)
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                if (isNew)
                {
                    if (this.selectedVideo != null)
                    {
                        this.selectedVideo.IsSelected = false;
                    }
                    this.selectedVideo = new VideoSurface(this.videoPaths[this.videoPointer++]);
                    this.videos.Add(this.selectedVideo);
                    this.selectedVideo.RequestRemove += new EventHandler(videoSurface_RequestRemove);
                    if (videoPointer >= this.videoPaths.Length)
                    {
                        videoPointer = 0;
                    }

                    this.viewPort.Children.Add(selectedVideo.ModelVisual3D);
                    this.selectedVideo.Play();
                    this.selectedVideo.Opacity = 0.8;
                    isNew = false;
                }
                if (selectedVideo.IsPaused)
                {
                    selectedVideo.Play();
                }

                var points = new List<CCT.NUI.Core.Point>();

                var hand1 = data.Hands[0];
                var hand2 = data.Hands[1];

                points.Add(hand1.FingerPoints[0].Fingertip);
                points.Add(hand1.FingerPoints[1].Fingertip);
                points.Add(hand2.FingerPoints[0].Fingertip);
                points.Add(hand2.FingerPoints[1].Fingertip);

                points = points.OrderBy((p) => p.X).ToList();
                var leftPoints = points.Take(2).ToList();
                var rightPoints = points.Skip(2).Take(2).ToList();
                leftPoints = leftPoints.OrderByDescending(p => p.Y).ToList();
                rightPoints = rightPoints.OrderByDescending(p => p.Y).ToList();

                this.selectedVideo.SetPoints(Map(leftPoints[0]), Map(rightPoints[0]), Map(rightPoints[1]), Map(leftPoints[1]));
            }));
            moveMode = false;
        }
Esempio n. 12
0
 private void dataSource_NewDataAvailable(HandCollection hands)
 {
     this.Dispatcher.Invoke(new Action(() => InvalidateVisual()));
 }
 void handDataSource_NewDataAvailable(HandCollection data)
 {
     this.element.Update(data);
 }
Esempio n. 14
0
        private void handDataSource_NewDataAvailable(HandCollection data)
        {
            if (data.HandsDetected)
            {
                var hand = data.Hands.Last();

                var location = MapToScreen(hand.Location);

                //if (hand.HasPalmPoint)
                //{
                //    location = MapToScreen(hand.PalmPoint.Value);
                //}
                //else
                //{
                //    return;
                //}

                Debug.WriteLine("timespan: {0}, fingerCount: {2}, lastFingerCount: {3}, location: {4}",
                    DateTime.Now - lastUpdate,
                    lastUpdate,
                    hand.FingerCount,
                    lastFingerCount,
                    location);

                if (DateTime.Now > lastUpdate.AddMilliseconds(100))
                {
                    lastUpdate = DateTime.Now;

                    int x = (int)location.X,
                        y = (int)location.Y;

                    //set mouse position
                    MouseController.SendMouseInput(x, y, ScreenWidth, ScreenHeight, false);

                    var fingerCountChanged = lastFingerCount != hand.FingerCount;
                    lastFingerCount = hand.FingerCount;

                    if (fingerCountChanged)
                    {
                        if (hand.FingerCount == TouchGestureFingerCount)
                        {
                            //start
                            OnTouchStart(x, y);
                        }
                        else if (hand.FingerCount == MoveGestureFingerCount)
                        {
                            //end
                            OnTouchEnd(x, y);
                        }
                    }
                    else if (hand.FingerCount == TouchGestureFingerCount)
                    {
                        // update touch
                        OnTouchMove(x, y);
                    }
                }

                this.Dispatcher.Invoke(() =>
                                           {
                                               this.labelHandLocation.Content = location.ToString();
                                               this.labelFingerCount.Content = hand.FingerCount;
                                           });
            }
        }
Esempio n. 15
0
        void handDataSource_NewDataAvailable(HandCollection handData)
        {
            if (handData.IsEmpty)
            {
                this.ResetHands();
                return;
            }

            this.UnhoverImages();
            this.UpdateHandTrackData(handData);

            var handsOverImages = this.handTracks.Where(h => h.IsOverImage);
            foreach (var handTrack in handsOverImages)
            {
                this.HandleTwoHandedActions(handTrack);
            }

            this.Invalidate();
        }
Esempio n. 16
0
        void handDataSource_NewDataAvailable(HandCollection data)
        {
            for (int index = 0; index < data.Count; index++)
            {
                var hand = data.Hands[index];
               // Console.WriteLine(string.Format("Fingers on hand {0}: {1}", index, hand.FingerCount));
                //HINT : the current contet when running is on a separate thread, need to use begininvoke or a backgroundworker to change the UItext

                //uncomment the following 1 line, and get it working if you can.
                //updateHandLabels(data.Count, hand.FingerCount);

                //offloaded to a separate method.
                //handLabel.Text = "Hands: " + data.Count;
                //fingerLabel.Text = "Fingers: " + hand.FingerCount;
            }
        }
Esempio n. 17
0
 void dataSource_NewDataAvailable(HandCollection handData)
 {
     this.OnRequestRefresh();
 }
 internal void Update(HandCollection handCollection)
 {
     if (stopped)
     {
         return;
     }
     this.Dispatcher.Invoke(new Action(() =>
         {
             this.currentData = handCollection;
             if (!handCollection.IsEmpty)
             {
                 var hand = handCollection.Hands.First();
                 this.UpdateFingerCount(hand);
                 if (this.fingerPointCount >= 1)
                 {
                     UpdateHandValues(hand);
                 }
             }
             if ((handCollection.IsEmpty || this.fingerPointCount == 0) && this.InterfaceOpacity == 100)
             {
                 this.FadeOut(500);
             }
             InvalidateVisual();
         }));
 }