2013年8月23日

Visual Studio 2008 安裝 OpenCV 2.4.6


作業系統環境/IDE/OpenCV版本:


  • Windows XP 32bit
  • Microsoft Visual Studio 2008
  • Microsoft .NET 3.5 SP1
  • OpenCV 2.4.6


建立環境步驟:

1.OpenCV 2.4.6

Download link for Windows

下載後,解壓縮執行OpenCV-2.4.6.0.exe至任一目錄下,此文安裝在D:\desktop\opencv2_4_6之中


2.設定電腦中PATH環境變數

我的電腦->(右鍵)->內容->進階->環境變數->系統變數:Path

新增兩處
D:\desktop\opencv2_4_6\opencv\build\x86\vc9\bin;
D:\desktop\opencv2_4_6\opencv\build;


附註:IDE版本不同,所需的library會在不同位置
vc9:vs2008
vc10:vc2010
vc11:vc2012


3.Visual Studio 2008 IDE環境設定
(工作->選項->VC++目錄->顯示目錄)


可執行檔(新增1行)

D:\desktop\opencv2_4_6\opencv\build\x86\vc9\bin


Include檔案(新增3行)

D:\desktop\opencv2_4_6\opencv\build\include
D:\desktop\opencv2_4_6\opencv\build\include\opencv
D:\desktop\opencv2_4_6\opencv\build\include\opencv2

參考檔(新增3行)

D:\desktop\opencv2_4_6\opencv\build\x86\vc9
D:\desktop\opencv2_4_6\opencv\build\x86\vc9\lib
D:\desktop\opencv2_4_6\opencv\build\x86\vc9\staticlib

程式庫檔(新增1行)

D:\desktop\opencv2_4_6\opencv\build\x86\vc9\lib


4.專案linker設定
(project右鍵->屬性)


組態Debug

連結器->輸入->其他相依性:

新增:
opencv_features2d246d.lib
opencv_highgui246d.lib
opencv_core246d.lib
opencv_imgproc246d.lib
opencv_ml246d.lib
opencv_objdetect246d.lib
opencv_video246d.lib
opencv_contrib246d.lib
opencv_calib3d246d.lib


組態Release

連結器->輸入->其他相依性:

新增:
opencv_features2d246.lib
opencv_highgui246.lib
opencv_core246.lib
opencv_imgproc246.lib
opencv_ml246.lib
opencv_objdetect246.lib
opencv_video246.lib
opencv_contrib246.lib
opencv_calib3d246.lib



測試程式碼:(jpg圖案須自行輸入)

#include "cv.h"      // include it to used Main OpenCV functions.
#include "highgui.h" //include it to use GUI functions.

int main(int argc, char** argv)
{
    IplImage* img = cvLoadImage( "xxx.jpg" ); //change the name (image.jpg) according to your Image filename.
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage("Example1", img);
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example1" );
    return 0;
}








沒有留言:

張貼留言

新電腦上重新安裝 Windows 10

想要在電腦上安裝 Windows 10 嗎? 若要開始使用,您首先必須取得安裝 Windows 10 的授權。然後才可以下載並執行媒體建立工具。如需工具使用方式的詳細資訊,請參閱下列指示。 https://www.microsoft.com/zh-tw/software-...