Tutorial: Difference between revisions

From EMGU
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==Namespace==
== Wrapping OpenCV ==


===Emgu===
===Function Mapping - Emgu.CV.CvInvoke ===
All libraries implemented by Emgu® belongs to the namespace of Emgu.
 
===Emgu.CV===
The Emgu.CV namespace implement wrapper functions for [[OpenCV]]. To use this namespace in your code, it is recommended to include
<source lang="csharp">
using Emgu.CV;
using Emgu.CV.Structure;
</source>
in the beginning of your C# code.
 
====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  
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  
<source lang="csharp">  
<source lang="csharp">  
Line 22: Line 11:
Both of which create a 400x300 of 8-bit unsigned grayscale image.
Both of which create a 400x300 of 8-bit unsigned grayscale image.


====Enumeration Mapping - Emgu.CV.CvEnum ====
===Structure Mapping - Emgu.CV.Structure.M''xxx'' ===
The CvEnum namespace provides direct mapping to [[OpenCV]] enumerations. For example, <code> CvEnum.IPL_DEPTH.IPL_DEPTH_8U </code> has the same value as <code> IPL_DEPTH_8U </code> in [[OpenCV]]; both of which equals <code>8</code>.
 
====Structure Mapping - Emgu.CV.Structure.M''xxx'' ====
This type of structure is a direct mapping to [[OpenCV]] structures.
This type of structure is a direct mapping to [[OpenCV]] structures.
{| style="text-align:center" border="1px" cellspacing="0" cellpadding="5"
{| style="text-align:center" border="1px" cellspacing="0" cellpadding="5"
Line 55: Line 41:
|}
|}


==How to use [[Emgu CV]] (Image, Matrix ...)==
===Enumeration Mapping - Emgu.CV.CvEnum ===
 
The CvEnum namespace provides direct mapping to [[OpenCV]] enumerations. For example, <code> CvEnum.IPL_DEPTH.IPL_DEPTH_8U </code> has the same value as <code> IPL_DEPTH_8U </code> in [[OpenCV]]; both of which equals <code>8</code>.
[[Working with Images]]


[[Working with Matrices]]
==Managed classes==
===[[Working with Images]]===
===[[Working with Matrices]]===


==Error Handling==
==Error Handling==

Revision as of 14:15, 27 May 2009

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

Both of which create a 400x300 of 8-bit unsigned grayscale image.

Structure Mapping - Emgu.CV.Structure.Mxxx

This type of structure is a direct mapping to OpenCV structures.

Emgu CV Structure OpenCV structure
Emgu.CV.Structure.MIplImage IplImage
Emgu.CV.Structure.MCvMat CvMat
... ...
Emgu.CV.Structure.Mxxxx xxxx

The prefix M here stands for Managed structure.

Emgu CV also borrows some existing structures in .Net to represent structures in OpenCV:

.Net Structure OpenCV structure
System.Drawing.Point CvPoint
System.Drawing.PointF CvPoint2D32f
System.Drawing.Size CvSize
System.Drawing.Rectangle CvRect

Enumeration Mapping - Emgu.CV.CvEnum

The CvEnum namespace provides direct mapping to OpenCV enumerations. For example, CvEnum.IPL_DEPTH.IPL_DEPTH_8U has the same value as IPL_DEPTH_8U in OpenCV; both of which equals 8.

Managed classes

Working with Images

Working with Matrices

Error Handling

Emgu CV register a custom error handler in OpenCV. When error is encountered from OpenCV, a CvException will be thrown.

Code Documentation

Xml Documentation

Documentation is embedded in the code using xml format, which can then be compiled as HTML documentation using Sandcastle. You can browse our Online Documentation for the latest stable and development code.

Intellisense in Visual Studio

If you are using Visual Studio as your development tools, you will have intellisense support when developing Emgu CV applications. For example, if you wants to create an image directly using cvCreateImage function, which is wrapped by the CvInvoke Class, just type CvInvoke.

and a list of functions belongs to CvInvoke class is displayed along with a description for each of the function. Since you are creating an image, select the cvCreateImage function

The list of parameters for this function will be displayed as well as a description for each of the parameters.

Examples

C#

Image Processing Examples

Machine Learning Examples

C++

IronPython

VB.NET