Use your webcam with c#

Today my challenge was to extend an existing user management with pictures of the users. It should be able to import external pictures but it should also be possible to directly import the pictures from attached video devices, like webcams.

So i was looking for a ready-to-use .net webcam library.

I discovered that there are several ways to speak to video devices. I decided to use DirectShow because this method is compatible with most devices.

After chosing DirectShow as the method of choice i realized that Microsoft provides ready-to-use assemblies for several parts of DirectX, but not for DirectShow. Why not? I don't know. Fortuately some other guys (http://directshownet.sourceforge.net/) already did that job :)
My library is enirely based on DirectShow.Net, thanks guys you saved me hours :)

DirectShow.Net is mainly a wrapper project, so i had some effort to create simple to use capture classes.

The Test Project looks as follows:


The webcam library currently has the following features:

  • Enumerate all available video devices
  • Retrieve images of one or more devices
  • Ready to use control to display the webcam video
  • Capture still images

On request i can also add more functionality.

If someone finds it useful, please leave me a comment

Check out the code at: https://github.com/deveck/dotNetWebcamLibrary

References

We already have some projects using parts of this library (correct me if i'm wrong):

  • wiffzack.com uses it in their cash software for guest image recording

Updates

  • 25.11.2010: Did some minor changes to prevent possible race condition in ImageCaptureControl