最好的DirectShow方法从网络摄像头预览捕获图像? SampleGrabber已弃用 [英] Best DirectShow way to capture image from web cam preview ? SampleGrabber is deprecated

查看:699
本文介绍了最好的DirectShow方法从网络摄像头预览捕获图像? SampleGrabber已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了DirectShow C ++应用程序,它成功预览网络摄像头视图到提供的窗口。现在我想从这个实时网络摄像头预览捕获图像。我已经使用图管理器,ICaptureGraphBuilder2,IMoniker等。
我已搜索到以下选项:
WIA&样品抓取器。
许多建议使用SampleGrabber,但根据MS的msdn文档 SampleGrabber 已弃用,不应使用。我不想使用WIA API。

I have developed DirectShow C++ app which successfully previews web cam view into provided window. Now I want to capture image from this live web cam preview. I have used graph manager, ICaptureGraphBuilder2, IMoniker etc. for that. I have searched and found following options: WIA & Sample Grabber. Many recommends using SampleGrabber but as per MS's msdn document SampleGrabber is deprecated and one should not use. And I don't want to use WIA API.

那么,哪种是最好的DirectShow方法来捕获来自实时网络摄像头预览的图像?

So which is the best DirectShow way to capture image from live web cam preview?

推荐答案

以下是 DirectShow.NET库中的DxSnap示例


使用DirectShow捕获
设备的Still引脚的快照。注意MS鼓励你使用WIA为此,但如果你
想要做与DirectShow和C#,这里是如何。

Use DirectShow to take snapshots from the Still pin of a capture device. Note the MS encourages you to use WIA for this, but if you want to do in with DirectShow and C#, here's how.

请注意,此示例仅适用于将
未压缩视频作为RBG24输出的设备。这将包括大多数网络摄像头,但
可能是零电视调谐器。

Note that this sample will only work with devices that output uncompressed video as RBG24. This will include most webcams, but probably zero tv tuners.

这是C#代码,但你应该得到的想法因为接口都是相同的。还有其他示例,介绍如何在C ++中使用 Sample Grabber Filter

This is C# code, but you should get the idea as the interfaces are all the same. And there are other samples on how to use Sample Grabber Filter in C++.

示例Grabber已弃用,从一些最新的SDK中删除,但是运行时组件都在那里,并将在那里很长一段时间,否则大量的应用程序将被打破(例如视频聊天在浏览器托管的GMail正在使用Sample Grabber)。因此,基本上Sample Grabber仍然是一种从网络摄像头捕获快照的简单方法,或者如果您也选择遵循最新的MS API - 您需要查看Media Foundation( 2016年7月9日更新:新的Windows Server安装可能需要添加Media Foundation和/或Desktop Experience功能,以使Media Foundation API与DirectShow一起使用,并且DirectShow Editing Services,Sample Grabber是其中的一部分,默认安装不提供qedit .dll开箱即用)。

Sample Grabber is deprecated, the headers are removed from a couple of latest SDKs, however the runtime components are all there and are going to be there for a long time, or otherwise a multitude of application would be broken (e.g. Video Chat in browser hosted GMail is using Sample Grabber). So basically Sample Grabber is still an easy way to capture snapshots from a web camera, or if you alternatively prefer to follow the latest MS APIs - you would want to look into Media Foundation (09 Jul 2016 update: new Windows Server installations might need one to add "Media Foundation" and/or "Desktop Experience" features to make Media Foundation API available along with DirectShow, and DirectShow Editing Services, Sample Grabber is a part of which. Default installation does not offer qedit.dll out of the box).

在C ++中,你肯定不必使用Sample Grabber Filter。您可以使用DirectShow BaseClasses开发自定义过滤器,以作为自定义变换过滤器或自定义渲染器,它接受传入的视频Feed并从DirectShow管道导出帧。另一个选项是使用来自一个较旧的SDK(这不是OS Sample Grabber的精确源,但是它做同样的事情)的Sample Grabber示例源代码。然而,Windows随附的Sample Grabber仍然是一个很好的选择。

Also in C++ you certainly don't have to use Sample Grabber Filter. You can develop a custom filter using DirectShow BaseClasses to be a custom transformation filter or a custom renderer, which which accept incoming video feed and export the frames from the DirectShow pipeline. Another option is to use Sample Grabber sample source code from one of the older SDKs (which is not exact source for OS Sample Grabber, but it is doing the same thing). The point however that Sample Grabber shipped with Windows is still a good option.

这篇关于最好的DirectShow方法从网络摄像头预览捕获图像? SampleGrabber已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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