Emgu配置 pictureBox与imageBox等

来源:互联网 发布:淘宝上架后用不用管了 编辑:程序博客网 时间:2024/06/03 21:10

(1)Emgu配置:

http://blog.sina.com.cn/s/blog_4a185333010156ig.html

写的非常全面。

注意:右键单击“解决方案资源管理器”中刚才所建项目下的“引用”,选择“添加引用”;在新弹出的窗口中选择“浏览”,到目录:C:\Emgu\emgucv-windows-x86 2.3.0.1416\bin下,选择:Emgu.CV.dll、Emgu.CV.ML.dll、Emgu.CV.UI.dll、Emgu.Util.dll、ZedGraph.dll等共五个DLL文件,并点击确定加入    

可以在reference里面,add reference,就可以了。

(2)使用emgu打开摄像头

 private Capture _capture;
 private bool _captureInProgress;

 private void ProcessFrame(object sender, EventArgs arg)
        {
            Image<Bgr, Byte> frame = _capture.QueryFrame();
            imageBox1.Image = frame;
        }


        private void button2_Click(object sender, EventArgs e)
        {
            #region if capture is not created, create it now
            if (_capture == null)
            {
                try
                {
                    _capture = new Capture(0);


                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }

            #endregion
            if (_capture != null)
            {
                if (_captureInProgress)
                {  //stop the capture
                    button2.Text = "打开摄像头";
                    Application.Idle -= ProcessFrame;
                }
                else
                {
                    //start the capture
                    button2.Text = "关闭摄像头";
                    Application.Idle += ProcessFrame;
                }
                _captureInProgress = !_captureInProgress;
            }
        }


非常简单,比直接打开方便很多。

出现的问题:_capture = new Capture(0);

实例化的时候总是报错,是说unload opencv_core290.dll。

解决的办法是:将emgucv  bin 中x86中的dll全部(注意是全部,只拷unload opencv_core290.dll不行,拷x86整个文件夹也不行,只修改path也不行)拷如新建的工程的bin 中的debug里。


修改path:计算机——属性——高级系统设置——高级——环境变量

(3)emgu中imagebox与picturebox

imagebox 是emgu   设置好厚,新出现的控件。

这个可以用: Image<Bgr, Byte> frame = _capture.QueryFrame();
                         imageBox1.Image = frame;

picturebox是窗体中原有的: Image<Bgr, Byte> frame = _capture.QueryFrame();
                                                   imageBox1.Image =frame.ToBitmap();

就是这个差别。

    

C# 调用带参数EXE文件及带启动参数EXE:http://blog.csdn.net/lonet/article/details/4742256

将C++程序写为dll文件,再进行调用:http://wenku.baidu.com/view/d1b7e9fd910ef12d2af9e73c.html

C#读txt文件的方法:http://wenku.baidu.com/view/8fab9e62caaedd3383c4d328.html

0 0