PDA

View Full Version : Pb to install opencv2.3 under Qt



harold4
11th August 2011, 17:22
Hello to all,

As it is said in the title, I wish to install opencv2.3 under Qt creator.

My version is OpenCV-2.3.0-win-superpack, I decompressed it and installed under the directory:

Let be C:\Develop\Opencv\build and C:\Develop\Opencv\opencv

I installed then the last one sdk Qt that is:
Qt Creator 2.2.1
Based on Qt 4.7.4 32bit and mingw4.4 (I not nothing changed)

I already have to install opencv2.3 with codeblocks thanks to OpenCV-2.3.0-win-superpack and to MinGW-4.5.2 that I installed and then changed the tool chain in codeblocks.

And my wish would be to make it turn under Qt who seems to me rather nice.

I have already followed quite a lot of explanation but I do not still manage to take out there.

I put a project console with one quite simple hand for tried:


// main.cpp
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>

int main(){
cv::Mat image = cv::imread("test.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image", image);
cv::waitKey(-1);
return 0;
}

#.pro
TEMPLATE = app
QT -= gui
TARGET = SimpleCvApp

SOURCES += \
main.cpp

INCLUDEPATH += C:/Develop/Opencv/opencv/modules/core/include \
C:/Develop/Opencv/opencv/modules/highgui/include \
C:/Develop/Opencv/build/x86/mingw/lib
LIBS += "C:\Develop\Opencv\build\x86\mingw\lib\libopencv_co re230.dll.a" \
LIBS = "C:\Develop\Opencv\build\x86\mingw\lib\libopencv_hi ghgui230.dll.a"

I tried some solution, but unsuccessfully. If somebody had a track or a tutorial.

Thank you in advance
Stéphane

stampede
11th August 2011, 20:41
May be a coincidence, but there is similar thread about OpenCV 2.3 : link (http://www.qtcentre.org/threads/43793-Trying-to-use-OpenCV)...
Anyway, you forgot to tell us whats the problem :rolleyes:

LIBS += "C:\Develop\Opencv\build\x86\mingw\lib\libopencv_c ore230.dll.a" \
LIBS = "C:\Develop\Opencv\build\x86\mingw\lib\libopencv_h ighgui230.dll.a"
Surely you wanted to write LIBS += in the last line, not LIBS = , because this will ... yeah I think you know why. And dynamic linking should be done using the -l flag (LIBS += -lopencv_core230 etc).

harold4
12th August 2011, 11:06
Thank you for your answer
The problem it is because I do not manage to make turn opencv2.3 under qt creator.
I have to recompile opencv2.3 with mingw of Qt, thus I think that of this quoted, I am good.
I put back my main:
<code>
/**
* @file DisplayImage.cpp
* @brief Sample code that show how to read and display an image in a OpenCV window
* @author OpenCV team
*/

#include <QApplication>

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

using namespace cv;

int main(int argc, char *argv[])

{
QApplication app(argc, argv);

// Mat image;
//image = imread( argv[1], 1 );

//if( argc != 2 || !image.data )
// {
// printf( "No image data \n" );
// return -1;
// }

// namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
//imshow( "Display Image", image );

// waitKey(0);

return app.exec();

}
</code>
and my .pro
<code>
#.pro
TEMPLATE = app
QT -= gui
TARGET = Test

SOURCES += \
main.cpp

INCLUDEPATH += "C:/Develop/Opencv/Build/install/modules/core/include" \
"C:/Develop/Opencv/Build/install/modules/highgui/include"

LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_cali b3d230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_cont rib230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_core 230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_feat ures2d230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_flan n230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_gpu2 30.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_high gui230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_imgp roc230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_lega cy230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_ml23 0.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_objd etect230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_vide o230.dll" \
LIBS += "C:\Develop\Opencv\Build\install\bin\opencv_ffmpeg. dll" \

#LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_core 230.dll" \
#LIBS += "C:\Develop\Opencv\Build\install\bin\libopencv_high gui230.dll" \
</code>

When i shoot qmake qt say : Unescaped bachslashes are deprecated
And when i shoot the prog : QApplication : no such file or directory
like cv.h and highgui.h.
so the problem must be in the .pro
Thank for advance
Stephan

stampede
12th August 2011, 11:39
QApplication is a part of QtGui module, so you can't disable this module if you want to use it:

QT -= guiIf you dont want gui module, use QCoreApplication.

like cv.h and highgui.h.
Do you have files cv.h and highgui.h in directories specified in INCLUDEPATH variable ?

harold4
12th August 2011, 12:44
Ok for your recommandation.
What is it : Unescaped bachslashes are deprecated ligne 25
I must having a problem of syntax

harold4
12th August 2011, 16:13
Thank you it's good. It was the .pro