none
Extracting Depth Frame data from High Definition Face Frame RRS feed

  • Question

  • Hi there. I am getting stuck with this issue and was hoping someone else would be able to help figure out what I appear to be doing wrong or maybe explain what is going on better than I can understand.

    Basically, I want to get the depth frame associated with the HD face information that is coming back from the Kinect. I know how to utilize the MultiSourceFrameArrived method that is present in many of the example codes and I am using the HDFaceBasics-WPF example to understand the HD Face information.  The basic method for the HDFaceBasics-WPF code that is want to use is the following:

    private void HDFaceReader_FrameArrived(object sender, HighDefinititionFaceFrameArrivedEventArgs e)

    {

    var reference = e.FrameReference.AcquiredFrame();

    using (reference)

    {....code...}

    }

    All of this works just fine but I want to access the depth data assocaited with these frames as well.  According to the documentation I found, the information passed through here should allow for this.  Here is what I attempted to add just to acquire the depth data:

    private void HDFaceReader_FrameArrived(object sender, HighDefinititionFaceFrameArrivedEventArgs e)

    {

    var reference = e.FrameReference.AcquireFrame();

    var depthFrame = reference.DepthFrameReference.AcquireFrame();

    using (reference)

    {....code...}

    }


    When I add in the line above for depth data acquisition, the code appears to be stuck in some loop that ultimately stops the display of information. 

    I know this isn't a lot to go on but I am a bit of a novice programmer and my current code has a lot of other things that work just fine until I add in that one line for the depth frame.

    Any advice you can give would be appreciated.

    Evan

    Saturday, November 21, 2015 8:33 PM

Answers

  • Hello Evan,

    you need to dispose also the depth frame (maybe you do, but it is not visible from the code snippet you provided). I managed to reproduce "not working" scenario if you do not release depth frame resources.

    If you re-write the event handling method like this, it should work:

    using (var faceFrame = e.FrameReference.AcquireFrame())
    using (var depthFrame = faceFrame == null ? null : faceFrame.DepthFrameReference.AcquireFrame())
    {
        // processing of the frames
    }




    • Proposed as answer by Jan Marcincin Sunday, November 22, 2015 9:41 AM
    • Edited by Jan Marcincin Monday, November 23, 2015 7:54 AM code fix
    • Marked as answer by angela.h [MSFT] Monday, November 23, 2015 11:11 PM
    Sunday, November 22, 2015 9:41 AM

All replies

  • Hello Evan,

    you need to dispose also the depth frame (maybe you do, but it is not visible from the code snippet you provided). I managed to reproduce "not working" scenario if you do not release depth frame resources.

    If you re-write the event handling method like this, it should work:

    using (var faceFrame = e.FrameReference.AcquireFrame())
    using (var depthFrame = faceFrame == null ? null : faceFrame.DepthFrameReference.AcquireFrame())
    {
        // processing of the frames
    }




    • Proposed as answer by Jan Marcincin Sunday, November 22, 2015 9:41 AM
    • Edited by Jan Marcincin Monday, November 23, 2015 7:54 AM code fix
    • Marked as answer by angela.h [MSFT] Monday, November 23, 2015 11:11 PM
    Sunday, November 22, 2015 9:41 AM
  • Great, thank you for the information. You were correct in that the Dispose function helped alleviate my issue when trying to obtain the depth frame. 

    That process seems to work just fine in my code but I'll take a look at your example and see if I can incorporate that as it might be easier than the way I currently have it setup.

    Thanks again for the help.

    Monday, November 23, 2015 12:39 AM