简体   繁体   中英

C# + DirectShow.NET = Simple WebCam access?

I have found an example for accessing a webcam in C#. The example uses the DirectShow.NET library. 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.

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?

This might be simple to answer if you know your way around 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.

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.

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).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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