当Windows 10 UWP .NET C#应用程序的MediaFrameReader.FrameArrived事件接收到来自Logitech C920 USB网络摄像头的图像帧时,在哪里进行解压缩(解码)?
是在MediaFrameReader.FrameArrived事件之前还是在我调用sender.TryAcquireLatestFrame()时,摄像机的帧是否已解码?
答案 0 :(得分:0)
是在MediaFrameReader.FrameArrived事件之前还是在我调用sender.TryAcquireLatestFrame()时,摄像机的帧是否已解码?
对于此问题,您可以参考Camera Frames代码示例。从代码的角度来看。解压缩(解码)发生在FrameArrived
之前。
private void FrameReader_FrameArrived(MediaFrameReader sender, MediaFrameArrivedEventArgs args)
{
// TryAcquireLatestFrame will return the latest frame that has not yet been acquired.
// This can return null if there is no such frame, or if the reader is not in the
// "Started" state. The latter can occur if a FrameArrived event was in flight
// when the reader was stopped.
using (var frame = sender.TryAcquireLatestFrame())
{
if (frame != null)
{
var renderer = _frameRenderers[frame.SourceKind];
renderer.ProcessFrame(frame);
}
}
}
因为帧具有contained SoftwareBitmap
。这意味着原始数据已被解码,然后打包为帧实例。