2013年11月14日 星期四

Dev C++ 4.9.9.2 搭配OpenCV2.4.7

前言:
使用了Dev C++ 4.9.9.2搭配OpenCV版本2.4.7。

軟體:
作業系統:Windows 7 旗艦版
Dev-C++:4.9.9.2 (http://prdownloads.sourceforge.net/dev-cpp/devcpp-4.9.9.2_setup.exe)
OpenCV:2.4.7 (https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.7/OpenCV-2.4.7.exe/download)

設定:
1. 使用預設編譯器或者新增都可以
2. 連結器命令列中加入以下命令(是新增的話,前面框號記得要先打勾)
-lopencv_core247d -lopencv_highgui247d -lopencv_video247d -lopencv_ml247d -lopencv_legacy247d -lopencv_imgproc247d

3. 工具→編譯器選項→目錄→二進位檔

C:\Dev-Cpp\libexec\gcc\mingw32\3.4.2
C:\Dev-Cpp\bin
C:\opencv\build\x86\vc10\bin



4. 工具→編譯器選項→目錄→函式庫
C:\opencv\build\x86\vc10\lib
C:\Dev-Cpp\lib


5. 工具→編譯器選項→目錄→C引入檔
C:\opencv\build\include
C:\opencv\build\include\opencv
C:\opencv\build\include\opencv2
C:\Dev-Cpp\include

6. DEV 工具→編譯器選項→目錄→C++引入檔
C:\opencv\build\include\opencv
C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include
C:\Dev-Cpp\include\c++\3.4.2\backward
C:\Dev-Cpp\include\c++\3.4.2\mingw32
C:\Dev-Cpp\include\c++\3.4.2
C:\Dev-Cpp\include

使用範例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#include "highgui.h"
int main( int argc, char** argv) 
{
    IplImage* img = cvLoadImage("D:/個人檔案/Facbook covers/wallpaper-730977.jpg", 1);
    cvNamedWindow("Back to Space", CV_WINDOW_AUTOSIZE);
    cvShowImage("Back to Space", img);
    cvWaitKey(0);
    cvDestroyWindow("Back to Space");
    cvReleaseImage(&img);
}


分享:
Share to Facebook Share on Google Plus Share on Tumblr Share to Twitter Email This Pin This

4 則留言:

  1. 請問一下為什麼我全部照做後,#include "highgui.h"出現錯誤?

    回覆刪除
    回覆
    1. 可以給更詳細的描述嗎? 有出現什麼訊息?

      刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. 不好意思
    我也照做了
    出現了
    opencv2/core/core.hpp: No such file or directory.
    opencv2/core/core.hpp: No such file or directory.
    opencv2/highgui/highgui_c.h: No such file or directory.
    opencv2/highgui/highgui.hpp: No such file or directory.

    回覆刪除