Monday, May 9, 2011

OpenCV with Eclipse CDT and MinGW

  1. CMake 
  2. MinGW with MSYS 
  3. OpenCV source code 
  4. Eclipse CDT
 Let say, you download OpenCV and put it into C:/c-dev/OpenCV-2.2.0
  1. Open MSYS and go to OpenCV folder
    cd C:/c-dev/OpenCV-2.2.0
  2. Run CMake command to generate "Build files"
    cmake -G "Unix Makefiles" .
  3.  Build OpenCV
    make install
  4. Add bin directory to your PATH
After successfully build process you can see dll files in "bin" folder and library files ".dll.a" in "lib" folder. Now you are ready to make the first OpenCV program.
  • Create new project

  • Add header path

  • Add library path

  • Add libraries

Time to code

#include <iostream>
#include "opencv2/opencv.hpp"

int main(int argc, char** argv) {
cout << "Hello OpenCV" << endl;
IplImage* img = cvLoadImage("lena.jpg", CV_LOAD_IMAGE_COLOR);
if (img) {
cvShowImage("Hello OpenCV", img);
return 0;

No comments:

Post a Comment