Hello,

J'ai besoin d'installer OpenCV pour faire des tests. Cependant, pour une raison obscur, je ne peux pas compiler le moindre programme, meme un programme exemple...

Environnement: Anjuta 2.26.0.0, Ubuntu 9.04

Code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
////////////////////////////////////////////////////////////////////////
//
// hello-world.cpp
//
// This is a simple, introductory OpenCV program. The program reads an
// image from a file, inverts it, and displays the result. 
//
////////////////////////////////////////////////////////////////////////
 
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
 
 
int main(int argc, char *argv[])
{
  IplImage* img = 0; 
  int height,width,step,channels;
  uchar *data;
  int i,j,k;
 
  if(argc<2){
    printf("Usage: main <image-file-name>\n\7");
    exit(0);
  }
 
  // load an image  
  img=cvLoadImage("/home/olivier/c++/source/examples/c/lena.jpg");
  if(!img){
    printf("Could not load image file: %s\n",argv[1]);
    exit(0);
  }
 
  // get the image data
  height    = img->height;
  width     = img->width;
  step      = img->widthStep;
  channels  = img->nChannels;
  data      = (uchar *)img->imageData;
  printf("Processing a %dx%d image with %d channels\n",height,width,channels); 
 
  // create a window
  cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
  cvMoveWindow("mainWin", 100, 100);
 
  // invert the image
  for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
    data[i*step+j*channels+k]=255-data[i*step+j*channels+k];
 
  // show the image
  cvShowImage("mainWin", img );
 
  // wait for a key
  cvWaitKey(0);
 
  // release the image
  cvReleaseImage(&img );
  return 0;
}
Message d'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
make
/bin/bash ../libtool --tag=CXX   --mode=link g++  -g -O2   -o facedetect main.o  
libtool: link: g++ -g -O2 -o facedetect main.o 
main.o: In function `main':
/home/olivier/c++/facedetect/src/main.cc:30: undefined reference to `cvLoadImage'
/home/olivier/c++/facedetect/src/main.cc:45: undefined reference to `cvNamedWindow'
/home/olivier/c++/facedetect/src/main.cc:46: undefined reference to `cvMoveWindow'
/home/olivier/c++/facedetect/src/main.cc:53: undefined reference to `cvShowImage'
/home/olivier/c++/facedetect/src/main.cc:56: undefined reference to `cvWaitKey'
/home/olivier/c++/facedetect/src/main.cc:59: undefined reference to `cvReleaseImage'
collect2: ld returned 1 exit status
make: *** [facedetect] Error 1
Terminé sur un échec
Temps total : 0 secondes
Pourtant les fonctions sont bien dans opencv/highgui.h. Bref, je comprends pas... Une idée?

Olivier