Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Webcamera, Multithreading and VFW

, 15 Feb 2008 CPOL
An article on webcamera frame-grabbing in a multi-thread environment
vfwwebcamdemo.zip
ImageProcessing.dll
WebCam.exe
WebCamera.dll
vfwwebcamsource.zip
ImageProcessing
Properties
WebCam
Properties
Settings.settings
WebCamera
Properties
WebCamera.csproj.user
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace SevenZ.WebCamera
{
   public class Device
   {
      public string Name;
      public string Version;

      public Device(string name, string version)
      {
         this.Name = name; this.Version = version;
      }

      public override string ToString()
      {
         return Name + "  " + Version;
      }
      
   }

   public class WebCameraDeviceManager
   {
      [DllImport("avicap32.dll")]
      static extern bool capGetDriverDescription(int wDriverIndex,
          [MarshalAs(UnmanagedType.VBByRefStr)]ref String lpszName,
          int cbName, [MarshalAs(UnmanagedType.VBByRefStr)] ref String lpszVer, int cbVer);
      
      List<Device> devices = new List<Device>(10);

      public WebCameraDeviceManager()
      {
         Refresh();
      }

      public void Refresh()
      {
         string name = "".PadRight(100), version = "".PadRight(100);

         for (int i = 0; i < 10; i++)
         {
            if (capGetDriverDescription(i, ref name, 100, ref version, 100))
            {
               Device d = new Device(name,version);
               d.Name = name.Trim();
               d.Version = version.Trim();
               devices.Add(d);
            }
         }
      }

      public Device Device(int index)
      {
         return devices[index];
      }

      public Device[] Devices
      {
         get { return devices.ToArray(); }
      }
   }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Zaur Nasibov
Software Developer
Finland Finland
I'm a Master degree student, studying at the University of Joensuu, Finland.

| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 16 Feb 2008
Article Copyright 2007 by Zaur Nasibov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid