EmguCV学习-摄像头采集

271 篇文章 2 订阅
215 篇文章 2 订阅

作者:分享技术、分享生活

转自:http://www.cnblogs.com/fitel/archive/2012/10/23/2735345.html


一、目的:

  测试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.运行效果

  


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值