Emgu CV
Http://sourceforge.net/projects/emgucv/files/
Find the latest one. Just install it in a silly way. After selecting the directory, the installation will be completed automatically. Then, you will be prompted to install the vs2008 and vs2010 plug-ins. I will use vs2010 and then complete the operation.
What is emgu CV?
Emgu CV is the encapsulation of the opencv image processing library on the. NET platform, that is, the. NET version. It can run in C #, VB, VC ++, etc.
After the installation is complete, you need to set the environment variables, such as I installed in E:/emgu/emgucv-windows-x86 2.2.1.1150, and then add E:/emgu/emgucv-windows-x86 2.2.1.1150/bin
Write the first Applet
Create a new windows application in vs2010
First, import the UI plug-in.
Navigate to the emgu installation directory bin and select emgu. cv. UI. dll.
Add DLL calls to references, including emgu. cv. dll, emgu. cv. ml. dll, emgu. cv. UI. dll, emgu. util. dll, and zedgraph. dll.
After adding the widget, place a button control and an imagebox control (custom plug-in imported in the third figure), and write the code.
Code
[C-sharp: nogutter]View plaincopy
- Using system;
- Using system. Collections. Generic;
- Using system. componentmodel;
- Using system. Data;
- Using system. drawing;
- Using system. LINQ;
- Using system. text;
- Using system. Windows. forms;
- Using emgu. CV; // PS: The called emgu DLL
- Using emgu. cv. structure;
- Using emgu. util;
- Using system. Threading;
- Namespace emgu1
- {
- Public partial class form1: Form
- {
- Public form1 ()
- {
- Initializecomponent ();
- }
- Private capture;
- Private bool captureinprocess; // determines the camera status
- Private void button#click (Object sender, eventargs E)
- {
- If (capture! = NULL) // the camera is not empty.
- {
- If (captureinprocess)
- {
- Application. Idle-= new eventhandler (processfram );
- Button1.text = "Stop! ";
- }
- Else
- {
- Application. Idle + = new eventhandler (processfram );
- Button1.text = "start! ";
- }
- Captureinprocess =! Captureinprocess;
- }
- Else // if the camera is empty, it is called using the capture () method.
- {
- Try
- {
- Capture = new capture ();
- }
- Catch (nullreferenceexception excpt)
- {
- MessageBox. Show (excpt. Message );
- }
- }
- }
- Private void processfram (Object sender, eventargs Arg)
- {
- Image <BGR, byte> frame = capture. queryframe ();
- Imagebox1.image = frame;
- }
- }
- }