Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Controlling Your Web Camera Using C#

4.92/5 (7 votes)
3 May 2013GPL31 min read 87.4K  
Controlling your web camera using C#.

I have recently been looking for a C# project to control my web cam or an attached video camera.  Apparently, this is a tall order since most video camera controllers are written in very low level C or C++ and not easily wrapped in C# without using P/Invoke and many Dllimport statements (i.e. un-managed and possibly unsafe code).

I did stumble across the Versatile C# Webcam Library on Code Project.  However, after downloading the project’s source code, it took me quite a while to get it to compile in Visual Studio 2010.  Apparently, one of the C++ libraries used (qedit.h)  is no longer included with Windows 7.  After reading countless comments, adding a custom header file for qedit.h, and tinkering, I was able to get this project to compile in Visual Studio 2010.

For anyone who is interested, you can find the working code below!

Edit

A copy of the source code compiled in release mode can be found here HERE (version 2).

A “Published” version of the code can be found HERE.

Additional Resources:

Here is a link to the DirectShow.Net project on Sourceforge.  If you still have found what you are looking for, I believe this DirectShow.dll contains the most comprehensive set of features for controlling video.  I have not really tested this .NET wrapper, but it looks like it covers just about everything in DirectShow, and it comes with tons of example projects!

Here is a link to a very simple .NET wrapper for Microsoft’s latest video controller WIA.

Here are a few Video links from StackOverflow as well:

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)