1. 程式人生 > >VS 配置Opencv2413

VS 配置Opencv2413

stream 圖像 wait med 工程 ret ctu bin tool

系統變量 Path: F:\2biancheng_tool\Opencv2413\opencv\build\x86\vc12\bin

用戶變量:添加opencv變量,值: F:\2biancheng_tool\Opencv2413\opencv\build

說明:不管你系統是32位還是64位,路徑目錄均選擇X86,因為編譯都是使用32位編譯;如果選用X64,則程序運行時候會出錯。

工程目錄的配置(Debug)

找到屬性管理器,如果找不到,請安裝下圖方法找到。雙擊Debug|Win32打開如下窗口,

設置如下:(下圖紅框項為設置項)

1、包含目錄:(VC++目錄)

D:\Program Files\opencv\build\include

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

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

2、庫目錄:(VC++目錄)D:\Program Files\opencv\build\x86\vc12\lib

3、連接器->輸入->附加依賴項:

opencv_ml2413d.lib
opencv_calib3d2413d.lib
opencv_contrib2413d.lib
opencv_core2413d.lib

opencv_features2d2413d.lib
opencv_flann2413d.lib
opencv_gpu2413d.lib
opencv_highgui2413d.lib
opencv_imgproc2413d.lib
opencv_legacy2413d.lib
opencv_objdetect2413d.lib
opencv_ts2413d.lib
opencv_video2413d.lib
opencv_nonfree2413d.lib
opencv_ocl2413d.lib
opencv_photo2413d.lib
opencv_stitching2413d.lib
opencv_superres2413d.lib
opencv_videostab2413d.lib

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

工程目錄的配置(Release)

其他與Debug一樣,只是連接器->輸入->附加依賴項不一樣,設置如下:

opencv_objdetect2413.lib
opencv_ts2413.lib
opencv_video2413.lib
opencv_nonfree2413.lib
opencv_ocl2413.lib
opencv_photo2413.lib
opencv_stitching2413.lib
opencv_superres2413.lib
opencv_videostab2413.lib
opencv_calib3d2413.lib
opencv_contrib2413.lib
opencv_core2413.lib
opencv_features2d2413.lib
opencv_flann2413.lib
opencv_gpu2413.lib
opencv_highgui2413.lib
opencv_imgproc2413.lib
opencv_legacy2413.lib
opencv_ml2413.lib

輸入代碼:

<pre name="code" class="cpp">#include <iostream>
#include<core/core.hpp>
#include<highgui/highgui.hpp>


using namespace cv;
using namespace std;


int main()
{

//讀入圖片,註意圖片路徑
Mat image=imread("D:\\Picture\\lena.jpg");


//圖片讀入成功與否判定
if(!image.data)
{
cout<<"you idiot!where did you hide lena!"<<endl;


//等待按鍵
system("pause");
return -1;
}


//創建一個名字為“Lena”的圖像顯示窗口,(不提前聲明也可以)
namedWindow("Lena",1);


//顯示圖像
imshow("Lena",image);


//等待按鍵
waitKey();
return 0;
}

VS 配置Opencv2413