Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 660
michele Avatar asked Jan 20 '23 13:01

michele


1 Answers

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>
like image 154
karlphillip Avatar answered Jan 25 '23 06:01

karlphillip