How to get web cam images in C#?

2019-01-14 09:43发布

问题:

I'm working on online video conferencing project in C# and .Net4.0.

I want a library or code which I can use for collecting web camera images per second in different form. I try this by using the AVICAP32, in which we send Messages for different purpose like copy or edit frames.but in this we have to pass a reference of picturebox while creating handler as given below:

mCapHwnd = capCreateCaptureWindowA("0", 268435456 | 1073741824, 0, 0, 640, 480,picturebox1.Handle.ToInt32(), 0);

Using these commands I'm able to capture images but the problem comes when I minimize the picturebox form. At that time doesn't create new image.

I think this is happened because I minimize the form and when it copies the image from this clipboard it doesn't show anything.

How can i solve this problem . Any type of help will be appreciated.

Thanks srdusad

回答1:

I've done this using all the mentioned techniques (WIA, AviCap & DirectShow). DirectShow is your best option. Check out the free DirectShowNet library which is a .NET wrapper for DirectShow, it even includes samples: http://directshownet.sourceforge.net/

UPDATE 2012-07-26: I've just released the complete sourcecode of my Windows app CamTimer (written in .NET/C#). Download/view the complete code (with working Webcam examples) at https://github.com/johanssonrobotics/CamTimer



回答2:

If you are comfortable, you can use VLC for this. VLC provides facility to handle webcam.



回答3:

Other approach using WIA http://www.codeproject.com/KB/cs/WebCamService.aspx