简体   繁体   English

C#+ DirectShow.NET =简单的WebCam访问?

[英]C# + DirectShow.NET = Simple WebCam access?

I have found an example for accessing a webcam in C#. 我找到了一个用C#访问网络摄像头的例子 The example uses the DirectShow.NET library. 该示例使用DirectShow.NET库。 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. 我试图理解代码,但到目前为止我唯一可以理解的是,usercontrol不知何故调用directshow直接绘制到用户控件的表面。

I want to access each frame and put it into a Bitmap object. 我想访问每个帧并将其放入Bitmap对象。 How can I tell when a new frame arrived? 如何判断新帧何时到达? How can I capture this new frame into a Bitmap Object? 如何将这个新帧捕获到位图对象中?

This might be simple to answer if you know your way around DirectShow.NET. 如果您了解DirectShow.NET的方法,这可能很容易回答。

You will need to use the ISampleGrabber interface 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 Touchless it has a project in code which takes a web cam and give you a callback every time a new frame arrived. 还有一个名为Touchless的开源库,它有一个代码项目,它带有一个网络摄像头,每次新帧到达时都会给你一个回调。

Be sure to take a look at this article - http://www.codeproject.com/Articles/125478/Versatile-WebCam-C-library ; 一定要看一下这篇文章 - 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). 它基于Touchless WebCam捕获组件(但没有Touchless SDK的其他部分)。

如果您发现Touchless很有用,但想使用最新的DirectX SDK,请尝试在http://touchless.codeplex.com/SourceControl/ListDownloadableCommits.aspx上更改31008后获取最新的源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM