예제 #1
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);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        ///  Called to update point info
        /// </summary>
        public void AnalyzeHeadAndHands()
        {
            if (skeleton.Joints[JointType.HandLeft].TrackingState == JointTrackingState.Tracked)
            {
                //System.Diagnostics.Debug.WriteLine(RoomSetting.CameraPointToRoomPoint(this.painter.SkeletonPointToCameraPoint(skeleton.Joints[JointType.HandLeft].Position)).Z);

                if (RoomSetting.CameraPointToRoomPoint(this.painter.SkeletonPointToCameraPoint(skeleton.Joints[JointType.HandLeft].Position)).Z > 1200)
                {
                    RoomSetting.move = true;
                }
                else
                {
                    RoomSetting.move = false;
                }
            }

            // If we can't find either head or right hand, exit
            if (skeleton.Joints[JointType.Head].TrackingState == JointTrackingState.NotTracked ||
                skeleton.Joints[JointType.HandRight].TrackingState == JointTrackingState.NotTracked)
            {
                this.headAndHandValid = false;
                return;
            }

            // Don't analyze if both points are inferred
            if (skeleton.Joints[JointType.Head].TrackingState == JointTrackingState.Inferred &&
                skeleton.Joints[JointType.HandRight].TrackingState == JointTrackingState.Inferred)
            {
                this.headAndHandValid = false;
                return;
            }

            this.headAndHandValid = true;
            //this.startPointInColorFrame = this.painter.SkeletonPointToScreen(skeleton.Joints[JointType.Head].Position);
            this.startPointInCameraCoordinates = this.painter.SkeletonPointToCameraPoint(skeleton.Joints[JointType.Head].Position);
            //this.endPointInColorFrame = this.painter.SkeletonPointToScreen(skeleton.Joints[JointType.HandRight].Position);
            this.endPointInCameraCoordinates = this.painter.SkeletonPointToCameraPoint(skeleton.Joints[JointType.HandRight].Position);
        }