Exemple #1
0
        void OnBodyData()
        {
            var description = Sensor.DepthFrameSource.FrameDescription;
            var cm          = Sensor.CoordinateMapper;

            OnMessage(new Message <BodyFrameData>
            {
                Content = new BodyFrameData
                {
                    ScreenDescription = description,
                    Bodies            = Bodies.Select(x => new BodyModel
                    {
                        Lean                = x.Lean,
                        IsRestricted        = x.IsRestricted,
                        IsTracked           = x.IsTracked,
                        TrackingId          = x.TrackingId,
                        ClippedEdges        = x.ClippedEdges,
                        Joints              = x.Joints,
                        HandRightState      = x.HandRightState,
                        HandLeftConfidence  = x.HandLeftConfidence,
                        HandLeftState       = x.HandLeftState,
                        JointOrientations   = x.JointOrientations,
                        LeanTrackingState   = x.LeanTrackingState,
                        HandRightConfidence = x.HandRightConfidence,

                        // Convert all joint camera space points to depth space
                        // points that can be projected to 2D screen.
                        JointScreenPositions = x.Joints.ToDictionary(
                            y => y.Key,
                            y => cm.MapCameraPointToDepthSpace(new CameraSpacePoint
                        {
                            X = y.Value.Position.X,
                            Y = y.Value.Position.Y,

                            // Make sure that depth does not vanish.
                            Z = Math.Max(y.Value.Position.Z, 0.1f)
                        })
                            )
                    })
                }
            });
        }