Slt les amis ça fait quelques jours que j'essaye d'intégrer OpenCV dans Qt mais sans succés, j'ai suivi le tutos sur le net, mais chez moi ça marche pas :

Je veux juste afficher une image avec opencv, jai linker les .lib de opencv et les headers mais quand je compil: j'ai ces erreur dans le main.o

undefined reference to cv::imgread....
undefined reference to cv::namedWindow...
...

Voila mon .pro

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
#-------------------------------------------------
#
# Project created by QtCreator 2011-05-19T00:55:47
#
#-------------------------------------------------
 
QT       += core gui
 
TARGET = mirs
TEMPLATE = app
 
 
SOURCES += main.cpp\
        mainwindow.cpp
 
INCLUDEPATH += C:\OpenCV2.2\include
HEADERS  += mainwindow.h
 
win32:LIBS += c:/OpenCV2.2/lib/opencv_core220d.lib c:/OpenCV2.2/lib/opencv_highgui220d.lib c:/OpenCV2.2/lib/opencv_calib3d220d.lib \
              c:/OpenCV2.2/lib/opencv_contrib220d.lib c:/OpenCV2.2/lib/opencv_features2d220d.lib c:/OpenCV2.2/lib/opencv_ffmpeg220d.lib \
              c:/OpenCV2.2/lib/opencv_flann220d.lib c:/OpenCV2.2/lib/opencv_gpu220d.lib c:/OpenCV2.2/lib/opencv_imgproc220d.lib c:/OpenCV2.2/lib/opencv_legacy220d.lib \
              c:/OpenCV2.2/lib/opencv_ml220d.lib c:/OpenCV2.2/lib/opencv_objdetect220d.lib c:/OpenCV2.2/lib/opencv_ts220.lib c:/OpenCV2.2/lib/opencv_video220d.lib
 
CONFIG += qt debug
et voici mon fichier main.cpp

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
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
 
using namespace cv;
 
int main(int argc, char *argv[])
{
    QApplication mirs(argc, argv);
 
    Mat loadedImage = imread("images/1.jpg",1);
    namedWindow("picture window", CV_WINDOW_AUTOSIZE);
    imshow("picture window", loadedImage);
    waitKey(0);
 
    MainWindow w;
    w.show();
 
    return mirs.exec();
}
Merci