emgu CV应用于视觉计数

由于C++的窗口编程太难了,本人才疏学浅,无法胜任。所以想用C#配合emgu CV做了一个简单的视觉计数,期间参考了各位大神的资料。请见谅。

using AForge.Video.DirectShow;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using Emgu.CV.Util;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApp1

{
    public partial class Form1 : Form
    {
        public ImageViewer viewer = new ImageViewer();//读取视频            
        public VideoCapture capture = new VideoCapture(); //视频帧率
        public FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        public VideoCaptureDevice videoSource = new VideoCaptureDevice();
        public Mat srcc = new Mat();

        //private NewFrameEventHandler videoSource_NewFrame;
        public Form1()
        {
            InitializeComponent();
            GetDevices();
        }

        public FilterInfoCollection GetDevices()
        {
            try
            {
                //枚举所有视频输入设备  
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                if (videoDevices.Count != 0)
                {
                    //MessageBox.Show("已找到视频设备.");
                    foreach (FilterInfo device in videoDevices)
                    {
                        cbCapture.Items.Add(device.Name);//把所有的视频设备添加到下拉框中
                    }
                    cbCapture.SelectedIndex = 0;
                    return videoDevices;
                }
                else
                    MessageBox.Show("error:没有找到视频设备!具体原因:");
                return null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("error:没有找到视频设备!具体原因:", ex.Message);
                return null;
            }
        }

        private void Counter(Mat src)
        {
            Mat src_binary = new Mat(), dst = new Mat(), src_distance = new Mat();

            //CvInvoke.Imshow("y

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值