当前位置:首页 > Windows程序 > 正文

Add opencv to eclipse on Windows

2021-03-25 Windows程序

reference from 

step 1. download

1. eclipse c++. select Windows 32-bit or Windows 64-bit

2. mingGW.

  2.1 follow "Basic Setup", select all and click Installation -> apply...

  2.2 Add bin directory to path  (mycomputer -> prosperties -> advanced system settings -> Environment Variables -> system Variables:Path ->Edit add the directory).

3. OpenCV for Windows 2.4.10. Extract files and  add the bin directory => Path (mycomputer -> prosperties -> advanced system settings -> Environment Variables -> system Variables:Path ->Edit add the directory).

step 2. Create and Configure

1. Open the Eclipse, Create a new C++ project : File > New > C++ Project ( Don‘t forget to select the MinGW toolchains)

2. replace test code

///////////////CODE/////////// #include "opencv2/highgui/highgui.hpp" #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat im = imread(argc == 2 ? argv[1] : "lenna.png", 1);// the image in your project if (im.empty()) { cout << "Cannot open image!" << endl; return -1; } imshow("image", im); waitKey(0); return 0; } ///////////////CODE///////////

3. Now go to Properties >> C/C++ Build >> Settings on the Tool Setting tab :

    GCC C++ Compiler >> Includes and include opencv path ! [opencvDir\build\include]

    MinGW C++ Linker >> Libraries and add the Library search path [opencvDIR\build\x86\mingw\lib]

Add opencv to eclipse on Windows

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/67417.html