コード例 #1
0
        public virtual void Add(SkeletonPoint position, KinectSensor sensor)
        {
            Entry newEntry = new Entry {
                Position = position.ToVector3(), Time = DateTime.Now
            };

            Entries.Add(newEntry);

            // Look for gestures
            LookForGesture();
        }
コード例 #2
0
ファイル: GestureDetector.cs プロジェクト: K-Cully/SticKart
        /// <summary>
        /// Adds the skeleton point to the positions being tracked by the gesture detector.
        /// Checks if the gesture has been detected.
        /// </summary>
        /// <param name="position">The position of the joint being tracked.</param>
        public virtual void Add(SkeletonPoint position)
        {
            if (this.GestureDetected == GestureType.None)
            {
                GestureEntry newEntry = new GestureEntry(position.ToVector3(), DateTime.UtcNow);
                this.GestureEntries.Add(newEntry);
                if (this.GestureEntries.Count > this.MaxRecordedPositions)
                {
                    this.GestureEntries.RemoveAt(0);
                }

                this.LookForGesture();
            }
        }
コード例 #3
0
        public virtual void Add(SkeletonPoint position, KinectSensor sensor)
        {
            Entry newEntry = new Entry {
                Position = position.ToVector3(), Time = DateTime.Now
            };

            Entries.Add(newEntry);

            // Drawing
            if (DisplayCanvas != null)
            {
                newEntry.DisplayEllipse = new Ellipse
                {
                    Width  = 4,
                    Height = 4,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    StrokeThickness     = 2.0,
                    Stroke         = new SolidColorBrush(DisplayColor),
                    StrokeLineJoin = PenLineJoin.Round
                };

                Vector2 vector2 = Tools.Convert(sensor, position);

                float x = (float)(vector2.X * DisplayCanvas.ActualWidth);
                float y = (float)(vector2.Y * DisplayCanvas.ActualHeight);

                Canvas.SetLeft(newEntry.DisplayEllipse, x - newEntry.DisplayEllipse.Width / 2);
                Canvas.SetTop(newEntry.DisplayEllipse, y - newEntry.DisplayEllipse.Height / 2);

                DisplayCanvas.Children.Add(newEntry.DisplayEllipse);
            }

            // Remove too old positions
            if (Entries.Count > WindowSize)
            {
                Entry entryToRemove = Entries[0];

                if (DisplayCanvas != null)
                {
                    DisplayCanvas.Children.Remove(entryToRemove.DisplayEllipse);
                }

                Entries.Remove(entryToRemove);
            }

            // Look for gestures
            LookForGesture();
        }