Configure Eclipse With C++ And OpenCV

CONFIGURE ECLIPSE WITH C++ AND OPENCV
ref:http://rodrigoberriel.com/2014/10/using-opencv-3-0-0-with-eclipse/
1. Assumed eclipse and cdt (C++ Development tools) already installed. if not, pls follow this:

a. Install C++ Development (CDT):
ref:https://eclipse.org/cdt/downloads.php
Help -> Install New Software -> Add… ->
Add Repository form:
Name: C++ Development Tools
Location: http://download.eclipse.org/tools/cdt/releases/8.8.1 (CDT 8.8.1 FOR ECLIPSE MARS)

b. Check All and Install

2. Creating a New C++ Project on Eclipse
a. File » New » C++ Project;
b. Give a name to your project in Project Name; for example: TestOpenCV
c. Choose Executable » Empty Project in Project Type;
d. Check Linux GCC in Toolchains and press Next;
e. Click on Finish;

3. Linking OpenCV to the newly created project
a. Select the project and go to the menu Project » Properties (or press Alt+ENTER);
b. We’re going to modify somethings on Tool Settings tab of C/C++ Build » Settings;
c. In GCC C++ Compiler » Includes, add “/usr/local/include/opencv” in Include paths (-l). Discover the correct path by typing the following on the terminal: pkg-config –cflags opencv;

d. Go to GCC C++ Linker » Libraries and add “/usr/local/lib” in Library search paths (-L). Discover the correct path by typing the following on the terminal:: pkg-config –libs opencv;

e. Still in GCC C++ Linker » Libraries, add the libraries you’ll need in your project in Libraries (-l). We’re going to need 3 to our project (don’t forget to link opencv_imgcodecs, since imread() has moved to it in OpenCV 3):
opencv_core
opencv_imgcodecs
opencv_highgui

Done!

4. Lets test it!
a. Right-click on the project in Project Explorer and go to New » Folder;
b. Give a name to the folder, for instance: src.
c. Right-click on the src folder and go to New » File;
b. Give a name to the file, for instance: DisplayImage.cpp and type (or copy and paste) the code snippet below. Don’t forget to save the file.

Project » Build All (or Ctrl+B) to build;

5. Run the program
a. Right-click on the project in Project Explorer and go to Run As » Local C/C++ Application
b. The image should be appeared!!!

Leave a Reply

Your email address will not be published. Required fields are marked *