Click here to Skip to main content
15,881,755 members
Articles / Desktop Programming / Windows Forms

Versatile WebCam C# library

Rate me:
Please Sign up or sign in to vote.
4.96/5 (137 votes)
23 Feb 2015CPOL9 min read 1.1M   85K   444  
Easy to use C# WebCam library that's not plagued with weird DLL references or PInvoke calls
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Touchless.Vision.Camera
{
    internal static class WebCamLibInterop
    {

        //[DllImport("WebCamLib.dll", EntryPoint = "Initialize")]
        //public static extern int WebCamInitialize();

        //[DllImport("WebCamLib.dll", EntryPoint = "Cleanup")]
        //public static extern int WebCamCleanup();

        //[DllImport("WebCamLib.dll", EntryPoint = "RefreshCameraList")]
        //public static extern int WebCamRefreshCameraList(ref int count);

        //[DllImport("WebCamLib.dll", EntryPoint = "GetCameraDetails")]
        //public static extern int WebCamGetCameraDetails(int index,
        //    [Out, MarshalAs(UnmanagedType.Interface)] out object nativeInterface,
        //    out IntPtr name);

        public delegate void CaptureCallbackProc(
                UInt32 dwSize,
                [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1, SizeParamIndex = 0)] byte[] abData);

        //[DllImport("WebCamLib.dll", EntryPoint = "StartCamera")]
        //public static extern int WebCamStartCamera(
        //    [In, MarshalAs(UnmanagedType.Interface)] object nativeInterface,
        //    CaptureCallbackProc lpCaptureFunc,
        //    ref int width,
        //    ref int height
        //    );

        //[DllImport("WebCamLib.dll", EntryPoint = "StopCamera")]
        //public static extern int WebCamStopCamera();

        //[DllImport("WebCamLib.dll", EntryPoint = "DisplayCameraPropertiesDialog")]
        //public static extern int WebCamDisplayCameraPropertiesDialog(
        //    [In, MarshalAs(UnmanagedType.Interface)] object nativeInterface);
    }
}

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)


Written By
Chief Technology Officer
United States United States
If you liked this article, consider reading other articles by me. For republishing article on other websites, please contact me by leaving a comment.

Comments and Discussions