I want to connect to a USB Webcam in .NET, specifically using C#. Being new to .NET I don't know what kind of support there is in the standard libraries for doing so. I found one example on the web that copies bitmaps through the clipboard, but that seems very hacky (and probably slow). Is there a better way?
6 Answers
You will need to use Windows Image Acquisition (WIA) to integrate a webcam with your application. There are plenty examples of this readily available. Here is a C# Webcam User Control with source.
Here are some more articles and blog posts from people looking to solve the same problem you are:

- 3,641
- 2
- 34
- 42

- 47,184
- 49
- 157
- 202
-
Hi. Is this still up to date? Microsoft comment that WIA on Vista onwards doesn't support video - I think they mean they only support scanners? Also, your second link, which is to the WIA example when you get to the article it says uses direct-show *and doesn't mention WIA*. Does this mean that really we should use direct-show nowadays? – noelicus Mar 07 '14 at 10:37
Interesting side note, WIA isn't supported by Vista for doing Captures from Webcams anymore. They mainly targeted it towards Scanners and pulling stills from cameras.
Also, larger manufacturers like logitech have abandoned WIA is favor of DirectShow.

- 1,166
- 2
- 15
- 28
-
3+1, though can you include any links to back this up in more detail? – DuckMaestro Jan 02 '12 at 07:35
Here is nice example of doing this. It's using DirectShow.Net (http://directshownet.sourceforge.net/), which is propably better than using "clipboard" :D.
https://www.codeproject.com/Articles/18511/Webcam-using-DirectShow-NET
Theres a package with functions with a lot of things to do with computer vision systems called AForge. And they have an easy way to get webcam images from a USB camera if you're still looking.
Just check out the sample code for computer vision motion sensor example code. I'm sure you can pull out the function calls you need from it as I did.
[sorry to necro, but this could be of use to someone in the future]

- 14,180
- 18
- 64
- 84
On my computer, WIA was painstakingly sloooow... so i decided to give the Windows Multimedia Video Capture a try.
You can find a demo here.

- 346
- 4
- 9
It really depends on what you want to do. WIA is primarily for capturing stills from imaging devices, and DirectShow (used either through directshow.net or managed DirectX) is for access to fuller video features.
The other option is to create a WPF application. It has a huge amount of built in support for video (to the extent that having a looping video clip as a button is pretty trivial), and should be quick and easy to develop.

- 51
- 2