C#下的openCV(Emgu CV)

4 篇文章 0 订阅

http://blog.csdn.net/gaaranaruto/article/details/6328358

2011-04-16 20:582871人阅读评论(5)收藏举报

Emgu CV下载地址

http://sourceforge.net/projects/emgucv/files/

找最新的下就行了,傻瓜式安装,选择目录后自动完成安装,然后提示安装VS2008和VS2010的插件,我使用的是VS2010,然后完成操作。

Emgu CV是什么?

Emgu CV是.NET平台下对OpenCV图像处理库的封装,也就是.NET版。可以运行在C#、VB、VC++等。

安装完成后需要设置环境变量,比如我安装在E:/Emgu/emgucv-windows-x86 2.2.1.1150,然后再系统环境变量添加E:/Emgu/emgucv-windows-x86 2.2.1.1150/bin即可

编写第一个小程序

在VS2010中新建一个Windows应用程序

首先需要导入UI插件

在浏览中定位到Emgu的安装目录bin下,选择Emgu.CV.UI.dll

在引用中添加dll调用,分别是Emgu.CV.dll和Emgu.CV.ML.dll和Emgu.CV.UI.dll和Emgu.Util.dll以及ZedGraph.dll

添加完毕后放置一个Button控件和一个imagebox控件(第三张图中导入的自定义插件),然后编写代码即可

代码

[c-sharp:nogutter] view plain copy print ?
  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:调用的Emgu dll 
  10. using Emgu.CV.Structure; 
  11. using Emgu.Util; 
  12. using System.Threading; 
  13. namespace Emgu1 
  14.     public partial class Form1 : Form 
  15.     { 
  16.         public Form1() 
  17.         { 
  18.             InitializeComponent(); 
  19.         } 
  20.         private Capture capture; 
  21.         private bool captureinprocess;//判断摄像头的状态 
  22.         private void button1_Click(object sender, EventArgs e) 
  23.         { 
  24.             if (capture != null)//摄像头不为空 
  25.             { 
  26.                 if (captureinprocess) 
  27.                 { 
  28.                     Application.Idle -= new EventHandler(processfram); 
  29.                     button1.Text = "Stop!"; 
  30.                 } 
  31.                 else 
  32.                 { 
  33.                     Application.Idle += new EventHandler(processfram); 
  34.                     button1.Text = "Start!"; 
  35.                 } 
  36.                 captureinprocess = !captureinprocess; 
  37.             } 
  38.             else//摄像头为空则通过Capture()方法调用 
  39.             { 
  40.                 try 
  41.                 { 
  42.                     capture = new Capture(); 
  43.                 } 
  44.                 catch (NullReferenceException excpt) 
  45.                 { 
  46.                     MessageBox.Show(excpt.Message); 
  47.                 } 
  48.             } 
  49.         } 
  50.         private void processfram(object sender, EventArgs arg) 
  51.         { 
  52.             Image<Bgr, Byte> frame = capture.QueryFrame(); 
  53.             imageBox1.Image = frame; 
  54.         } 
  55.     } 

总结

我刚开始研究Emgu CV,有很多很多不懂的地方,以上步骤我基本是按照网上教程一步一步做的(http://www.dotblogs.com.tw/chou/archive/2009/06/13/8812.aspx),没有任何问题,CV中提供了众多的借口方便调用,非常适合需要图像处理而不精通算法的人,这里面非常值得研究,这是我发的第一篇心得,基本算是转帖,大家见谅!欢迎一起讨论

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值