Windows

Getting the Dependency

For Version 3.0+, the required vcrt dlls are included in the "x86" and "x64" folder. You will be ready as long as you copy all the unmanaged dlls in the "x86" and "x64" folder to the folder of executable.

Creating a New Project in Visual Studio

For a Full guide to using the dependencies under Visual Studio and C# see the C# Tutorial.

Core Functionality

Managed Code

Create a new Visual Studio project or use an existing one

Add the two files Emgu.Utils.dll and Emgu.CV.dll to References of the project. as well.

Optionally put the following lines in the top of your code to include the Emgu.CV namespace.

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

Open CV unmanaged dll

Universal Package

For the new universal packages (packages that contains the word "-universal" in the package name):
Copy the "x86" and "x64" folder, along with the DLLs inside those folder to the folder of the executable. The universal package is able to load the unmanaged binary from the "x86" folder when running in 32bit mode, and load the unmanaged binary from the "x64" folder when running in 64bit-mode.

Architecture Specific Package

For architecture specific package (packages that contains either the work "-x86" or "-x64" in the package name):
Copy the OpenCV dll files: opencv_calib3d{XXX}.dll, opencv_contrib{XXX}.dll, opencv_core{XXX}.dll, opencv_features2d{XXX}.dll, opencv_ffmpeg{XXX}.dll, opencv_flann{XXX}.dll, opencv_gpu{XXX}.dll, opencv_highgui{XXX}.dll, opencv_imgproc{XXX}.dll, opencv_legacy{XXX}.dll, opencv_ml{XXX}.dll, opencv_objdetect{XXX}.dll, opencv_video{XXX}.dll and cvextern.dll to the execution directory, where {XXX} is the OpenCV version number.

CUDA (GPU) package

Emgu CV 3.x

Only package containing -cuda in its name (e.g. libemgucv-xxx-cuda-xxx ) has CUDA processing enabled.

Optionally put the following lines in the top of your code to include the Emgu.CV.GPU namespace.

using Emgu.CV.GPU;

Commercial package

The commercial version is build with Intel Compiler, Intel IPP and (commercial version of) Intel TBB. It contains -tbb-ipp-icc in the package file name. Once you purchase the commercial version you will received an email containing the instructions to download these packages.

Start Developing

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

If you see this exception, please check the following

Have you installed MSVCRT?

For Version 3.0+, the required vcrt dlls are included in the "x86" and "x64" folder. You will be ready as long as you copy all the unmanaged dlls in the "x86" and "x64" folder to the folder of executable.

For Emgu CV version 2.2, 2.3 this means the following dlls: opencv_calib3dXXX.dll, opencv_contribXXX.dll, opencv_coreXXX.dll, opencv_features2dXXX.dll, opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll, opencv_mlXXX.dll, opencv_objectdetectXXX.dll, opencv_videoXXX.dll where XXX is the OpenCV version number.

For Emgu CV version <= 2.1, this means the following dlls:cvXXX.dll, cvauxXXX.dll, cxcoreXXX.dll, highguiXXX.dll, opencv_ffmpegXXX.dll, mlXXX.dllcvextern.dll where XXX is the OpenCV version number.

The best way to set up your project is:

Copy the unmanaged DLLs to your project folder

Right click on the project, click Add->Existing Item and select all unmanaged DLLs. Add them to the project.

For each of the included Dlls, left click on it, find the "Copy to Output Directory" option and select "Copy if newer"

Are you missing any dependency?

Download Dependency Walker and use it to open the "cvextern.dll" file. Check if any dependency is missing.

Configuring the project

32-Bit Windows

Run Build_Binary_x86_nocuda.bat script located in the platforms\windows folder of GIT.

64-Bit Windows

Run Build_Binary_x86-64_doc.bat script located in the platforms\windows folder of GIT.

Building the unmanaged code

Double check if the emgucv.sln file exists in the root folder, if not, run the above step again.
Open emgucv.sln solution located in the root folder with the matching version of Visual Studio, switch the configuration to "Release" and build the cvextern project.

Building the managed code

Browse to the "Solution\VS2013-2015" Folder

Open Emgu.CV.sln and build the solution.

At this point, the Emgu CV dlls should be available under the bin folder in the top most directory.

Raspbian (Raspberry Pi 2)

We will build a custom version of OpenCV in the next step. It is recommended to remove any OpenCV package if it is installed on your machine.

CMake

Emgu CV has adapted to use cmake to compile its source code (as well as OpenCV).

Installing GIT so you can check out the project folder, you can install GIT by running

sudo apt-get install git

Getting the source code

To build from source, you will need a Git client to check out the source code from SourceForge. For more information, see GIT. The following command can be used to check out the source:

git clone git://git.code.sf.net/p/emgucv/code emgucv

Go to emgucv directory

cd emgucv

Skip this step if you are using Fedora or Raspbian, you can use the latest master development branch. You need to check out an old stable branch of emgucv only if you are using Ubuntu, you can check out 2.4.9 instead of the master development code. the latest development code has issues compiling on Ubuntu and will result in a crash when the opencv_calib3d module is being loaded. On Ubuntu, run the following command

git checkout 2.4.9

Initialize opencv, tesseract-ocr and cvblob submodules

git submodule update --init --recursive

Configuring the project

Fedora

Got to the configuration folder

cd platforms/fedora/20

Installing the perquisites

This only needs to be run once. You can install the prerequisites by running

./install_dependency

Use the following command to configure the project:

./cmake_configure

Go back to the source code root folder

cd ../../..

Raspbian (Raspberry Pi 2)

Got to the configuration folder

cd platforms/raspbian

Installing the perquisites

This only needs to be run once. You can install the prerequisites by running

./apt_install_dependency

Use the following command to configure the project:

./cmake_configure

Go back to the source code root folder

cd ../..

Ubuntu

Installing the prerequisites

This only needs to be run once. You can install the prerequisites by running

Sit back and wait as this will build OpenCV, as well as cvextern.so, Emgu.Util.dll, Emgu.CV.dll, Emgu.CV.UI.dll and Emgu.CV.ML.dll

Now go to the bin folder

cd bin

Try to run the example

mono Example.PlanarSubdivision.monoexe

You should see the planar subdivision window. Note that the first time a mono program is executed, it may take a considerable time to start, some times as long as one minute. Any consecutive execution should be fast.