4

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

Yacoby
  • 54,544
  • 15
  • 116
  • 120
SR Dusad
  • 73
  • 1
  • 4
  • 13
  • Did any of the google searches for "webcam c#" work for you? – PatrickSteele May 21 '10 at 13:39
  • @ Patrick : currently i m using AVICAP32.dll and this is working for me. But my problem is that i want to use camera images in diferent forms. But by using AVICAP32.dll we have to bind a picturebox handler for get picture. and when i minimize the form it doesn't send anything on other system.I also try some other like WIA and directshow but i can't found much help from them. – SR Dusad May 22 '10 at 05:17

3 Answers3

8

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

Fredrik Johansson
  • 3,477
  • 23
  • 37
  • thanks for giving your views. I downloads the files from above link and the samples run perfectly. But i don't yet able to use this in other form , so i can view same picture in both forms without any dependency.Pls give me any idea that how can i show picture in multi forms using directshow. – SR Dusad May 28 '10 at 08:19
  • When i change the framework of sample from 2.0 to 4.0 ,it gives me error on sourceFilter = FindCaptureDevice(); pls tell me how to use the direct show sample in .net4.0 – SR Dusad May 28 '10 at 09:50
  • Great to hear that it's working (even if partly)! You should try asking this question in the dedicated DirectShowNet forums at SourceForge, i'm sure the developers are better suited to answer this: http://sourceforge.net/projects/directshownet/forums/forum/460697 – Fredrik Johansson May 28 '10 at 10:23
  • Hi Fedrik : The samples worked correctly upto .Net3.5 but when i change version to .Net4.0 .It gives me error on moniker[0].BindToObject(null, null, ref iid, out source); in public IBaseFilter FindCaptureDevice() function.Pls help me because i want this DirectShownet in .Net4.0 – SR Dusad Jun 01 '10 at 05:22
  • SR Dusad, there is error in your code as I mentioned on DirectShow.Net forum. Last sample and last DirectShow.Net work fine with any version of .net including .net4 and VS2010. – Konstantin Salavatov Jun 04 '10 at 05:52
  • @Konstantin:At my side does all effort,but can't find any success.Pls can send me mail of that sample running on .net4.0 vs2010. my mail id is "sanjudusad@gmail.com" . i m waiting for ur mail. Thanks in aadvance – SR Dusad Jun 04 '10 at 13:22
  • Surface camera can be used for it ? – Asadullah Ali Dec 05 '13 at 03:32
0

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

Ram
  • 11,404
  • 15
  • 62
  • 93
  • Thanks for your reply ! I want to show these grabbed picture in the picture box of diferent forms . If VLC will helpfull , then guide me how to use VLC in my .net code and which dll i have to need for this. – SR Dusad May 22 '10 at 05:11
  • You can use VLC wrapper created for .NET. You can go to VLC site and also seek help from the VLC developer forum. – Ram May 24 '10 at 05:51
0

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

Konstantin Salavatov
  • 4,370
  • 2
  • 25
  • 24