65.9K
CodeProject is changing. Read more.
Home

Controlling Your Web Camera Using C#

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.92/5 (7 votes)

May 3, 2013

GPL3

1 min read

viewsIcon

87376

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:

Controlling Your Web Camera Using C# - CodeProject