michele
michele

Reputation: 26598

Eclipse and OpenCV on Ubuntu

I have 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've opened Eclipse and created a new c/c++ project. So I've 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 have these errors returned:

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

But in my eclipse workspace project I have these libraries under /usr/include...

What may be wrong? Thanks.

Upvotes: 4

Views: 7154

Answers (1)

karlphillip
karlphillip

Reputation: 93468

Open a terminal and execute:

pkg-config --cflags opencv

On my system it returns:

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

Those are the directories you'll have to add on Eclipse to compile your application.

Or, you could try replacing your includes for:

#include <opencv/cv.h>
#include <opencv/highgui.h>

Upvotes: 9

Related Questions