Emgu CV-Basic Knowledge

Source: Internet
Author: User
Tags image processing library

First of all, due to recent needs, you need to learn about emgu cv. As the things to be done are just some simple things, I 'd like to take a look at the basic knowledge here and learn from you.

 

Relationship between emgu CV and opencv

   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

Emgu CV is in.. Net Library, mainly. use C #, VB, and VC ++ to call opencv. this encapsulated library can run on Windows, Linux, Mac OSX, iphoe, iPad, and Android after mono compilation.

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 inadvantanges from the. NET world.

Emgu CV has two layers of encapsulation:

1. The first layer is the basic layer, which directly corresponds to opencv, including functions, structures, and enumeration types.

2. The second layer is the expansion layer, including some mixed classes with. Net libraries, which is suitable for. net advantages.

The figure below shows the basic architecture of emgu cv. We used the following library files during the previous configuration process. here we can see their specific functions and architecture.

Emgu. util is a template library. It is a base class. (This is incorrect description. Due to my limited personal ability, I only want to describe my opinion. I hope you can criticize and correct it.) Below is emgu cv, that is, the implementation of two-layer architecture

The following describes the relationship between emgu CV and opencv.

 

 

Some basic structures in emgu CV

2. 1. Hello word

Code:

Using system; using system. collections. generic; using system. LINQ; using system. text; // using emgu. CV; using emgu. CV. cvenum; using emgu. CV. structure; using emgu. CV. ui; using system. drawing; using system. windows. forms; namespace hello_word {class program {static void main (string [] ARGs) {// window name string win1 = "test window"; // create a window cvinvoke. cvnamedwindow (win1); // create a 400*200 Blue Image Using (image <BGR, byte> IMG = new image <BGR, byte> (400,200, new BGR (255, 0, 0) {// create a font. In my program, set the cvenum. font. cv_font_hershey_complex's cvenum is removed for some reason. // mcvfont F = new mcvfont (cvenum. font. cv_font_hershey_complex, 1.0, 1.0); mcvfont F = new mcvfont (font. cv_font_hershey_complex, 1.0, 1.0); // d to "Hello, world. "image IMG. draw ("Hello, world", ref F, new point (10, 80), new BGR (0,255, 0);/* First method // show the image cvinvoke. cvshowimage (win1, IMG. PTR); // wait for the key pressing event cvinvoke. cvwaitkey (0); // destory the window cvinvoke. cvdestroywindow (win1); ** // The second method is imageviewer. show (IMG, "test window ");}}}}

 

This is a hello Word program. Let's take a look at the specific data types and functions.

2.1.1 Image

// Abstract: // create an empty image protected image (); // Abstract: // obtain the image from the specific bitmap // parameter: // BMP: // The bitmap which will be converted to the image public image (bitmap BMP); // Abstract: // create a multi-channel image from multiple gray scale images /// parameter: // channels: // The image channels to be merged into a single image public image (image <gray, tdepth> [] channels); // summary: // create a blank image of the specific size // parameter: // size: // the size of the image public image (size); // summary: // read image from a file /// parameter: // filename: // The name of the file that contains the image public image (string filename ); /// Summary: // create image from the specific multi-dimen1_data, where the 1st dimesion // is # of rows (height ), the 2nd dimension is # Cols (width) and the 3rd dimension // is the channel /// parameter: // data: // The multi-dimension data where the 1st dimension is # of rows (height), // The 2nd dimension is # Cols (width) and the 3rd dimension is the channel public image (tdepth [,] data); // Abstract: // create a blank image of the specified width and height. //// parameter: // width: // The width of the image // Height: // The height of the image public image (INT width, int height ); /// Summary: // constructor used to deserialize runtime serialized object // parameter: // info: // the serialization info /// context: // The streaming context public image (serializationinfo info, streamingcontext context); // Abstract: // create a blank image of the specified width, height and color. //// parameter: // width: // The width of the image // Height: // The height of the image // value: // The initial color of the image public image (INT width, int height, tcolor value); // Abstract: // create an image from unmanaged data. //// parameter: // width: // The width of the image // Height: // The height of the image // stride: // size of aligned image row in bytes /// scan0: // pointer to aligned image data, where each row shoshould be 4-align /// note: // The caller is responsible for allocating and freeing the block of memory // specified by the scan0 parameter, however, the memory shocould not be released // until the related image is released. public Image (INT width, int height, int stride, intptr scan0 );

The above is the code I tracked. We can see that the image has a lot of overloaded constructors. Here we only look at what is used in the code, and the rest can be tested by themselves based on the parameter price.

Image <BGR, byte> IMG = new image <BGR, byte> (400,200, new BGR (255, 0, 0 )) the constructor in the program uses the second derivative in the above Code,

Public Image (INT width, int height, tcolor value );

Tcolor is also used here, which is the parent class of BGR. In the code, we use create a BGR color using the specific values, that is, to create BGR with three BGR data, that is, a three-channel color image.

// Abstract: // defines a BGR (blue green red) color [colorinfo (conversioncodename = "BGR")] public struct BGR: icolor, iequatable <BGR >{/// Abstract: // create a BGR color using the system. drawing. color // parameter: // wincolor: // system. drawing. color public BGR (color wincolor); // Abstract: // create a BGR color using the specific values /// parameter: // Blue: // The blue value for this color /// Green: // The green value for this color /// Red: // The Red value for this color public BGR (Double blue, double green, double red); // Abstract: // get or set the intensity of the blue color channel [displaycolor (255, 0, 0)] public Double blue {Get; Set ;}/// Abstract: // get the dimension of this color public int dimension {Get;} // Summary: // get or set the intensity of the green color channel [displaycolor (0,255, 0)] public double green {Get; set;} // Abstract: // get or set the equivalent mcvscalar value public mcvscalar {Get; set ;} /// Summary: // get or set the intensity of the red color channel [displaycolor (0, 0,255)] public double red {Get; set;} // summary: // return true if the two color equals // parameter: // other: // The other color to compare with /// the returned result: // true if the two color equals public bool equals (BGR other); // Abstract: // represent this color as a string /// return result: // The string representation of this color public override string tostring ();}

I only care about the imga class here, and others can be viewed in a similar way. Of course, it is much more convenient to view the API. Because I can't go to the website, I can only do it using the original method.

// Abstract: // defines a BGR (blue green red) color [colorinfo (conversioncodename = "BGR")] public struct BGR: icolor, iequatable <BGR >{/// Abstract: // create a BGR color using the system. drawing. color // parameter: // wincolor: // system. drawing. color public BGR (color wincolor); // Abstract: // create a BGR color using the specific values /// parameter: // Blue: // The blue value for this color /// Green: // The green value for this color /// Red: // The Red value for this color public BGR (Double blue, double green, double red); // Abstract: // get or set the intensity of the blue color channel [displaycolor (255, 0, 0)] public Double blue {Get; Set ;}/// Abstract: // get the dimension of this color public int dimension {Get;} // Summary: // get or set the intensity of the green color channel [displaycolor (0,255, 0)] public double green {Get; set;} // Abstract: // get or set the equivalent mcvscalar value public mcvscalar {Get; set ;} /// Summary: // get or set the intensity of the red color channel [displaycolor (0, 0,255)] public double red {Get; set;} // summary: // return true if the two color equals // parameter: // other: // The other color to compare with /// the returned result: // true if the two color equals public bool equals (BGR other); // Abstract: // represent this color as a string /// return result: // The string representation of this color public override string tostring ();}

 

 

 

 

Website for emgu CV: http://www.emgu.com/wiki/index.php/Main_Page

Example http://www.cnblogs.com/zengqs/archive/2009/02/01/1382024.html for face recognition

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.