Step 1. 安裝minGW
下載 http://sourceforge.net/projects/mingw/files/
路徑: C:\MinGW
選項 mingw32-base and mingw32-gcc-g++
Step 2: 將minGW 家入 system path
Control Panel -> System -> Advanced System Settings
C:\MinGW\bin
Step 3: 安裝 Code::Blocks
下載最近版
(codeblocks-10.05-setup.exe)
http://www.codeblocks.org/downloads/binaries
安裝預設路徑
執行 Code::Blocks
功能表選項 Settings -> Compiler and Debugger
Toolchain Executables 下拉選項 GNU GCC Compiler
按 AutoDetect
確任 Code::Blocks 已找到 MinGW
測試 Code::Blocks and MinGW 和 a simple Hello World C++ program.
Step 4: 安裝 OpenCV
下載最近版 (2.4.2 for Windows) http://opencv.org/downloads.html
解壓縮 複製到 C:\
configured with Code::Blocks
安裝 cmake
執行 cmake 選 C:\opencv\source 和 C:\opencv\build\x86\mingw
按 configure 選 minGW makefiles 完成然按 generate.
命令視窗
cd C:\opencv\build\x86\mingw
type“mingw32-make”. Mingw will now start compiling OpenCV
,等待100%完成,時間久
然後 “mingw32-make install”
Step 5: Add OpenCV to the system path
C:\opencv\build\x86\mingw\bin
Step 6: Configuring Code::Blocks with OpenCV
Make a new Code::Blocks Project: testopencv
E.設定CodeBlocks編譯器參數
下載 lena.png
Now run this simple OpenCV “Hello World” program to test that the install has worked.
#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>using namespace cv;int main(){ Mat image;// new blank image image = cv::imread("lena.png", 0);// read the file namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// create a window for display. imshow( "Display window", image );// show our image inside it. waitKey(0);// wait for a keystroke in the window return 0;} |
//參考
http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/

