简体   繁体   中英

Kinect 2.0 skeleton drawing - only upper body; c#

I'm doing a project with kinect 2.0 sensor.

Drawing a skeleton on user is pretty easy, but what about drawing only certain parts, or even drawing the whole skeleton, but if some body parts (feet, legs...) are outside of camera view range, than how to not draw them?

I'm using Vitruvius library and standard kinect 2.0 library.

 //depth
 using (var depthFrame = reference.DepthFrameReference.AcquireFrame())

 //Body index
 using (var bodyIndexFrame = reference.BodyIndexFrameReference.AcquireFrame())



 // Body
 using (var bodyframe = reference.BodyFrameReference.AcquireFrame())
 {
      var bodies = bodyframe.Bodies();
       ...
      _playersController.Update(bodies);
       ...
       Body body = bodies.Closest();
       viewer.Clear();
       viewer.DrawBody(body, 10.0, Brushes.Green, 10.0, Brushes.Green);
       ...
}

This is how I draw my body, and it works. If I go to ' DrawBody() ' definition, I get this:

public void DrawBody(Body body, double jointRadius, Brush jointBrush, double boneThickness, Brush boneBrush);

And if I go to body definition (so I could select what joints to draw), I find this:

//
    // Summary:
    //     Represents a single body.
    public sealed class Body
    {
        ~Body();

        //
        // Summary:
        //     Gets the number of joints in a body.
        public static int JointCount { get; }
        //
        // Summary:
        //     Gets the lean vector of the body.
        public PointF Lean { get; }
        //
        // Summary:
        //     Gets whether or not the body is restricted.
        public bool IsRestricted { get; }
        //
        // Summary:
        //     Gets whether or not the body is tracked.
        public bool IsTracked { get; }
        //
        // Summary:
        //     Gets the tracking ID for the body.
        public ulong TrackingId { get; }
        //
        // Summary:
        //     Gets the edges of the field of view that clip the body.
        public FrameEdges ClippedEdges { get; }
        //
        // Summary:
        //     Gets the status of the body's engagement. This API is not implemented in the
        //     Kinect for Windows v2 SDK. It is included to support cross-compilation with the
        //     Xbox SDK.
        [Obsolete("This API has been replaced by Microsoft.Kinect.Face", true)]
        public DetectionResult Engaged { get; }
        //
        // Summary:
        //     Gets the joint positions of the body.
        public IReadOnlyDictionary<JointType, Joint> Joints { get; }
        //
        // Summary:
        //     Gets the status of the body's right hand state.
        public HandState HandRightState { get; }
        //
        // Summary:
        //     Gets the confidence of the body's left hand state.
        public TrackingConfidence HandLeftConfidence { get; }
        //
        // Summary:
        //     Gets the status of the body's left hand state.
        public HandState HandLeftState { get; }
        //
        // Summary:
        //     Gets the status of the body's possible appearance characteristics. This API is
        //     not implemented in the Kinect for Windows v2 SDK and will always return null.
        //     It is included to support cross-compilation with the Xbox SDK.
        [Obsolete("This API has been replaced by Microsoft.Kinect.Face", true)]
        public IReadOnlyDictionary<Appearance, DetectionResult> Appearance { get; }
        //
        // Summary:
        //     Gets the status of the body's possible activities. This API is not implemented
        //     in the Kinect for Windows v2 SDK and will always return null. It is included
        //     to support cross-compilation with the Xbox SDK.
        [Obsolete("This API has been replaced by Microsoft.Kinect.Face", true)]
        public IReadOnlyDictionary<Activity, DetectionResult> Activities { get; }
        //
        // Summary:
        //     Gets the status of the body's possible expressions. This API is not implemented
        //     in the Kinect for Windows v2 SDK and will always return null. It is included
        //     to support cross-compilation with the Xbox SDK.
        [Obsolete("This API has been replaced by Microsoft.Kinect.Face", true)]
        public IReadOnlyDictionary<Expression, DetectionResult> Expressions { get; }
        //
        // Summary:
        //     Gets the joint orientations of the body.
        public IReadOnlyDictionary<JointType, JointOrientation> JointOrientations { get; }
        //
        // Summary:
        //     Gets the tracking state for the body lean.
        public TrackingState LeanTrackingState { get; }
        //
        // Summary:
        //     Gets the confidence of the body's right hand state.
        public TrackingConfidence HandRightConfidence { get; }
    }

And that is really unhelpful. Where does it say what to draw? Can I even draw only certain parts? I saw someone who drew only upper body before, but didn't have any explanation to how he did it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM