View Single Post
  #2 (permalink)  
Old 07-30-2007, 12:18 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Thumbs up Re: How to control the webcam using C#?

Hi buddy,

I looked for the resources and found a couple of different ways of doing this.

1) Using WIA SDK:

This is the easier of the two methods to control the webcam by using the COM wrapper. This COM API is provided as part of the WIA SDK. Although most of the webcams do work by this method but if you get an exception "Exception from HRESULT: Ox80210015", chances are that you can't use this API.
Otherwise, this is a much better option. For more information, check Scott's article on MSDN.

2) Using "avicap32.dll":

The second method is to invoke the API's inside "avicap32.dll" to interact with the webcam device. This is a bit harder as you have to manually create signatures for the methods inside the dll.

So, for this project I wrote a simple class to wrap the basic functionality exposed by the dll. By using that, you will be able to get all the attached devices and can also see the preview of webcam inside a control (such as picturebox). It is a very small project but will save someone a little time.

I have atached a sample project. Find the Zip file.

There are two projects inside the zip file.

WebCamLib: This contains the wrapper around a couple of API's in "avicap32.dll".
Qurtaba: A Test project which uses the WebCamLib to show webcam preview.

Hope usefull.
Attached Files
File Type: zip WebCamLib.zip (44.4 KB, 3722 views)
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Reply With Quote