First emgu CV instance

Source: Internet
Author: User
Tags image processing library

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

  1. Using system;
  2. Using system. Collections. Generic;
  3. Using system. componentmodel;
  4. Using system. Data;
  5. Using system. drawing;
  6. Using system. LINQ;
  7. Using system. text;
  8. Using system. Windows. forms;
  9. Using emgu. CV; // PS: The called emgu DLL
  10. Using emgu. cv. structure;
  11. Using emgu. util;
  12. Using system. Threading;
  13. Namespace emgu1
  14. {
  15. Public partial class form1: Form
  16. {
  17. Public form1 ()
  18. {
  19. Initializecomponent ();
  20. }
  21. Private capture;
  22. Private bool captureinprocess; // determines the camera status
  23. Private void button#click (Object sender, eventargs E)
  24. {
  25. If (capture! = NULL) // the camera is not empty.
  26. {
  27. If (captureinprocess)
  28. {
  29. Application. Idle-= new eventhandler (processfram );
  30. Button1.text = "Stop! ";
  31. }
  32. Else
  33. {
  34. Application. Idle + = new eventhandler (processfram );
  35. Button1.text = "start! ";
  36. }
  37. Captureinprocess =! Captureinprocess;
  38. }
  39. Else // if the camera is empty, it is called using the capture () method.
  40. {
  41. Try
  42. {
  43. Capture = new capture ();
  44. }
  45. Catch (nullreferenceexception excpt)
  46. {
  47. MessageBox. Show (excpt. Message );
  48. }
  49. }
  50. }
  51. Private void processfram (Object sender, eventargs Arg)
  52. {
  53. Image <BGR, byte> frame = capture. queryframe ();
  54. Imagebox1.image = frame;
  55. }
  56. }
  57. }

 

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.