用Media Foundation来获取计算机摄像头

    

Media Foundation是微软在Windows上推出的下一代多媒体开发库,目的是为Windows平台提供统一的多媒体影音解决方案,开发者可以通过Media Foundation播放视频和声音文件、进行影音编码或者多媒体文件转码等等工作。Media Foundation是DirectShow为主的旧式多媒体应用程序接口的替代者与继承者,在微软的项目下将逐步淘汰替换DirectShow技术。(来自维基百科)

  1.下载 Windows SDK 

         下载地址:https://www.microsoft.com/en-us/download/details.aspx?id=8279 也可以自己在MSDN官网上去查找 media fundation SDK samples > > video Capture >> MFCaptureToFile>>Downloading the Sample >> windows SDK

  2.安装Windows SDK

         点击下载下来的sdk安装就可以了。安装要求.NET Framework 4,在网上搜索安装,如果在电脑上安装过.NET Framework 4以上版本的,如果安装出错就卸载掉其他版本,留有.NET Framework 4版本 

  3. 在安装中还有几种常见的错误:我列出来供大家参考。

         错误一:A problem occurred while installing selected Windows SDK components.Installation of the "Microsoft Windows SDK for Windows 7 Compilers for x86" product has reported the following error: 安装时发生严重错误Please attempt to resolve the problem and then start Windows SDK setup again. If you continue to have problems with this issue, please visit the SDK team support page at http://go.microsoft.com/fwlink/?LinkId=130245.Click the View Log button to review the installation log.To exit, click Finish. 解决办法:安装SDK ver7.1时不要勾选Visual C++ compiler,装完后安装KB2519277 

          错误二:A problem occurred while installing selected Windows SDK components.Installation of the "Microsoft Windows SDK for Windows 7" product has reported the following error: Please refer to Samples\Setup\HTML\ConfigDetails.htm document for further information.Please attempt to resolve the problem and then start Windows SDK setup again. If you continue to have problems with this issue, please visit the SDK team support page at http://go.microsoft.com/fwlink/?LinkId=130245.Click the View Log button to review the installation log.To exit, click Finish. 解决办法:卸载Microsoft Visual C++ 2010 x86 Redistributable,原因:Windows SDK 7.1不支持Microsoft Visual C++ 2010 x86 Redistributable - 10.0.30319 以上版本。这是安装过程中比较容易出现错误,特别是错误二。

         在一切准备工作做好了以后,就可以打开实例看看效果了;在安装SDK的目录下...Microsoft SDKs\Windows\v7.1\Samples\multimedia\media foundation 找到这个文件夹,这里面就全部是media foundation的实例。然后可以每个打开看看效果了。我选择的是SimpleCapture,这个实例就是打开计算机的摄像头。这个程序的代码对于我来说,实在是很有难度,我没有办法搞懂。我在网上查找了很多实例,可是最终没有找到精简的代码。

你可能感兴趣的:(计算机语言)