Starting With Emgu CV in .NET

What is the Emgu CV?

Before learning what Emgu CV is, one should know what OpenCV is.

OpenCV

OpenCV stands for Open Source Computer Vision. It was designed especially for computational efficiency with a strong focus on real-time applications. It is written in optimized C/C++ and can take advantage of multi-core processing. In Image processing, it has been a great boon for the developers.

Emgu CV

It is essentially a huge library of "wrapper" functions that allow calling OpenCV functions from Visual Studio Windows Form Application. It is necessary because Visual Studio/.NET is an "interpreted" environment that cannot directly call functions written in native C/C++.

In this tutorial, we will start configuring our Visual Studio and environment for developing applications using Emgu CV.

First, we need to download some of the essential tools. We will be using the most stable versions though the new versions are also available.

  1. Visual Studio 2010 Express Edition
  2. Emgu CV(version 2.4.2 is available but had various issues so I'm using the most stable version found, which is 2.3.0)

Once you have installed all this it should work fine, but one common exception that occurs:

The type initializer for "Emgu.CV.CvInvoke" threw an exception.

If you see this exception, do the following.

  • For Version 2.4+, the bundled OpenCV binary is built with Visual Studio 2010, you need to install MSVCRT 10.0 SP1 x86 or MSVCRT 10.0 SP1 x64 to resolve the dependency issue.
  • For Version 2.0+, the bundled OpenCV binary is built with Visual Studio 2008, you need to install MSVCRT 9.0 SP1 to resolve the dependency issue.
  • For Version 1.5, the bundled OpenCV pre1.1 binary is built with Visual Studio 2005, you need to install MSVCRT 8.0 SP1 to resolve the dependency issue.

This is the most effective solution to the problem for the above exception, for others and detailed troubleshooting click here.

Now start the configuration part.

  1. We need to add an environment variable to the system variables.
  2. Right-click "My Computer" then select "Advanced System Settings" > "Environment Variables".
  3. Under "System Variables" edit variable "path".
  4. add a semicolon(;) and the path to the emgu installation directory's bin folder (by default it is "C:\Emgu\emgucv-windows-x86 2.3.0.1416\bin").
    System Variables
  5. Now the environment is ready and we need to add the emgu custom controls to the Visual Studio ToolBox.
  6. In the toolbox, right-click on the General tab and select "choose items"; see:
    Items
  7. Select browse in the bottom-right corner and browse for "Emgu.CV.UI.dll" (it is located in the bin folder of the installation directory, such as "C:\Emgu\emgucv-windows-x86 2.3.0.1416\bin").
  8. Now Visual Studio will have the tools for menu control.
     Visual Studio

This is all that is required to set up the environment for working with Emgu CV, in the next article we will learn how to create our first project with Emgu CV.


Similar Articles