comparison on webcam connection code libraries in c#

if u search u will find more than one hundred dll for c# to take input video stream or picture from webcam, all of them are doing nearly same thing but in different way, couple of them have more feature than other, every one has some advantage and disadvantage.

first i m going to discuss about most little size library name WebCam_Capture.dll only 24kb it is the smallest and  probably the most old library for webcam in c#. but a warning it cant work in  integreted webcam i mean it will not likely work in laptop webcam only external webcam will work, so u can  reject it. but if u r not going to use internal cam and u r not have to do fastest image processing type job u can consider it. is connection code is easiest .

 private WebCam_Capture.WebCamCapture WebCamCapture;
 private void Form1_Load(object sender, System.EventArgs e) {
            this.WebCamCapture.CaptureHeight = this.pictureBox1.Height;
            this.WebCamCapture.CaptureWidth  = this.pictureBox1.Width;
private void WebCamCapture_ImageCaptured(object source, WebCam_Capture.WebcamEventArgs e)
              this.pictureBox1.Image = e.WebCamImage;

some additional command

 this.WebCamCapture.Stop();//for stoping
 this.WebCamCapture.Start(this.WebCamCapture.FrameNumber); // for continue after stop

next i m going to discuss about DirectShowLib.dll , it probabaly most popular i see , but i dont know the reason why i dont like it much, it is larger size and it has some privacy issue 🙂 i think. well for normal and fast purpose u can use it.
u will find it sample code. very troublesome if u want to make a movie consider it :),

my most favorite is aforge webcam dll, u need to download aforge dll, and  also add a very good videocontrol for showing video u can add it in ur toolbox. just click freespace on toolbox chooseitems-> browse the dll -> add the control

using AForge;
using AForge.Video.DirectShow;

then initialize

  videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

               foreach (FilterInfo device in videoDevices)
VideoCaptureDevice videoSource = new VideoCaptureDevice(device.MonikerString);
 videoSource.DesiredFrameSize = new Size(320, 240);
 videoSource.DesiredFrameRate = 15;
videoSourcePlayer1.VideoSource = videoSource;

for videoplayercontrol add a event in its misc

 private void videoSourcePlayer1_NewFrame(object sender, ref Bitmap image)
        {//work with image :)

now there is another named u have to add dll from there. it is easy but need a timer also. but simplicity rulzz :).

using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;

namespace face
    public partial class Form1 : Form
        private Capture cap;
        public Form1()
      {  cap = new Capture(0);
  private void timer1_Tick(object sender, EventArgs e)
            using (Image nextFrame = cap.QueryFrame())
             pictureBox1.Image = nextFrame.ToBitmap();
//work with image :)


so emgucv and aforge giving u best option for webcam programming, whatever u choose u will get plenty of resource in online.

but if u want to hear an honest opinion here is the summery

  • webcam_capture: easy , small but backdated
  • directshownet :      complicated but many features
  • Aforge: easy, gool control or componnent whatever u say problem is size
  • emgucv: easy,need help from timer ,size matters

i m going for emgu and aforge depend on application, because both of them are upgraded regularly and effectively .


About kishordgupta

A software developer
This entry was posted in C#, Image Processing and tagged , , , , , , , , , , , . Bookmark the permalink.

One Response to comparison on webcam connection code libraries in c#

  1. Thank you very much, you saved my day ..!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s