Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV using Eclipse with CDT

I was always using QtCreator for OpenCV but a new project started with a friend needs to be done with eclipse.

I did all things I usually do with QtCreator but I am facing a strange problem. Although I did set the include path (/home/opencv/include) when I try to compile I get errors for missing headers (i.e opencv2/core/core.hpp). In the project explorer under include tag the only headers appear are the ones in the first level of the included directory. This means that cdt does not include headers recursively.

Is this a bug or I have to include every single directory?

enter image description here

like image 252
kechap Avatar asked Dec 16 '22 05:12

kechap


2 Answers

I had the same problem yesterday. It searched all around forums but nobody could answer me. Finally I realized that I was doing the include for the whole project and including files for the project is not the same as including files for the source file "source.cpp" (for eclipse, because for VisualStudio it is the same).

enter image description here

So try to rightclick on the .cpp file and include the directories for it. Anyway, if you tell me which version of OpenCV you're using I can tell you more aspects of how to include files in case you keep having troubles.

I hope it helps. When you get errors about missing headers is always related to include. At least it happened to be like this in my case.

like image 131
Jav_Rock Avatar answered Dec 28 '22 23:12

Jav_Rock


If the include path in Eclipse is /home/opencv/include , we assume that inside this directory you have 2 folders: opencv and opencv2.

On your source code you must reference the headers as:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

Does that makes sense to you?

Nevertheless, there are several tutorials that can help you configure Eclipse.

like image 42
karlphillip Avatar answered Dec 29 '22 01:12

karlphillip