Eclipse and OpenCV on Ubuntu

I installed Eclipse + CDT and OpenCV with:

$ sudo apt-get install libcv1 libcv-dev libcvaux1 libcvaux-dev \ libhighgui1 libhighgui-dev \ opencv-doc \ python-opencv 

After that, I opened Eclipse and created a new c / C ++ project. So I typed this code:

 #include <stdlib.h> #include <stdio.h> #include <math.h> #include <cv.h> #include <highgui.h> int main(int argc, char *argv[]) { IplImage* img = 0; img=cvLoadImage("C:/.../Pictures/immagine.jpg"); // carica l'immagine cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); // crea la finestra cvShowImage("mainWin", img ); // mostra l'immagine cvWaitKey(0); // wait for a key cvReleaseImage(&img ); //rilascia l'immagine system("PAUSE"); return 0; } 

The problem is that I return these errors:

 Unresolved inclusion: <cv.h> Unresolved inclusion: <highgui.h> 

But in my eclipse workspace project, I have these libraries in the / usr / include directory ...

What could be wrong? Thank you

+4
source share
1 answer

Open a terminal and do:

 pkg-config --cflags opencv 

On my system, it returns:

 -I/usr/local/include/opencv -I/usr/local/include 

These are the directories you will need to add to Eclipse to compile your application.

Or , you can try replacing your included ones for:

 #include <opencv/cv.h> #include <opencv/highgui.h> 
+9
source

All Articles