Sie sind auf Seite 1von 11

c  


 

  
   

1.1 Getting the Dependency

1.2 Building the Examples

1.3 Creating a New Project in Visual Studio

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

1.4.1 Have you installed MSVCRT?

1.4.2 Have you copied the OpenCV dlls to the execution directory?

1.4.3 Are you running a 32-Bit OS?

1.4.4 Are you missing any dependency?

1.4.5 I have checked all of above but I still got the Exception

1.5 Building from SVN

1.5.1 Prerequisite

1.5.2 Building the unmanaged code

1.5.2.1 32-Bit Windows

1.5.2.2 64-Bit Windows

1.5.3 Building the managed code

 

2.1 Getting the Dependency

2.1.1 Fedora 12

2.1.2 Ubuntu 9.10


2.2 Building from Source

2.3 System.DllNotFoundException

2.4 Building Installable Package

2.4.1 RPM Package for Fedora 12

2.4.2 Debian Package for Ubuntu 9.10

   

`     


·p Emgu CV use WCF(Windows Communication Foundation) therefore


requires .Net 3.0
·p 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.
·p 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.

    

·p Follow this link to the file server on Source Forge.


·p Download and extract the windows installer.
·p Install the software
·p Go to the Solution folder
·p If you are using Visual Studio 2005, browse to VS2005_MonoDevelop
·p If you are using Visual Studio 2008, browse to VS2008
·p Open Emgu.CV.Example.sln and build the solution. At this point, you should
be able to run the example programs.


à   
   

ð 
        

·p Download and extract the binary files package Emgu.CV.Windows.Binary-
{version}.zip (They are compiled from source on Windows using MsBuild)
·p Create a new Visual Studio project or use an existing one
·p Add the 3 files zlib.net.dll, Emgu.Utils.dll and Emgu.CV.dll to References of
the project. If you needs to use the Machine Learning library, include
Emgu.CV.ML.dll to References as well.
·p Copy the OpenCV dll files: cvXXX.dll, cvauxXXX.dll, cxcoreXXX.dll,
highguiXXX.dll, opencv_ffmpegXXX.dll, mlXXX.dll and cvextern.dll to the
execution directory, where XXX is the OpenCV version number.
·p Optionally put the following lines in the top of your code to include the
Emgu.CV namespace.

·p using Emgu.CV;
·p using Emgu.CV.Structure;

V        


     
 

using Emgu.CV.ML;

Follow the Tutorial to learn how to use Emgu CV. The "Hello, World" Example is a
good starting point.

ð        àà   





If you see this exception, please check the following

K    àð 

·p 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.
·p 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.

K   
   à   
 
 

·p Make sure the unmanaged DLLs are in the execution directory.


·p 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.
·p 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.

ð     

·p Copy the unmanaged DLLs to your project folder


·p Right click on the project, click Add->Existing Item and select all unmanaged
DLLs. Add them to the project.
·p For each of the included Dlls, left click on it, find the "Copy to Output
Directory" option and select "Copy if newer"

?    
 

·p 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:
·p Uou can download the 64bit binary only zip package from sourceforge and
add it to your project.
·p Uou can also recompile OpenCV from source for 64-bit platform. See the
instruction for building from SVN
·p 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'.

?       


         !" "#  


 
 "

 

       


·p In this case, please try to build and run the examples. After building the
examples, try to run the "Hello World" Program.

·p If "Hello World" runs without any problem, compare it with you project,
find the difference in configuration and fix it.

·p 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

  

·p 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.
  

·p Uou will need to install CMAKE in-order to build the unmanaged C++ code
(OpenCV and cvextern.dll).
·p Uou will need either Visual Studio 2010 / Visual Studio 2008 / Visual Studio
2005 to build the Managed code (Emgu CV)

    
 


! 

v$ %$  %!&'"        ("

È 
! 

v$ %$  %!&')'*"        (.

   
 

·p Browse to the Solution Folder


·p If you are using Visual Studio 2005, browse to VS2005_MonoDevelop
·p If you are using Visual Studio 2008, browse to VS2008
·p Open Emgu.CV.sln and build the solution.

?  +


#       

  "

" 

`     

Ö  #
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. Uou should remove
OpenCV by running as root

yum remove opencv

Mono

Uou will need Mono >= 2.2. Mono 2.4 is recommended.

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

Uou 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-devel libtiff-devel gtk2-devel

$  %#&

Mono

Uou will need Mono >= 2.2. Mono 2.4 is recommended.

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

Uou can install the prerequisites by running

sudo apt-get install build-essential monodevelop libmono-wcf3.0-cil libtiff4-dev


libgtk2.0-dev cmake svn

  


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_PUTHON_SUPPORT:BOOL=FALSE -
DBUILD_TESTS:BOOL=FALSE .

This will generate make file for Emgu CV

Build Emgu CV by calling

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_LIBRARU_PATH=.:$LD_LIBRARU_PATH

Try to run the example

mono Example.PlanarSubdivision.monoexe

Uou should see the planar subdivision window

Follow the instruction on Compiling with Monodevelop, as the environment has


been setup by cmake

   Ö  


If you encounter this exception during

mono Example.PlanarSubdivision.monoexe

Uour 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


  Ö  #
Make sure the dependency is satisfied.

Make sure that cmake >= 2.8.1 is installed. Uou 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_PUTHON_SUPPORT:BOOL=FALSE -
DEMGU_CV_EXAMPLE_BUILD:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE .

Create a rpm package by running as root

make package

Uou 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)

 
  $  %#&

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_PUTHON_SUPPORT:BOOL=FALSE -
DEMGU_CV_EXAMPLE_BUILD:BOOL=FALSE -DBUILD_TESTS:BOOL=FALSE .

Create a debian package with

sudo make package


Uou should get a libemgucv-{VERSION}.{SUBVERSION}-{arch}.deb file which
includes

OpenCV library and documentations

Emgu CV library and its dependencies (including ZedGraph and zlib.net)