1. 程式人生 > >Windows7 64位機上Emgu CV2 4 2安裝與配置

Windows7 64位機上Emgu CV2 4 2安裝與配置

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!

               

1.      從http://sourceforge.net/projects/emgucv/?source=directory下載最新的Emgu CV2.4.2

2.      將libemgucv-windows-x86-gpu-2.4.2.1777拷貝到D:\soft\Emgu2.4.2資料夾下,執行此.exe檔案,將其安裝到D:\soft\Emgu2.4.2\emgucv-windows-x86-gpu2.4.2.1777資料夾下,安裝完後會自動重啟;

3.      將D:\soft\Emgu2.4.2\emgucv-windows-x86-gpu2.4.2.1777\binD:\soft\Emgu2.4.2\emgucv-windows-x86-gpu2.4.2.1777\bin\x86(

x86資料夾下包含有對應的OpenCV2.4.2的動態庫,將此目錄加入到環境變數後Emgu不需要額外的安裝相對應的OpenCV);新增到系統環境變數Path中,重啟;

4.      開啟vs2008,新建一個基於Windows窗體的應用程式;

5.      匯入UI外掛:Tool-->Choose Toolbox Items-->.NET Framework Components-->點選Browse,選中D:\soft\Emgu2.4.2\emgucv-windows-x86-gpu2.4.2.1777\bin

下的Emgu.CV.UI.dll開啟,會在列表中新增HistogramBoxImageBoxMatrixBoxPanAndZoomPictureBox四項;

6.      新增引用:選中工程下的References-->Add Reference-->Browse選中D:\soft\Emgu2.4.2\emgucv-windows-x86-gpu2.4.2.1777\bin下的Emgu.CV.dllEmgu.CV.ML.dll Emgu.CV.UI.dll Emgu.Util.dllZedGraph.dll 5個動態庫,點選OK

7.      點選Solution Platforms-->Configuration ManagerActive solution platform將原來的Any CPU改為x86,否則會提示“Emgu.CV.CvInvoke的型別初始值設定項引發異常”的錯誤。

網上的一個程式碼示例,編譯、執行成功:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

usingEmgu.CV;//Emgu

usingEmgu.CV.Structure;

usingEmgu.Util;

usingSystem.Threading;

namespaceTestEmgu

{

    public partial class Form1 : Form

    {

       publicForm1()

       {

           InitializeComponent();

       }

       privateCapturecapture;

       privateboolcaptureinprocess;//判斷攝像頭的狀態

       privatevoidbutton1_Click(objectsender,EventArgse)

       {

           if(capture !=null)

           {

               if(captureinprocess)

               {

                   Application.Idle -=newEventHandler(processframe);

                   button1.Text ="stop!";

               }

               else

               {

                   Application.Idle +=newEventHandler(processframe);

                   button1.Text ="start!";

               }

               captureinprocess= !captureinprocess;

           }

           else//攝像頭為空,則通過Capture()方法呼叫

           {

               try

               {

                   capture=newCapture();

               }

               catch(NullReferenceExceptionexcpt)

               {

                   MessageBox.Show(excpt.Message);

               }

           }

       }

       privatevoidprocessframe(objectsender,EventArgsarg)

       {

           Image<Bgr,Byte>frame =capture.QueryFrame();

           imageBox1.Image =frame;

       }

    }

}

參考文獻:

1.  http://www.emgu.com/wiki/

2.  http://blog.163.com/[email protected]/blog/static/71379539201282511180304/

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

           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述