Difference between revisions of "Download And Installation"

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to navigation Jump to search
(→‎Windows: Added a link to a site with a heavily automated EmguCV installer)
Line 165: Line 165:
  
 
*Use cmake to generate make file
 
*Use cmake to generate make file
<pre>cmake -DBUILD_NEW_PYTHON_SUPPORT:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE -DBUILD_DOXYGEN_DOCS:BOOL=FALSE -DWITH_TBB:BOOL=TRUE .</pre>
+
<pre>cmake -DBUILD_NEW_PYTHON_SUPPORT:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE -DBUILD_DOCS:BOOL=FALSE -DWITH_TBB:BOOL=TRUE .</pre>
  
 
This will generate make file for [[Emgu CV]]
 
This will generate make file for [[Emgu CV]]

Revision as of 02:53, 10 August 2011

Windows

You can run an AutoIt script that automates much of the process, including installing OpenCV if necessary, and lets you start developing with Visual Studio right away.

Getting the Dependency

  • Emgu CV use WCF(Windows Communication Foundation) therefore requires .Net 3.0
  • For Version 2.0+, the bundled OpenCV 2.0 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 folder
    • If you are using Visual Studio 2005, browse to VS2005_MonoDevelop
    • If you are using Visual Studio 2008, browse to VS2008
    • If you are using Visual Studio 2010, browse to VS2010
  • 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

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

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.

GPU package

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 GPU processing enabled.

  • Install the latest cuda graphic card driver from NVIDIA on your running platform.
  • Copy the cuda and npp dll files: cudart{bit}_{maj_rev}_{min_rev}.dll and npp{bit}_{maj_rev}_{min_rev}.dll to the execution directory
  • 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;

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.

  • If you are using the Zip package, you need to install the intel C++ runtime. The installer is w_ccompxe_redist_ia32_2011.1.127.exe for 32bit Windows and w_ccompxe_redist_intel64_2011.1.127.exe for 64bit Windows. If you use the windows installer, it automatically install the correct version for your computer.
  • Copy the IPP dll files ipp*.dll to the execution directory
  • Copy the TBB dll file tbb.dll to the execution directory

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

  • 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 2.0+, the bundled OpenCV 2.0 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.1, this means the following dlls: cvXXX.dll, cvauxXXX.dll, cxcoreXXX.dll, highguiXXX.dll, opencv_ffmpegXXX.dll, mlXXX.dll and cvextern.dll where XXX is the OpenCV version number.
    • For Emgu CV version >= 2.2 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.
  • 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 running a 32-Bit OS?

The windows installer is only available for 32-Bit windows. If you are using a 64-bit OS, there are three possible ways to resolve this issue:

  • You can download the 64bit binary only zip package from sourceforge and add it to your project.
  • You can also recompile OpenCV from source for 64-bit platform. See the instruction for building from SVN
  • Alternatively you can force your .NET application to run in 32bit mode, even on a 64-bit OS. To do this, in the configuration page of your executable project, select Platform Target as 'x86'.

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 SVN

If you wants to build the development version of Emgu CV from source code, you can to get it from SVN 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 either Visual Studio 2010 / Visual Studio 2008 / Visual Studio 2005 to build the Managed code (Emgu CV)
Kinect On Windows

If you wants to build Emgu CV with OpenNI to enable Kinect support on windows. Here is the steps:

  • First you will need to install the Kinect driver for Windows. The official OpenNI driver will not work. PrimeSense does not officially release Kinect driver on Windows and have no plan to do so in the near feature. Here is the modified SensorKinect diver that is available from GitHub: https://github.com/avin2/SensorKinect.git You need a Git client such as TortoiseGit to check out the source code. Once the code is checked out, plug in your Kinect sensor. When you are asked for driver installation, maunally pick the driver from the SensorKinect\Platform\Win32\Driver folder you checked out. If everything go as planned, you should see the Kinect Hardware shown as follows:

KinectDriverScreenCapture.png

  • Do not proceed to the next step unless you got the driver setup correctly.
  • Download and install OpenNI
  • Check out Emgu CV from svn.
  • Configure the project manually using CMake. First open CMake GUI, set the source code and build folder to the root of the Emgu CV folder. Check the box "WITH_OPENNI", click "Configure". Then enter the location for "OPENNI_INCLUDE_DIR", "OPENNI_LIB_DIR" and "OPENNI_PRIME_SENSOR_MODULE_BIN_DIR", click "Configure" and "Generate".
  • Now you should have a Visual Studio solution to build Emgu CV with Kinect.

Building the unmanaged code

32-Bit Windows

Run Build_Binary_x86.bat script located in the trunk folder of SVN.

64-Bit Windows

Run Build_Binary_x86-64.bat script located in the trunk folder of SVN.

Building the managed code

  • Browse to the Solution Folder
    • If you are using Visual Studio 2005, browse to VS2005_MonoDevelop
    • If you are using Visual Studio 2008, browse to VS2008
  • Open Emgu.CV.sln and build the solution.

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

Linux

Getting the Dependency

Fedora 14

  • 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. You should remove OpenCV by running as root
       yum remove opencv 
  • Mono
    • You will need Mono >= 2.4.
    • Emgu CV library use WCF (Windows Communication Foundation) and therefore also requires mono-wcf.
  • CMake

Emgu CV has adapted to use cmake to compile all it source code (as well as OpenCV). Make sure you have cmake installed.

  • Installing the dependencies

You can install the dependencies by running as root

 yum install mono-core mono-extras mono-devel mono-wcf gcc-c++ cmake svn libpng-devel libjpeg-turbo-devel jasper-devel libtiff-devel libgeotiff-devel gtk2-devel OpenEXR-devel libv4l-devel eigen2-devel libdc1394-devel qt-devel tbb-devel tesseract-devel

Ubuntu 10.10

  • Mono
    • You will need Mono >= 2.6
    • Emgu CV library use WCF (Windows Communication Foundation) and therefore also requires libmono-wcf3.0-cil.
  • 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 all it source code (as well as OpenCV).

  • Installing the prerequisites

You can install the prerequisites by running

sudo apt-get install build-essential monodevelop libmono-wcf3.0-cil libtiff4-dev libgeotiff-dev libgtk2.0-dev libgstreamer0.10-dev libavcodec-dev libswscale-dev libavformat-dev libopenexr-dev libjasper-dev libdc1394-22-dev libv4l-dev libqt4-opengl-dev libeigen2-dev libtbb-dev cmake-curses-gui subversion

Building from Source

  • To build from source, you will need a SVN client to check out the source code from SourceForge. For more information, see SVN. The following command can be used to check out the source:
svn co https://emgucv.svn.sourceforge.net/svnroot/emgucv/trunk emgucv 
  • Go to emgucv directory
cd emgucv
  • Use cmake to generate make file
cmake -DBUILD_NEW_PYTHON_SUPPORT:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE -DBUILD_DOCS:BOOL=FALSE -DWITH_TBB:BOOL=TRUE .

This will generate make file for Emgu CV

make

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
  • make sure mono can load the dynamic library from the current location by typing
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
  • Try to run the example
mono Example.PlanarSubdivision.monoexe

You should see the planar subdivision window

System.DllNotFoundException

If you encounter this exception during

mono Example.PlanarSubdivision.monoexe

Your OpenCV build might be incomplete (e.g. GTK+ 2.x devel library is missing). To trace the cause of the error, run

MONO_LOG_LEVEL=debug mono Example.PlanarSubdivision.monoexe

and exam the error message.

Building Installable Package

RPM Package for Fedora 14

  • Make sure the dependency is satisfied.
  • Make sure that cmake >= 2.8.1 is installed. You can do this by running as root
    yum --enablerepo=rawhide install cmake
  • Check out the source from SVN and go the the emgucv source folder
  • Configure the package with
    cmake -DBUILD_NEW_PYTHON_SUPPORT:BOOL=FALSE -DEMGU_CV_EXAMPLE_BUILD:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE -DBUILD_DOXYGEN_DOCS:BOOL=FALSE .
  • Create a rpm package by running as root
    make package
  • You should get a libemgucv-{VERSION}.{SUBVERSION}-{arch}.rpm file which includes
    • OpenCV library and documentations
    • Emgu CV library and its dependencies (including ZedGraph and zlib.net)

Debian Package for Ubuntu 10.10

  • Make sure the dependency is satisfied.
  • Check out the source from SVN and go the the emgucv source folder
  • Configure the package with
    cmake -DBUILD_NEW_PYTHON_SUPPORT:BOOL=FALSE -DEMGU_CV_EXAMPLE_BUILD:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE -DBUILD_DOXYGEN_DOCS:BOOL=FALSE .
  • Create a debian package with
    sudo make package
  • You should get a libemgucv-{VERSION}.{SUBVERSION}-{arch}.deb file which includes
    • OpenCV library and documentations
    • Emgu CV library and its dependencies (including ZedGraph)