you will need the latest stable version of openCV 2.4.3.
Eclipse Juno! (Eclipse IDE for C / C ++ Developers) As well as MinGW - Minimalist GNU for Windows
we will ignore the x86 / 64 choice, since we are going to work with 32 compilers and 32 openCV lines, although the system is the 64th!
Step 1: Download and Install
Eclipse
Download Eclipse and unzip the archive. (I assumed that you already have a JRE on your computer, if not! Download and install it).
Mingw
Download MinGW. the installer will guide you through this process! you may need to add the bin directory to the path! (Default path: C / MinGW / bin)
Opencv
Download openCV exe from the link, extract the files (in the C: / directory in this lesson). Make sure you have the file structure below.
don't forget to add the bin => Path directory!
As I mentioned before! I will use the x86 build, even if I have 64 OSs, to avoid compiler issues and to make this tutorial open to x86 users!
Step 2. Create and configure
- Open the Eclipse IDE!
- Create a new C ++ project: File> New> C ++ Project
- Choose a Hello Word project to have a pre-structured! Remember to choose MinGW Tools
Click Finish and get started!
Now that you have your first Hello word project! replace the code in the soure.cpp file with the code below
///////////////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); if (im.empty()) { cout << "Cannot open image!" << endl; return -1; } imshow("image", im); waitKey(0); return 0; }
///////////////CODE///////////
Obviously there are a few errors in the code, yes! we must link the libraries!
Now go to the "Properties" menu -> C / C ++ Build -> Settings on the "Tool Setup" tab -> GCC C ++ Compiler -> Turns on and on the opencv path! [OpencvDir \ build \ include]
Now go to MinGW C ++ Linker β Libraries and add the library search path [opencvDIR \ build \ x86 \ mingw \ lib]
in the part of the "Library"! we add as many librarians as we need for the project! here I added 4 libraries just for the tutorial, even if you only need highgui for our test code! Library names can be found in the [opencvDIR \ build \ x86 \ mingw \ lib] directory Example! for libopencv_video243.dll.a wee add opencv_video243 to the linker!
click OK!
Now we can build our first project! You understand that you need to add an image to the project, as implied in the source code "lenna.png", Use lenna for good luck
Create and run a project! If you see a beautiful lady :) Congratulations :)
see pictures here! opencveclipse-on-windows