Пример #1
0
        void kinectStreamer_BodyDataReady(object sender, KinectStreamerEventArgs e)
        {
            Bodies = e.Bodies;

            using (DrawingContext dc = drawingGroup.Open())
            {
                dc.DrawImage(ColorImageSource, new Rect(0.0, 0.0, displayWidth, displayHeight));

                int penIndex = 0;
                foreach (Body body in Bodies)
                {
                    Pen drawPen = bodyColors[penIndex++];

                    if (body.IsTracked)
                    {
                        IReadOnlyDictionary<JointType, Joint> joints = body.Joints;

                        // convert the joint points to depth (display) space
                        Dictionary<JointType, Point> jointPoints = new Dictionary<JointType, Point>();

                        foreach (JointType jointType in joints.Keys)
                        {
                            // sometimes the depth(Z) of an inferred joint may show as negative
                            // clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
                            CameraSpacePoint position = joints[jointType].Position;
                            if (position.Z < 0)
                            {
                                position.Z = InferredZPositionClamp;
                            }
                            ColorSpacePoint colorSpacePoint = kinectStreamer.CoordinateMapper.MapCameraPointToColorSpace(position);
                            jointPoints[jointType] = new Point(colorSpacePoint.X, colorSpacePoint.Y);
                        }

                        DrawBody(joints, jointPoints, dc, drawPen);

                        DrawHand(body.HandLeftState, jointPoints[JointType.HandLeft], dc);
                        DrawHand(body.HandRightState, jointPoints[JointType.HandRight], dc);

                        CheckActiveWorkspace(new CameraSpacePoint[]{
                            body.Joints[JointType.HandRight].Position,
                            body.Joints[JointType.HandLeft].Position});
                    }
                }
                // prevent drawing outside of our render area
                drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, displayWidth, displayHeight));
                DrawWorksapces(dc);
                OnPropertyChanged("ColorImageSource");
                OnPropertyChanged("ImageSource");
            }
        }
Пример #2
0
 void kinectStreamer_ColorDataReady(object sender, KinectStreamerEventArgs e)
 {
     colorBitmap = e.ColorBitmap;
     OnPropertyChanged("ColorImageSource");
     OnPropertyChanged("ImageSource");
 }
Пример #3
0
 void kinectStreamer_DepthDataReady(object sender, KinectStreamerEventArgs e)
 {
     depthBitmap = e.DepthBitmap;
     OnPropertyChanged("ImageSource");
 }