1. 程式人生 > >Visual Studio 2010 配置OpenCV2.4.10

Visual Studio 2010 配置OpenCV2.4.10

記錄下來,備忘加分享!

0、環境:win 7 64位, visual studio 64位中文版,我直接把Opencv解壓到了C盤跟目錄下;

1、原材料,不說了,自行下載;

2、配置環境變數,建議把x86和x64的l路徑都加上去,很簡單,過!

3、開啟visual studio,新建一工程;

4、工程右鍵屬性,看到如圖所示,圖來了,簡直就是福音!


5、重點來了,看上方,配置和平臺了,在這裡說一下,配置分Debug和Release, 平臺分win32和64的,你可能看到的情況不一樣,因為我在配置管理器那塊,添加了64位支援,不過不要緊,接下來我舉例,Debug版本和win32平臺。

6、點選VC++目錄,新增包含目錄和庫目錄,如圖, 包含目錄如下圖,庫目錄如下圖,記住:此步驟只是配置的Win32下的Debug版本。 



7、新增庫,如下圖,那些庫檔案在C:\opencv\build\x86\vc10\lib, 不過新增的時候不支援選擇新增,只能手動新增,如下圖, 為方便大家,我把2.4.10所有庫敲了下來(其實也是從別處貼上來滴),你們直接貼上就好了,注意看這些庫名字,其實很有規律,2410代表版本為2.4.10,2410後面的d是使用debug版本的,不帶d是適用release版本的,選擇性貼上!!!

opencv_ml2410d.lib
opencv_calib3d2410d.lib
opencv_contrib2410d.lib
opencv_core2410d.lib
opencv_features2d2410d.lib
opencv_flann2410d.lib
opencv_gpu2410d.lib
opencv_highgui2410d.lib
opencv_imgproc2410d.lib
opencv_legacy2410d.lib
opencv_objdetect2410d.lib
opencv_ts2410d.lib
opencv_video2410d.lib
opencv_nonfree2410d.lib
opencv_ocl2410d.lib
opencv_photo2410d.lib
opencv_stitching2410d.lib
opencv_superres2410d.lib
opencv_videostab2410d.lib


opencv_objdetect2410.lib
opencv_ts2410.lib
opencv_video2410.lib
opencv_nonfree2410.lib
opencv_ocl2410.lib
opencv_photo2410.lib
opencv_stitching2410.lib
opencv_superres2410.lib
opencv_videostab2410.lib
opencv_calib3d2410.lib
opencv_contrib2410.lib
opencv_core2410.lib
opencv_features2d2410.lib
opencv_flann2410.lib
opencv_gpu2410.lib
opencv_highgui2410.lib
opencv_imgproc2410.lib
opencv_legacy2410.lib
opencv_ml2410.lib




8、可以了,測試用例,執行後會開啟攝像頭,你會看到,你自己!

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

int main( int argc, char** argv )
{
	//宣告IplImage指標
	IplImage* pFrame = NULL;

	//獲取攝像頭
	CvCapture* pCapture = cvCaptureFromCAM(0);

	//建立視窗
	cvNamedWindow("video", 1);

	//顯示視屏
	while(1)
	{
		pFrame=cvQueryFrame( pCapture );
		if(!pFrame)
			break;
		cvShowImage("video",pFrame);
		char c=cvWaitKey(33);
		if(c==27)
			break;
	}
	cvReleaseCapture(&pCapture);
	cvDestroyWindow("video");
}
9、寫在後面:

opencv這東西,還是覺得在window環境上順利,Linux上挺曲折;

opencv檔案下x86 x64的兩類庫名字完全一樣,並且debug和release的數量一樣,只是多多少少一個d而已;

按照上述方法,我試過debug+64、release+32、release+64,都沒有問題,只需對應改一下對應的庫目錄和庫檔案而已;

好了,有問題給我回信。微笑