-欢迎转载,请务必注明出处。
一、目的:
测试Emgu安装是否正确,摄像头采集测试。
二、背景知识:
1.什么是EmguCV?
其实就是OpenCV的C#版,对于我这种熟悉.net人来说比较容易上手。
2.如何安装EmguCV?
详见http://www.emgu.com/wiki/index.php/Main_Page,或百度一下,很容易安装。
三、安装环境:
VisualStudio2008 + Emgu V2.0.5
四、测试步骤:
1.程序界面设计
2.程序代码
/* * Wrote by james at 2012-10-11 * jamesking.chao@gmail.com */ 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; using Emgu.CV.Structure; using Emgu.Util; using System.Threading; namespace Emgu学习_摄像头采集显示 { public partial class Form1 : Form { private Capture capt; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.btnBegin.Enabled = true; this.btnEnd.Enabled = false; } private void GetFrame(object sender, EventArgs e) { Image<Bgr, Byte> frame = capt.QueryFrame(); imageBox1.Image = frame; } private void button1_Click(object sender, EventArgs e) { try { if (capt == null) capt = new Capture(); } catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); } if (capt != null) { btnBegin.Enabled = false; btnEnd.Enabled = true; Application.Idle += new EventHandler(GetFrame); } } private void btnEnd_Click(object sender, EventArgs e) { if (capt != null) { btnBegin.Enabled = true; btnEnd.Enabled = false; Application.Idle -= new EventHandler(GetFrame); } } } }
3.运行效果