Download And Installation
Windows
Nuget
Using nuget package manager is probably the easiest way to include Emgu CV library in your project.
Open Source Release
- From your project, right click on "References" and select "Manager Nuget Packages..." option. It will open up nuget package manager. In package source, make sure that "nuget.org" is selected. (If you are using the commercial release, please check the instruction in the commercial download area for instructions to setup the commercial release nuget repository.)
- Under "Browse", enter the search text "emgu.cv.runtime" and you should be able to find the Emgu.CV.runtime.windows nuget package.
Please make sure the package is created by "Emgu Corporation" for the official release.
- Click the "Install" button. Nuget will download Emgu.CV.runtime.windows and configure the project for you.
Commercial Release
- If you are using the commercial release, please check the instruction in the commercial download area for instructions to setup the commercial release nuget repository. Commercial release download link can be found in the "Download Instructions" at the bottom of your purchase complete page. It is also available on the product delivery email, under the "CUSTOMER SERVICE" session. Please click on the link below "Your Order Data" to access the Commercial release download area.
- If you have the Professional / Ultimate license. The instruction can be found at the bottom of the page once you clicked into the "windows" folder.
- If you have the Windows only license. The instructions can be found at the bottom of the page as soon as you logged in.
- Once the commercial nuget repository is setup, you should be able to find two packages: Emgu.CV.runtime.windows.dldt is the commercial release runtime without CUDA; Emgu.CV.runtime.windows.cuda.dldt is the commercial release runtime with CUDA support.
- Click the "Install" button. Nuget will download Emgu CV commercial release and configure the project for you.
Using the Downloadable packages
If you are using the downloadable packages (.zip or .exe), you can follow the instructions below.
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.
- For version 2.4.x the bundled OpenCV binary is build with Visual Studio 2010, you will needs to installed MSVCRT 9.0 SP1 x86 or MSVCRT 9.0 SP1 x64 to resolve the dependency issue.
- For Version 2.0 - 2.3, the bundled OpenCV binary is build with Visual Studio 2008, you will needs to installed MSVCRT 9.0 SP1 to resolve the dependency issue.
- For Version 1.5, the bundled OpenCV pre1.1 binary is build with Visual Studio 2005, you will needs to installed MSVCRT 8.0 SP1 to resolve the dependency issue.
Building the Examples
- Follow this link to the file server on Source Forge.
- Download and extract the windows installer.
- Install the software
- Go to the "Solution\Windows.Desktop" folder.
- Open
Emgu.CV.Example.sln
and build the solution. At this point, you should be able to run the example programs.
Creating a New Project in Visual Studio
To use the framework in Visual Studio, you need to
- Download and extract the binary files package Emgu.CV.Windows.Binary-{version}.zip
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 reference
- For 4.4 release. Add the
Emgu.CV.Platform.NetStandard.dll
to Reference. AddEmgu.CV.Runtime\Windows\Emgu.CV.Runtime.Windows
shared project to include the native dlls into your project. - For 4.2 release. Add the
Emgu.CV.World.NetStandard.dll
to Reference. AddEmgu.CV.Runtime\Windows\Emgu.CV.Runtime.Windows
shared project to include the native dlls into your project. - For 3.1 release. Add the
Emgu.CV.World.dll
to Reference of the project. - For 3.0 release. Add the two files
Emgu.Utils.dll
andEmgu.CV.dll
to References of the project.
- For 4.4 release. Add the
- 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
- For Emgu CV 4.2 and above, adding
Emgu.CV.Runtime\Windows\Emgu.CV.Runtime.Windows
shared project to your project will take care of deploying all the native files. - For older releases, copy the "x86" and "x64" folder, along with the DLLs inside those folder to the folder of the executable. Emgu CV 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. If you are only targeting the "x64" platform, you only need to copy the "x64" folder.
CUDA (GPU) package
- For Emgu CV 4.2 and above, adding
Emgu.CV.Runtime\Windows\Emgu.CV.Runtime.Windows
shared project to your project will take care of deploying all the native files. - For Emgu CV 3.x+, only package containing -cuda in its name (e.g.
libemgucv-xxx-cuda-xxx
) has CUDA processing enabled.- Install the latest cuda graphic card driver from NVIDIA on your development workstation.
- Adding reference: For 3.1 release. You don't need to add extra references. The Cuda namespace is part of the Emgu.CV.World.dll; For 3.0 release. Add
Emgu.CV.Cuda.dll
to References - Optionally put the following lines in the top of your code to include the Emgu.CV.Cuda namespace.
using Emgu.CV.Cuda;
- For Emgu CV 2.x, CUDA (GPU) for image processing is only available for Emgu CV rev 2.2.1 and later. Only package containing -gpu in its name (e.g.
libemgucv-xxx-gpu-xxx
) has CUDA (GPU) processing enabled.- Install the latest cuda graphic card driver from NVIDIA on your development workstation.
- Add
Emgu.CV.GPU.dll
to References - Optionally put the following lines in the top of your code to include the Emgu.CV.GPU namespace.
using Emgu.CV.GPU;
GUI
To display image using Emgu's ImageBox
- Add
Emgu.CV.UI.dll
to References - Optionally put the following lines in the top of your code to include the Emgu.CV.UI namespace.
using Emgu.CV.UI;
Machine Learning
- Adding reference
- For 3.1 release. You don't need to add extra reference.
- For release up to and including 3.0 release, add
Emgu.CV.ML.dll
to References
- Optionally put the following lines in the top of your code to include the Emgu.CV.ML namespace.
using Emgu.CV.ML;
Start Developing
- Follow the Tutorial to learn how to use Emgu CV.
- Hello World (C# or VB .NET) is a good starting point.
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 Version 2.4+, the bundled OpenCV binary is build with Visual Studio 2010, you will needs to installed 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 build with Visual Studio 2008, you will needs to installed MSVCRT 9.0 SP1 to resolve the dependency issue.
- For Version 1.5, the bundled OpenCV pre1.1 binary is build with Visual Studio 2005, you will needs to installed MSVCRT 8.0 SP1 to resolve the dependency issue.
Have you copied the OpenCV dlls to the execution directory?
- Make sure the unmanaged DLLs are in the execution directory.
- For Emgu CV version >=2.4.2, this means the "x86" and "x64" folder and all the dlls within the folders. The folder names and file structures should not be altered when deploying with the application.
- For EMGU CV version 2.4
cudart64_42_9.dll, cvextern.dll, npp64_42_9.dll, opencv_calib3dXXX.dll, opencv_contribXXX.dll, opencv_coreXXX.dll, opencv_features2dXXX.dll, opencv_flannXXX.dll, opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll, opencv_mlXXX.dll, opencv_nonfreXXX.dll, opencv_objectdetectXXX.dll, opencv_videoXXX.dll,</code?> where
XXX
is the OpenCV version number. - 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
whereXXX
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
whereXXX
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.
I have checked all of above but I still got the Exception
In this case, please try to build and run the examples. After building the examples, try to run the "Hello World" Program.
If "Hello World" runs without any problem, compare it with you project, find the difference in configuration and fix it.
If "Hello World" get the same "The type initializer for 'Emgu.CV.CvInvoke' threw an exception." message, try to find out the InnerException and report it to the discussion forum
Building from Git
If you wants to build the development version of Emgu CV from source code, you can to get it from GIT following instructions on This page.
Prerequisite
- You will need to install CMAKE in-order to build the unmanaged C++ code (OpenCV and cvextern.dll).
- You will need Visual Studio 2017/ Visual Studio 2015 to build the Managed code (Emgu CV)
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\Windows.Desktop" 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.
Linux
Getting ready
Ubuntu 20.04
- dotnet SDK
- For 4.5.1 release, you will need dotnet SDK 5.0. Please follow this instruction to install asp .net core on Ubuntu. Once that is done, run the following command to verify dotnet is installed:
ubuntu:~$ dotnet --list-runtimes
It should show a message similar to the following Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
- OpenCV
- 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
Raspberry Pi OS
- dotnet SDK
- For 4.5.1 release, you will need dotnet SDK 5.0
- OpenCV
- 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 https://github.com/emgucv/emgucv emgucv
- Go to emgucv directory
cd emgucv
- Initialize opencv, tesseract-ocr and cvblob submodules
git submodule update --init --recursive
Configuring & Building the project
Ubuntu 20.04
- Got to the configuration folder.
cd platforms/ubuntu/20.04
- Installing the prerequisites. This only needs to be run once. You can install them by running
./apt_install_dependency
- Use the following command to configure and build the project:
./cmake_configure
- If you want to re-configure the modules you need. Call
ccmake build
You can enable / disable modules as you need. e.g. If you do not want Emgu CV to build with tesseract. Set EMGU_CV_WITH_TESSERACT
to OFF
. Once all flags are set, press c
to re-configure. Press q
to quite cmake. Rebuild the project with cd build; make; cd ..
Raspberry Pi OS
- 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 and build the project:
./cmake_configure
- If you want to re-configure the modules you need. Call
ccmake build
You can enable / disable modules as you need. e.g. If you do not want Emgu CV to build with tesseract. Set EMGU_CV_WITH_TESSERACT
to OFF
. Once all flags are set, press c
to re-configure. Press q
to quite cmake. Rebuild the project with cd build; make; cd ..
Running the Examples
- We have the native binary compiled. Now let's compile and run our first dot net core program.
cd Emgu.CV.Example\BuildInfo.NetCore.Console
- make sure dotnet can load the dynamic library from the current location by typing
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
- Try to compile and run the program
dotnet run
System.DllNotFoundException
If you encounter this exception, there might be missing dependencies. In this case, go to libs\x64
folder (or libs\arm
folder, or libs\x86
folder, depends on your system architecture). Run this command
ldd libcvextern.so
and check if there is any dependency missing.
If not, go back to Emgu.CV.Example/BuildInfo.NetCore.Console
folder and run this command
gdb dotnet
then, on the (gdb) commandline, type
run run
to debug with GDB.
You can also try
LD_DEBUG=libs dotnet run
to find missing dependencies.
Mac OS
Emgu CV for Mac OS is available under our commercial license. The instructions below applies to the Emgu CV for Mac OS, Professional or Ultimate commercial release.
Adding Emgu CV to your Xamarin Mac App
You can either add Emgu CV to your project by directly adding the binary files, or by adding two projects.
Using binary files
The "libs" folder of the Mac OS (or Pro) release package should contains the files
Emgu.CV.Platform.NetStandard.dll
osx/libcvextern.dylib
Please add Emgu.CV.Platform.NetStandard.dll as a reference to your Xamarin Mac App. Deploy "libcvextern.dylib" file to the folder of executable. Then you are ready to use Emgu CV in your Mac OS App.
If the files "Emgu.CV.Platform.NetStandard.dll" does not exist, you can compile the visual studio solution under "Solution\Mac\Emgu.CV.Mac.Example.sln" to build the dlls.
Using project files
Instead of using the binary files as mention above. You can also add this two projects as references into your existing project:
For v4.4.0
- Emgu.CV.Platform\Netstandard\Emgu.CV.Platform.Netstandard.csproj
- Emgu.CV.Runtime\Mac\Emgu.CV.Runtime.Mac.shproj
Demos
The demo solution is available under the "Solution\Mac" folder.
iOS
Emgu CV for iOS is only available under our commercial license. The instructions below applies to the Emgu CV for iOS, Professional or Ultimate commercial release.
Adding Emgu CV to your Xamarin iOS App
The iOS (or Pro) release package should contains the following two files:
libs\iOS\Emgu.CV.Platform.NetStandard.dll
libs\Emgu.CV.Platform.IOS.dll
Adding this two dll files as a reference to your Xamarin iOS App should allow you to use Emgu CV in your App.
For 4.5.1 and later release, after adding the references. You should call
CvInvokeIOS.Init()
in the main ios app, to make sure the native binary is included in the compilation. Otherwise you may see a long list of missing native reference errors during compilation.
Size of the binary
The "Emgu.CV.Platform.IOS.dll" file size is large. For example, in the 4.4.0 iOS release, this file is 724MB. It contains the native binary for all supported CPU architectures, including those for simulators.
However, if you are building an IPA for app store submission, and is only targeting ARM64 devices, you can select just ARM64 architecture. When the IPA is build, the compiler will strip out all the binary that are not used. It will significantly reduce the final size of the IPA. Depends on the number of functions you used, if you are only targeting a single ARM64 architecture, the final IPA size should be some where around 40MB.
Demos
The demo solution is available under the "Solution\iOS" folder.
Android
Emgu CV for Android is only available under our commercial license. The instructions below applies to the Emgu CV for Android, Professional or Ultimate commercial release.
Adding Emgu CV to your Xamarin Android App
The "libs" folder of the Android (or Pro) release package should contains these two files
Emgu.CV.Platform.NetStandard.dll
Emgu.CV.Platform.Android.dll
Adding the above files as references to your Xamarin Android App should allow you to use Emgu CV in your App.
If the files does not exist, you can compile the visual studio solution under "Solution\Android\Emgu.CV.Android.sln" to build the dlls.
For 4.5.1 and later release, after adding the references. You should call
CvInvokeAndroid.Init()
in the main android app, to make sure the native binary is included in the compilation. Otherwise you may see PInvoke exception when you call an Emgu CV function on Android.
Size of the binary
The "Emgu.CV.Platform.Android.dll" file size is large. For example, in the 4.4.0 Android release, this file is 67MB. It contains the native binary for all supported CPU architectures.
However, if you are building an app for Google Play Store submission, and is only targeting armeabi-v7 devices, you can select just armeabi-v7 architecture. When the final APK is build, the compiler will strip out all the binary for the architectures that are not used. It will significantly reduce the final size of the APK. Depends on the number of functions you used, if you are only targeting a single armeabi-v7 architecture, the final APK size should be some where around 20-30MB.
Demos
The demo solution is available under the "Solution\Android" folder.