Ejemplo n.º 1
1
        /// <summary>
        /// Draws a bone line between two joints
        /// </summary>
        /// <param name="skeleton">skeleton to draw bones from</param>
        /// <param name="drawingContext">drawing context to draw to</param>
        /// <param name="jointType0">joint to start drawing from</param>
        /// <param name="jointType1">joint to end drawing at</param>
        public static void DrawBone(TSkeleton skeleton, DrawingContext drawingContext, TJointType jointType0, TJointType jointType1)
        {
            TJoint joint0 = skeleton.Joints[(int)jointType0];
            TJoint joint1 = skeleton.Joints[(int)jointType1];

            // If we can't find either of these joints, exit
            if (joint0.TrackingState == TJointTrackingState.NotTracked ||
                joint1.TrackingState == TJointTrackingState.NotTracked)
            {
                return;
            }

            // Don't draw if both points are inferred
            if (joint0.TrackingState == TJointTrackingState.Inferred &&
                joint1.TrackingState == TJointTrackingState.Inferred)
            {
                return;
            }

            // We assume all drawn bones are inferred unless BOTH joints are tracked
            Pen drawPen = inferredBonePen;
            if (joint0.TrackingState == TJointTrackingState.Tracked && joint1.TrackingState == TJointTrackingState.Tracked)
            {
                drawPen = trackedBonePen;
            }

            drawingContext.DrawLine(drawPen, SkeletonPointToScreen(joint0.Position), SkeletonPointToScreen(joint1.Position));
        }
Ejemplo n.º 2
0
        void Plot(TJointType centerID, TJointType baseID, TJoint[] joints)
        {
            float centerX;
            float centerY;

            GetCoordinates(centerID, joints, out centerX, out centerY);

            float baseX;
            float baseY;

            GetCoordinates(baseID, joints, out baseX, out baseY);

            double diameter = Math.Abs(baseY - centerY);

            Ellipse ellipse = new Ellipse
            {
                Width  = diameter,
                Height = diameter,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                StrokeThickness     = 4.0,
                Stroke         = new SolidColorBrush(Colors.Green),
                StrokeLineJoin = PenLineJoin.Round
            };

            Canvas.SetLeft(ellipse, centerX - ellipse.Width / 2);
            Canvas.SetTop(ellipse, centerY - ellipse.Height / 2);

            rootCanvas.Children.Add(ellipse);
        }
Ejemplo n.º 3
0
        void Trace(TJointType sourceID, TJointType destinationID, TJoint[] joints)
        {
            float sourceX;
            float sourceY;

            GetCoordinates(sourceID, joints, out sourceX, out sourceY);

            float destinationX;
            float destinationY;

            GetCoordinates(destinationID, joints, out destinationX, out destinationY);

            Line line = new Line
            {
                X1 = sourceX,
                Y1 = sourceY,
                X2 = destinationX,
                Y2 = destinationY,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                StrokeThickness     = 4.0,
                Stroke         = new SolidColorBrush(Colors.Green),
                StrokeLineJoin = PenLineJoin.Round
            };


            rootCanvas.Children.Add(line);
        }
Ejemplo n.º 4
0
 public MovementEventArgs(Vector3 displacement, long duration, TJointType jointType, ControlType controlType)
 {
     Displacement = displacement;
     Duration = duration;
     JointType = jointType;
     ControlType = controlType;
 }
Ejemplo n.º 5
0
 public MovementAnalyzer(FramesCollector framesCollector, TJointType joint)
     : base(framesCollector)
 {
     _joint = joint;
     MinimalVectorLength = 0.01f;
     MinimalPeriodBetweenGestures = 250;
 }
Ejemplo n.º 6
0
 public MovementEventArgs(Vector3 displacement, long duration, TJointType jointType, ControlType controlType)
 {
     Displacement = displacement;
     Duration     = duration;
     JointType    = jointType;
     ControlType  = controlType;
 }
Ejemplo n.º 7
0
 public SwipeAnalyzer(FramesCollector framesCollector, TJointType jointType) : base(framesCollector)
 {
     _joint               = jointType;
     SwipeMinimalLength   = 0.4f;
     SwipeMaximalHeight   = 0.2f;
     SwipeMininalDuration = 250;
     SwipeMaximalDuration = 1500;
 }
Ejemplo n.º 8
0
 public SwipeAnalyzer(FramesCollector framesCollector, TJointType jointType)
     : base(framesCollector)
 {
     _joint = jointType;
     SwipeMinimalLength = 0.4f;
     SwipeMaximalHeight = 0.2f;
     SwipeMininalDuration = 250;
     SwipeMaximalDuration = 1500;
 }
Ejemplo n.º 9
0
        void GetCoordinates(TJointType jointType, IEnumerable <TJoint> joints, out float x, out float y)
        {
            var joint = joints.First(j => j.JointType == jointType);

            Vector2 vector2 = Tools.Convert(joint.Position);

            x = (float)(vector2.X * rootCanvas.ActualWidth);
            y = (float)(vector2.Y * rootCanvas.ActualHeight);
        }
Ejemplo n.º 10
0
 public MovementAnalyzer(FramesCollector framesCollector, TJointType joint) : base(framesCollector)
 {
     _joint = joint;
     MinimalVectorLength          = 0.01f;
     MinimalPeriodBetweenGestures = 250;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Draws a bone line between two joints
        /// </summary>
        /// <param name="skeleton">skeleton to draw bones from</param>
        /// <param name="drawingContext">drawing context to draw to</param>
        /// <param name="jointType0">joint to start drawing from</param>
        /// <param name="jointType1">joint to end drawing at</param>
        public static void DrawBone(TSkeleton skeleton, DrawingContext drawingContext, TJointType jointType0, TJointType jointType1)
        {
            TJoint joint0 = skeleton.Joints[(int)jointType0];
            TJoint joint1 = skeleton.Joints[(int)jointType1];

            // If we can't find either of these joints, exit
            if (joint0.TrackingState == TJointTrackingState.NotTracked ||
                joint1.TrackingState == TJointTrackingState.NotTracked)
            {
                return;
            }

            // Don't draw if both points are inferred
            if (joint0.TrackingState == TJointTrackingState.Inferred &&
                joint1.TrackingState == TJointTrackingState.Inferred)
            {
                return;
            }

            // We assume all drawn bones are inferred unless BOTH joints are tracked
            Pen drawPen = inferredBonePen;

            if (joint0.TrackingState == TJointTrackingState.Tracked && joint1.TrackingState == TJointTrackingState.Tracked)
            {
                drawPen = trackedBonePen;
            }

            drawingContext.DrawLine(drawPen, SkeletonPointToScreen(joint0.Position), SkeletonPointToScreen(joint1.Position));
        }
Ejemplo n.º 12
0
 public ContinousMovementAnalyzer(FramesCollector framesCollector, TJointType joint) : base(framesCollector, joint)
 {
 }
Ejemplo n.º 13
0
        void Trace(TJointType sourceID, TJointType destinationID, TJoint[] joints)
        {
            float sourceX;
            float sourceY;

            GetCoordinates(sourceID, joints, out sourceX, out sourceY);

            float destinationX;
            float destinationY;

            GetCoordinates(destinationID, joints, out destinationX, out destinationY);

            Line line = new Line
                            {
                                X1 = sourceX,
                                Y1 = sourceY,
                                X2 = destinationX,
                                Y2 = destinationY,
                                HorizontalAlignment = HorizontalAlignment.Left,
                                VerticalAlignment = VerticalAlignment.Top,
                                StrokeThickness = 4.0,
                                Stroke = new SolidColorBrush(Colors.Green),
                                StrokeLineJoin = PenLineJoin.Round
                            };

            rootCanvas.Children.Add(line);
        }
Ejemplo n.º 14
0
        void Plot(TJointType centerID, TJointType baseID, TJoint[] joints)
        {
            float centerX;
            float centerY;

            GetCoordinates(centerID, joints, out centerX, out centerY);

            float baseX;
            float baseY;

            GetCoordinates(baseID, joints, out baseX, out baseY);

            double diameter = Math.Abs(baseY - centerY);

            Ellipse ellipse = new Ellipse
            {
                Width = diameter,
                Height = diameter,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                StrokeThickness = 4.0,
                Stroke = new SolidColorBrush(Colors.Green),
                StrokeLineJoin = PenLineJoin.Round
            };

            Canvas.SetLeft(ellipse, centerX - ellipse.Width / 2);
            Canvas.SetTop(ellipse, centerY - ellipse.Height / 2);

            rootCanvas.Children.Add(ellipse);
        }
Ejemplo n.º 15
0
        void GetCoordinates(TJointType jointType, IEnumerable<TJoint> joints, out float x, out float y)
        {
            var joint = joints.First(j => j.JointType == jointType);

            Vector2 vector2 = Tools.Convert(joint.Position);

            x = (float)(vector2.X * rootCanvas.ActualWidth);
            y = (float)(vector2.Y * rootCanvas.ActualHeight);
        }
Ejemplo n.º 16
0
 public ContinousMovementAnalyzer(FramesCollector framesCollector, TJointType joint)
     : base(framesCollector, joint)
 {
 }