1. 程式人生 > >在VS2013下的openCV2.4.9安裝過程

在VS2013下的openCV2.4.9安裝過程

OpenCV 2.4.9 +VS2013 開發環境配置

在windows平臺64位系統使用visual studio2013和opencv2.4.9配置一個開發環境。

首先先安裝好VS2013安裝過程在此不再詳說。

1.從上面地址下載的openCV2.4.9然後解壓,我是解壓在E:\opencv249下

如圖1所示

2. 配置環境變數

(1)系統變數找到path變數在其後新增E:\opencv249\opencv\build\x86\vc12\bin

(2)客戶變數:新增opencv變數,在其後新增E:\opencv249\opencv\build

                           新增path變數在其後新增E:\opencv249\opencv\build\x86\vc12\bin

如圖2所示

3新建visualC++專案,如圖3、4所示

4. 工程目錄 配置(debug)

如圖5所示找到屬性管理器,雙擊Debug|Windows32

設定如下:

1、包含目錄:(VC++目錄)(圖6所示)

D:\Program Files\opencv\build\include

D:\Program Files\opencv\build\include\opencv

D:\Program Files\opencv\build\include\opencv2

2、庫目錄:(VC++目錄)(圖6所示)

D:\Program Files\opencv\build\x86\vc12\lib

3、聯結器->輸入->附加依賴項:(圖7所示)

opencv_ml249d.lib

opencv_calib3d249d.lib

opencv_contrib249d.lib

opencv_core249d.lib

opencv_features2d249d.lib

opencv_flann249d.lib

opencv_gpu249d.lib

opencv_highgui249d.lib

opencv_imgproc249d.lib

opencv_legacy249d.lib

opencv_objdetect249d.lib

opencv_ts249d.lib

opencv_video249d.lib

opencv_nonfree249d.lib

opencv_ocl249d.lib

opencv_photo249d.lib

opencv_stitching249d.lib

opencv_superres249d.lib

opencv_videostab249d.lib

其實以上都是D:\Program Files\opencv\build\x86\vc12\lib下所有的lib檔案(圖8所示),你會發現,有的後面帶上d,有的沒有d,這是因為Debug的就有d,Release則沒有d。

5.然後在 圖5所示單擊release\Windows32,其配置過程和debug的配置一樣,不過在連結器-輸入-附加依賴項的時候輸入的不同

opencv_objdetect249.lib

opencv_ts249.lib

opencv_video249.lib

opencv_nonfree249.lib

opencv_ocl249.lib

opencv_photo249.lib

opencv_stitching249.lib

opencv_superres249.lib

opencv_videostab249.lib

opencv_calib3d249.lib

opencv_contrib249.lib

opencv_core249.lib

opencv_features2d249.lib

opencv_flann249.lib

opencv_gpu249.lib

opencv_highgui249.lib

opencv_imgproc249.lib

opencv_legacy249.lib

opencv_ml249.lib

6.最後建立一個cpp檔案測試一下即可。例如

#include <cv.h>

#include <highgui.h>

using namespace std;

int main()

{

IplImage * test;

test = cvLoadImage("D:\\Sample_8.bmp");//圖片路徑

cvNamedWindow("test_demo", 1);

cvShowImage("test_demo", test);

cvWaitKey(0);

cvDestroyWindow("test_demo");

cvReleaseImage(&test);

return 0;

}

建立過程如圖9、10所示

文章參考百度經驗