1

so I'm using Kinect v2.0.

I want to track the body and draw the skeleton on the body. I do this successfully, but when I want to add background removal, it won't draw my skeleton anymore. So, that's how I get frame and depth and body index:

var reference = e.FrameReference.AcquireFrame();
// Color
using (var frame = reference.ColorFrameReference.AcquireFrame())

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

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

This is the code for greenscreen and for displaying body:

// Body
using (var bodyframe = reference.BodyFrameReference.AcquireFrame())
{
    if (bodyframe != null)
    {
        if (frame != null && depthFrame != null && bodyIndexFrame != null)
        {
            if (viewer.Visualization == Visualization.Color)
            {
                //viewer.Image = frame.ToBitmap();
            }
            image.Source = frame.GreenScreen(depthFrame, bodyIndexFrame);
        }
        var bodies = bodyframe.Bodies();
        _playersController.Update(bodies);
        //some calculations...
    }

The commented line viewer.Image = frame.ToBitmap(); is for displaying the frame. I want to have greenscreen so I removed the frame, but now it won't draw me the body. If I uncomment this line the skeleton will be drawn but also frame will appear. I use body = bodies.Closest(); to detect the closest body. I'm also using LightBuzz Vitruvius library and I'm programming in Visual Studio 2017. This is where the actual skeleton is being drawn:

if (body != null)
{
   viewer.DrawBody(body, 10.0, Brushes.Green, 10.0, Brushes.Green);
}

Every code written here is in void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e).

Am I missing something? Am I forgetting anything? Is this even possible? I don't understand why I need a frame to draw body.

UPDATE: I think that the problem is because of the "viewer". As viewer is in xaml a window (frame). And I would need to create a frame and than do background removal. Not yet sure how.

4

0 回答 0