在DirectShow中获取捕获的视频帧的不同方法 [英] Different approaches on getting captured video frames in DirectShow

查看:263
本文介绍了在DirectShow中获取捕获的视频帧的不同方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用回调机制在媒体应用程序中抓取网络摄像头帧.它可以正常工作,但是由于在回调本身中执行了某些额外的缓冲功能,所以运行速度很慢.

I was using a callback mechanism to grab the webcam frames in my media application. It worked, but was slow due to certain additional buffer functions that were performed within the callback itself.

现在,我正在尝试另一种获取帧的方法.也就是说,调用方法并获取框架(而不是回调).我在CodeProject中使用了一个示例,该示例利用了IVMRWindowlessControl9 :: GetCurrentImage.

Now I am trying the other way to get frames. That is, call a method and grab the frame (instead of callback). I used a sample in CodeProject which makes use of IVMRWindowlessControl9::GetCurrentImage.

我遇到了以下问题.

  1. 在Microsoft网络摄像头中,Preview在Windows 7上没有渲染(只有黑屏),但是同一台摄像机在XP上渲染了Preview.

我的疑问是,VMR的特定功能是否取决于不同平台上的摄像头驱动程序?否则,这种差异怎么发生?

Here my doubt is, will the VMR specific functionalities be dependent on camera drivers on different platforms? Otherwise, how could this difference happen?

  1. 无论示例应用程序如何工作,我都观察到生成的BITMAPINFOHEADER结构的biBitCount成员为32.

这是应用程序设置的值还是VMR操作的驱动程序设置?如何配置? 最后,哪种是抓取网络摄像头帧的最佳方法?回调方法?还是直接方法?

Is this a value set by application or a driver setting for VMR operations? How is this configured? Finally, which is the best method to grab the webcam frames? A callback approach? Or a Direct approach?

预先感谢

推荐答案

IVMRWindowlessControl9::GetCurrentImage用于偶尔的快照,而不用于常规图像捕获.

IVMRWindowlessControl9::GetCurrentImage is intended for occasional snapshots, not for regular image grabbing.

来自MSDN的报价:

无论过滤器处于什么状态,都可以随时调用此方法 处于运行,停止还是暂停状态. 但是,经常拨打 这种方法会降低视频播放性能.

This method can be called at any time, no matter what state the filter is in, whether running, stopped or paused. However, frequent calls to this method will degrade video playback performance.

此方法首先从缓慢的视频内存中回读.这种方法确实可以转换(即再次变慢)到RGB颜色空间,因为这种格式最适合非流式应用程序,并且兼容性问题较少.

This methods reads back from video memory which is slow in first place. This methods does conversion (that is, slow again) to RGB color space because this format is most suitable for for non-streaming apps and gives less compatibility issues.

总而言之,您可以将其用于定期图像抓取,但这不是您应做的.要以流式传输速率捕获,您需要在管道中使用过滤器,或在带回调的Sample Grabber中使用

All in all, you can use it for periodic image grabbing, however this is not what you are supposed to do. To capture at streaming rate you need you use a filter in the pipeline, or Sample Grabber with callback.

这篇关于在DirectShow中获取捕获的视频帧的不同方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆