C# + DirectShow.NET = 简单的网络摄像头访问?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/833724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# + DirectShow.NET = Simple WebCam access?
提问by George
I have found an examplefor accessing a webcam in C#. The example uses the DirectShow.NETlibrary. I have tried to understand the code, but so far the only thing I could figure out is that somehow the usercontrol calls directshow to draw directly to the surface of the user control.
我找到了一个在 C# 中访问网络摄像头的示例。该示例使用DirectShow.NET库。我试图理解代码,但到目前为止我唯一能弄清楚的是用户控件以某种方式调用 directshow 直接绘制到用户控件的表面。
I want to access each frame and put it into a Bitmap object. How can I tell when a new frame arrived? How can I capture this new frame into a Bitmap Object?
我想访问每一帧并将其放入一个 Bitmap 对象中。我如何知道新框架何时到达?如何将这个新帧捕获到位图对象中?
This might be simple to answer if you know your way around DirectShow.NET.
如果您了解 DirectShow.NET,这可能很容易回答。
采纳答案by Shay Erlichmen
You will need to use the ISampleGrabberinterface there are many c++ examples on the net on how to use it, it will give you data the in RGB raw format which you can feed into the Bitmap class.
您将需要使用ISampleGrabber接口,网上有许多关于如何使用它的 C++ 示例,它会为您提供 RGB 原始格式的数据,您可以将这些数据输入 Bitmap 类。
There is also an open source library called Touchlessit has a project in code which takes a web cam and give you a callback every time a new frame arrived.
还有一个名为Touchless 的开源库,它有一个代码项目,它采用网络摄像头,并在每次新帧到达时给您一个回调。
回答by Shay Erlichmen
If you found Touchless useful, but would like to use the latest DirectX SDK, try getting the latest source after change 31008 at http://touchless.codeplex.com/SourceControl/ListDownloadableCommits.aspx
如果您发现 Touchless 有用,但想使用最新的 DirectX SDK,请尝试在更改 31008 后获取最新源代码:http://touchless.codeplex.com/SourceControl/ListDownloadableCommits.aspx
回答by nikib3ro
Be sure to take a look at this article - http://www.codeproject.com/Articles/125478/Versatile-WebCam-C-library; it is based on Touchless WebCam capturing component (but without other parts from Touchless SDK).
一定要看看这篇文章 - http://www.codeproject.com/Articles/125478/Versatile-WebCam-C-library;它基于 Touchless WebCam 捕获组件(但没有来自 Touchless SDK 的其他部分)。