Exemplo n.º 1
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>
        private void DrawBone(DrawingContext dc, Skeleton skeleton, JointType jointType0, JointType jointType1)
        {
            Joint joint0 = skeleton.Joints[jointType0];
            Joint joint1 = skeleton.Joints[jointType1];

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

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

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

            if (joint0.TrackingState == JointTrackingState.Tracked && joint1.TrackingState == JointTrackingState.Tracked)
            {
                drawPen = this.TrackedBonePen;
            }

            dc.DrawLine(drawPen, RoomSetting.CameraPointToObservePoint(SkeletonPointToCameraPoint(joint0.Position)), RoomSetting.CameraPointToObservePoint(SkeletonPointToCameraPoint(joint1.Position)));
        }
Exemplo n.º 2
0
        /*
         * private const int DMAFilterN = 3;
         * private Filter DMAFilterX = new DMAFilter(DMAFilterN);
         * private Filter DMAFilterY = new DMAFilter(DMAFilterN);
         *
         * private const int MedianFilterN = 4;
         * private Filter MedianFilterX = new MedianFilter(MedianFilterN);
         * private Filter MedianFilterY = new MedianFilter(MedianFilterN);
         */
        /// <summary>
        /// draw output points on the screen
        /// </summary>
        private void DrawOutput()
        {
            using (DrawingContext dc = this.outputDrawingGroup.Open())
            {
                dc.DrawImage(blankColorBitmap, new Rect(0.0, 0.0, RenderWidth, RenderHeight));
                RoomSetting.PaintPlatesAndCoordinates(dc);

                foreach (Player player in this.players)
                {
                    player.DrawSkeleton(dc);

                    if (player.headAndHandValid == true)
                    {
                        SpacePoint intersection = RoomSetting.FindTheIntersection(RoomSetting.CameraPointToRoomPoint(player.startPointInCameraCoordinates),
                                                                                  RoomSetting.CameraPointToRoomPoint(player.endPointInCameraCoordinates));

                        if (intersection != null)
                        {
                            Point showPoint = RoomSetting.RoomPointToObservePoint(intersection);
                            dc.DrawLine(new Pen(player.color, 2), RoomSetting.CameraPointToObservePoint(player.startPointInCameraCoordinates),
                                        showPoint);

                            if (showPoint.X >= 0 && showPoint.X < RenderWidth && showPoint.Y >= 0 && showPoint.Y < RenderHeight)
                            {
                                dc.DrawEllipse(player.color, null, showPoint, this.PointThickness, this.PointThickness);
                            }
                            else
                            {
                                RenderClippedEdges(showPoint, dc);
                            }
                        }
                    }
                }
            }
        }