本文介绍了当MultiSourceFrame准备好并获得时,是否可以保证各种帧类型不为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当MultiSourceFrameReader触发MultiSourceFrameArrived事件时,是否可以保证MultiSourceFrame将具有我在打开MultiSourceFrameReader时请求的所有帧类型?

When the MultiSourceFrameReader fires a MultiSourceFrameArrived event, is there any guarantee that the MultiSourceFrame will have all the frame types that I requested when I opened the MultiSourceFrameReader?

如果不是,在什么条件下会丢失某些帧类型?

If not, under what conditions would some frame types be missing?

某些帧类型总是 可以通过MultiSourceFrame获得吗?

Will certain frame types be always available through the MultiSourceFrame?

推荐答案

MultiSourceFrame multiSourceFrame = e.FrameReference.AcquireFrame();           

// If the Frame has expired by the time we process this event, return.
if (multiSourceFrame == null)
{
    return;
}

// We use a try/finally to ensure that we clean up before we exit the function.  
// This includes calling Dispose on any Frame objects that we may have and unlocking the bitmap back buffer.
try
{                
    depthFrame = multiSourceFrame.DepthFrameReference.AcquireFrame();
    colorFrame = multiSourceFrame.ColorFrameReference.AcquireFrame();
    bodyIndexFrame = multiSourceFrame.BodyIndexFrameReference.AcquireFrame();

    // If any frame has expired by the time we process this event, return.
    // The "finally" statement will Dispose any that are not null.
    if ((depthFrame == null) || (colorFrame == null) || (bodyIndexFrame == null))
    {
        return;
    }

    // from this point on you have the frames
    // if you take to long to process frames, the runtime will no longer provide frame updates
    // copy data and release the frames as quickly as possible
}
...
finally
{

    if (depthFrame != null)
    {
        depthFrame.Dispose();
    }

    if (colorFrame != null)
    {
        colorFrame.Dispose();
    }

    if (bodyIndexFrame != null)
    {
        bodyIndexFrame.Dispose();
    }
}





这篇关于当MultiSourceFrame准备好并获得时,是否可以保证各种帧类型不为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 13:55