Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get web cam images in C#?

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

like image 254
SR Dusad Avatar asked Feb 28 '23 00:02

SR Dusad


1 Answers

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

like image 50
Fredrik Johansson Avatar answered Mar 06 '23 20:03

Fredrik Johansson