Problème opencv

Fermé
konova - 5 juin 2015 à 15:28
Bonjour à tous,

j'ai un problème pour faire fonctionner opencv avec Qtcreator. J'ai opencv d'installé sur mon mac (10.10) et qui marche très bien avec Xcode. Cependant, quand je compile avec Qtcreator j'ai une erreur. J'ai vue pas mal de réponses sur les forums mais ça n'a jamais marché pour moi. Je demande donc votre aide car j'en ai besoin pour mon stage.

#include "mainwindow.h"
#include <QApplication>

#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}

Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file

if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}

namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;
}


Et voici mon .pro avec plein de truc rajouté que j'ai trouvé sur différent forum

#-------------------------------------------------
#
# Project created by QtCreator 2015-06-05T10:31:59
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = test_opencv_qt
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

INCLUDEPATH += /usr/local/include\
LIBS += -L/usr/local/lib \
LIBS += -libopencv_calib3d \
-1ibopencv_core \
-libopencv_features2d \
-libopencv_flann \
-1ibopencv_imgproc \
-libopencv_imgcodecs \
-libopencv_ml \
-libopencv_objdetect \
-libopencv_photo \
-libopencv_shape \
-libopencv_stitching \
-libopencv_superres \
-libopencv_video \
-libopencv_videoio \
-libopencv_videostab \
-1ibopencv_highgui

LIBS += -stdlib=libc++
LIBS += -framework IOKit

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -mmacosx-version-min=10.9
QMAKE_LFLAGS += -mmacosx-version-min=10.9

macx {
QMAKE_MAC_SDK = macosx10.10
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
}


Et enfin voici l'erreur:
Undefined symbols for architecture x86_64:
"cv::namedWindow(cv::String const&, int)", referenced from:
_main in main.o
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in main.o
"cv::Mat::copySize(cv::Mat const&)", referenced from:
cv::Mat::operator=(cv::Mat const&) in main.o
"cv::String::deallocate()", referenced from:
cv::String::~String() in main.o
"cv::String::allocate(unsigned long)", referenced from:
cv::String::String(char const*) in main.o
"cv::imread(cv::String const&, int)", referenced from:
_main in main.o
"cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
_main in main.o
"cv::waitKey(int)", referenced from:
_main in main.o
"cv::fastFree(void*)", referenced from:
cv::Mat::~Mat() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test_opencv_qt.app/Contents/MacOS/test_opencv_qt] Error 1
14:12:32: Le processus "/usr/bin/make" s'est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet test_opencv_qt (kit : Desktop Qt 5.4.2 clang 64bit)
When executing step "Make"