Windows7 64位机上Emgu CV2.4.2安装与配置
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\bin;D:\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打開,會在列表中新增HistogramBox、ImageBox、MatrixBox、PanAndZoomPictureBox四項;
6.????? 添加引用:選中工程下的References-->Add Reference-->Browse選中D:\soft\Emgu2.4.2\emgucv-windows-x86-gpu2.4.2.1777\bin下的Emgu.CV.dll、Emgu.CV.ML.dll、 Emgu.CV.UI.dll、 Emgu.Util.dll、ZedGraph.dll 5個動態庫,點擊OK;
7.????? 點擊Solution Platforms-->Configuration Manager:Active 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
??? {
???????public Form1()
???????{
???????????InitializeComponent();
???????}
?
???????privateCapturecapture;
???????privateboolcaptureinprocess;//判斷攝像頭的狀態
?
???????privatevoidbutton1_Click(objectsender, EventArgse)
???????{
???????????if(capture !=null)
???????????{
???????????????if(captureinprocess)
???????????????{
???????????????????Application.Idle -=new EventHandler(processframe);
?
???????????????????button1.Text ="stop!";
???????????????}
???????????????else
???????????????{
???????????????????Application.Idle +=new EventHandler(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/woshitony111@126/blog/static/71379539201282511180304/
3.? http://blog.csdn.net/gaaranaruto/article/details/6328358
總結
以上是生活随笔為你收集整理的Windows7 64位机上Emgu CV2.4.2安装与配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows 7 64位机上OpenC
- 下一篇: tesseract-ocr3.02字符识