注意本教程配置環(huán)境:win7 32位
如果只配置vs2013+opencv2.4.11,參考http://jingyan.baidu.com/article/ff411625b1311a12e4823784.html
【具體步驟】
一、準(zhǔn)備配置
下載并安裝vs2013
下載并安裝Qt5.5.1
下載并安裝opencv2.4.11
下載qt-vs-addin-opensource-1.2.5
二、開(kāi)始配置
1、 安裝qt-vs-addin-opensource-1.2.5。安裝成功后vs2013的菜單欄上會(huì)多出一個(gè)Qt5的選項(xiàng)
2、 選擇QT5->Qt Options,將Qt下msvc2013的路徑添加進(jìn)來(lái)
3、 將opencv\build\x86\vc12\bin文件添加到系統(tǒng)環(huán)境變量中
選中系統(tǒng)變量中的Path點(diǎn)擊編輯將opencv的安裝目錄下的bin文件路徑添加到環(huán)境變量中。我的目錄是D:\StudyProgram\OpenCV2_4_11\opencv\build\x86\vc12\bin
(注意: 添加完環(huán)境變量之后需要重啟電腦才能生效。)
下面進(jìn)行一次性永久配置
4.添加Opencv和Qt的庫(kù)文件具體操作如下:
選擇VC++目錄添加可執(zhí)行文件目錄、包含目錄、庫(kù)目錄
(注意:opencv庫(kù)文件最好選擇x86使用x64版本在編譯時(shí)可能會(huì)提示錯(cuò)誤。vs2012對(duì)應(yīng)VC11,vs2010對(duì)應(yīng)vc10,vs2013對(duì)應(yīng)vc12。)
可執(zhí)行文件: D:\StudyProgram\OpenCV2_4_11\opencv\build\x86\vc12\bin
包含目錄: D:\StudyProgram\ OpenCV2_4_11\opencv\build\include
D:\StudyProgram\OpenCV2_4_11\opencv\build\include\opencv
D:\StudyProgram\OpenCV2_4_11\opencv\build\include\opencv2
庫(kù)目錄:D:\StudyProgram\OpenCV2_4_11\opencv\build\x86\vc12\lib
D:\StudyProgram\QT5_5_1\5.5\msvc2013\lib
5.選擇鏈接器->輸入|附加依賴項(xiàng)。注意,后面加d的是Debug版本的文件沒(méi)加d的是Release版本的文件。
Debug版本文件:(復(fù)制粘貼如下內(nèi)容即可)
qtmaind.lib
Qt5Cored.lib
Qt5Guid.lib
Qt5Widgetsd.lib
Qt5Sqld.lib
opencv_ml2411d.lib
opencv_calib3d2411d.lib
opencv_contrib2411d.lib
opencv_core2411d.lib
opencv_features2d2411d.lib
opencv_flann2411d.lib
opencv_gpu2411d.lib
opencv_highgui2411d.lib
opencv_imgproc2411d.lib
opencv_legacy2411d.lib
opencv_objdetect2411d.lib
opencv_ts2411d.lib
opencv_video2411d.lib
opencv_nonfree2411d.lib
opencv_ocl2411d.lib
opencv_photo2411d.lib
opencv_stitching2411d.lib
opencv_superres2411d.lib
opencv_videostab2411d.lib
6.在release模式下,按第2步建立opencv2411_release,雙擊后重復(fù)第5步
Release版本文件:(復(fù)制粘貼如下內(nèi)容即可)
qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Widgets.lib
Qt5Sql.lib
opencv_ml2411.lib
opencv_calib3d2411.lib
opencv_contrib2411.lib
opencv_core2411.lib
opencv_features2d2411.lib
opencv_flann2411.lib
opencv_gpu2411.lib
opencv_highgui2411.lib
opencv_imgproc2411.lib
opencv_legacy2411.lib
opencv_objdetect2411.lib
opencv_ts2411.lib
opencv_video2411.lib
opencv_nonfree2411.lib
opencv_ocl2411.lib
opencv_photo2411.lib
opencv_stitching2411.lib
opencv_superres2411.lib
opencv_videostab2411.lib
這些文件中關(guān)于Opencv的文件位于(目錄中的2411表示版本號(hào)):
D:\StudyProgram\OpenCV2_4_11\opencv\build\x86\vc12\lib。
關(guān)于Qt的文件位于:
D:\StudyProgram\QT5_5_1\5.5\msvc2013\lib
7.在你的項(xiàng)目文件夾下,你會(huì)發(fā)現(xiàn)兩個(gè)項(xiàng)目屬性表
把他們保存到不易刪除的地方,以后新建項(xiàng)目,直接添加相應(yīng)的項(xiàng)目屬性表即可,無(wú)需再次配置。
【測(cè)試程序】
#include<opencv2\highgui\highgui.hpp>
usingnamespacecv;
usingnamespacestd;
intmain()
{
MatsrcImage = imread("C:/Users/a/Desktop/1.jpg");
namedWindow("你很優(yōu)秀",0);
imshow("你很優(yōu)秀",srcImage);
waitKey(0);
return 1;
}
聯(lián)系客服