UB CS550 2012
EMGU CV Tutorial
Agenda
• Part I : Overview of Emgu CV
• Part II: Setup the required tools
• Part III: Run the Samples
• Part IV: Show image from a camera stream or video
• Part V: Optional Convert the previous Open CV tutorial to Emgu CV.
Part I
Description
Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library. Allowing OpenCV functions to be
called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled in Mono
and run on Windows, Linux, Mac OS X, iPhone, iPad and Android devices.
Overview of Emgu CV Versions:
Advantage of Emgu CV
Cross Platform
Emgu CV is written entirely in C#. The benefit is that it can be compiled in Mono and therefore is able to run
on any platform Mono supports, including Linux, Mac OS X, iOS and Android.
Cross Language and comes with example code
Emgu CV can be used from several different languages, including C#, VB.NET, C++ and IronPython.
Other Advantages
•
Image class with Generic Color and Depth
•
Automatic garbage collection
•
XML Serializable Image
•
XML Documentation and intellisense support
•
The choice to either use the Image class or direct invoke functions from OpenCV
Although it is possible to create image by calling
CvInvoke.cvCreateImage
, it is suggested to construct
a Image<TColor, TDepth> object instead. There are several advantages using the managed
Image<TColor, TDepth> class
Memory is automatically released by the garbage collector
Image<TColor, TDepth> class can be examined by Debugger Visualizer
Image<TColor, TDepth> class contains advanced method that is not available on OpenCV, for example,
generic operation on image pixels, conversion to Bitmap etc.
•
Generic operations on image pixels
Architecture Overview
Emgu CV has two layers of wrapper as shown below
•
The basic layer (layer 1) contains function, structure and enumeration mappings which directly reflect those in
OpenCV.
•
The second layer (layer 2) contains classes that mix in advantanges from the .NET world.
Wrapping OpenCV
Function Mapping - Emgu.CV.CvInvoke
The CvInvoke class provides a way to directly invoke OpenCV function within .NET languages. Each method
in this class corresponds to a function in OpenCV of the same name. For example, a call to
IntPtr image = CvInvoke.cvCreateImage(new System.Drawing.Size(400, 300),
CvEnum.IPL_DEPTH.IPL_DEPTH_8U, 1);
is equivalent to the following function call in C
IplImage* image = cvCreateImage(cvSize(400, 300), IPL_DEPTH_8U, 1);