Using OpenCV 3.0.0 with Eclipse

19 Oct 2014

In this article, we’re going to see how to use OpenCV with Eclipse. We’ll use their latest releases: OpenCV 3.0.0 alpha e Eclipse Luna for C/C++ Developers. We’ll pass from downloading Eclipse, by setting a project linked with OpenCV until the implementation of our program. Don’t forget to check out the video demonstration of this process at the end of this article.

Pre-requirements:

Let’s start!

Before we start, we’re going to need to download Eclipse. I use OpenCV with C++, then I’m going to download the specific release to C/C++ of Eclipse Luna: Eclipse IDE for C/C++ Developers.

Note:

I didn’t add any image to exemplify each step, because there’s a video demonstration at the end. Watch the video: youtu.be/9ksMjQ2sBSQ!

Downloading and Installing Eclipse

You also can install Eclipse using sudo apt-get install eclipse-cdt

Creating a New C++ Project on Eclipse

Linking OpenCV to the newly created project

Lets test it!

Can we build our programs using OpenCV in this project? Let’s test? Coming right up!

Creating and building our program

#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char** argv) {
	Mat inputImage = imread(argv[1]);
	imshow("Input Image", inputImage);
	
	waitKey(0);
	return 0;
}

Running the program

On the Terminal, go to the folder where you created the project(cd {workspace}/{project_name}/). Inside, you’re going to see our program (main.cpp) and the folder “Release/”. Access the folder Release and run our program.

./{project_name} {image}

E.g.: ./OpenCV ~/Images/lena.jpg</pre>

If your image has opened, congratulations! You just ran your first program using OpenCV with Eclipse. Do you want to know how to run our program directly from Eclipse? Watch the video.

In case you have any question about how to execute any of the steps above, watch the video below demonstrating the whole process.

Do you still have questions? Has an error occurred? Leave a comment or contact me.