2013年12月26日木曜日

How to build an opencv 2.4.7.2 (mingw) on windows 8.1

Windows上に、最新のOpencv2.4.7.2を展開したら、

何ということでしょう? minigw 対応のライブラリーがない。

で、Build のメモ、いろいろかき集めて、メモとして保存。なくなると困りそうなので、、、

opencvは、E:\opencvに展開する。cmakeもインストールしておく。

(1) Download and install MinGW and add to the system PATH with  c:\mingw\bin

(2) Download OpenCV2.4.7.2 Windows version

(3)  Install Opencv to E:\opencv  (README,index.rst and CMakeLists.txt are here with all subfolders)

(4)  Run CMake GUI tool

(5) Choose E:\opencv\sources as source

(6) Choose the destination, E:\opencv\build\x86  where to build the binaries

(7) Press Configure button, choose MinGW Makefiles as the generator. There are some red highlights in the window, choose options as you need. 

(8) Press the Configure button again. Configuring is now done.

(9) Press the Generate button.

(10)  Exit the program when the generating is done.

(11)  Exit the Cmake program.

(12) Run the command line mode (cmd.exe) and go to the destination directory E:\opencv\build\x86

(13) Type "mingw32-make install" (without quotation marks). You will see a progress of building binaries. If the command is not found, you must make sure that the system PATH is added with c:/mingw/bin. The build continues according the chosen options to a completion.

(14) In Windows system PATH (My Computer > Right button click > Properties > Advanced > Environment Variables > Path) add the destination's bin directory, E:\opencv\build\x86\mingw\bin

(15) Go to the Eclipse CDT IDE, create a C++ program using the sample OpenCV code 


(16)  Go to Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes, and add the source OpenCV folder (including quotation marks) "E:\opencv\build\include"

(17) Go to Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries, and add to the Libraries (-l)ONE BY ONE (this could vary from project to project, you can add all of them if you like or some of them just the ones that you need for your project): 

opencv_calib3d247
opencv_contrib247
opencv_core247
opencv_features2d247
opencv_flann247
opencv_gpu247
opencv_highgui247
opencv_imgproc247
opencv_legacy247
opencv_ml247
opencv_nonfree247
opencv_objdetect247
opencv_photo247
opencv_stitching247
opencv_video247
opencv_videostab247

(18) Add the built OpenCV library folder (including quotation marks),  "E:\opencv\build\x86\mingw\lib" to Library search path (-L)

Peace!!


-------------------------------------------------------------------------------------
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/nonfree/nonfree.hpp>
#include <iostream>
//#pragma comment(lib,"opencv_nonfree24.lib");
using namespace std;
    cv::initModule_nonfree();

------------------------------------------------------
//#include <cv.h>
//include <highgui.h>

#include <opencv2/opencv.hpp>
#include <opencv2/legacy/legacy.hpp> // cvCreateKDTree, cvFindFeatures, cvReleaseFeatureTree
#include <opencv2/legacy/compat.hpp> // CvSURFParams, cvExtractSURF
#include <opencv2/nonfree/nonfree.hpp> // cv::initModule_nonfree

//cv::initModule_nonfree();

0 件のコメント:

コメントを投稿