Camera Capture in 7 lines of code using Emgu CV

This tutorial are for those who had a background in Emgu CV and for those who are new in EmguCV visit this link: http://www.emgu.com/wiki/index.php/Download_And_Installation This tutorial talks about on how to use your webcam in your pc using EmguCV with C# as your code. So first create a project then name it whatever you want then after that add the following references in your project Emgu.CV.dll,Emgu.CV.UI.dll, and Emgu.Util. After adding those referrences add a new form then add a picture box. So when you are done in designing your form, add the following codes.Excluding the using statements in the beginning, only 7 lines of code are required to perform a camera capture loop.
  1. using Emgu.CV;
  2. using Emgu.CV.UI;
  3. using Emgu.CV.Structure;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. ...
  7.  
  8. ImageViewer viewer = new ImageViewer(); //create an image viewer
  9. Capture capture = new Capture(); //create a camera captue
  10. Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
  11. {  //run this until application closed (close button click on image viewer)
  12.    viewer.Image = capture.QueryFrame(); //draw the image obtained from camera
  13. });
  14. viewer.ShowDialog(); //show the image viewer
This example requires Emgu CV 1.5.0.0 or later.

Add new comment