PDA

View Full Version : Qt and OpenCV



malorie
18th November 2009, 20:41
Hi ! I know there are other threads about "Qt and OpenCV" but I didn't find any understable solution for my problem. Sorry if my search was not well done.

Here is my problem: I try to use someone else's code to create an UI (now it is just a console application). I never tried to run this code on my computer, I am not sure there is no problem but there wasn't problem on other computers, it was running well. The problem is that code uses some OpenCV functions, it uses:

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

I tried to follow some advices and to search on this forum.

Until now, I wrote in my .pro file:


QT -= gui
TARGET = testSeb
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
FichiersSources/SignatureImage.cpp \
FichiersSources/Repertoire.cpp \
FichiersSources/Librairie.cpp \
FichiersSources/FichierImage.cpp \
FichiersSources/Fichier.cpp \
FichiersSources/Description.cpp \
FichiersSources/BaseDImages.cpp
HEADERS += FichiersRessources/dirent.h \
FichiersDEntete/SignatureImage.h \
FichiersDEntete/Repertoire.h \
FichiersDEntete/Librairie.h \
FichiersDEntete/FichierImage.h \
FichiersDEntete/Fichier.h \
FichiersDEntete/Description.h \
FichiersDEntete/BaseDImages.h
INCLUDEPATH += "C:\OpenCV2.0\include\opencv"
LIBS += "C:\OpenCV2.0\lib\libcv200.dll.a" "C:\OpenCV2.0\lib\libcvaux200.dll.a" "C:\OpenCV2.0\lib\libcxcore200.dll.a" "C:\OpenCV2.0\lib\libhighgui200.dll.a" "C:\OpenCV2.0\lib\libcxts200.dll.a"


"C:\OpenCV2.0\include\opencv" is the repertory where cv.h and highgui.h are.

But I obtained 17 errors and 45 warnings when compiling:



"Running build steps for project testSeb...
Starting: C:/Qt/2009.04/qt/bin/qmake.exe C:/Documents and Settings/Malorie/qtprojects/testSeb/testSeb.pro -spec win32-g++ -r
Exited with code 0.
Starting: C:/Qt/2009.04/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Documents and Settings/Malorie/qtprojects/testSeb'
C:/Qt/2009.04/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/Malorie/qtprojects/testSeb'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\Qt\2009.04\qt\include\QtCore" -I"..\..\..\..\Qt\2009.04\qt\include" -I"..\..\..\..\OpenCV2.0\include\opencv" -I"..\..\..\..\Qt\2009.04\qt\include\ActiveQt" -I"debug" -I"..\..\..\..\Qt\2009.04\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
In file included from ../../../../OpenCV2.0/include/opencv/cxcore.hpp:2243,
from ../../../../OpenCV2.0/include/opencv/cxcore.h:2123,
from ../../../../OpenCV2.0/include/opencv/cv.h:58,
from FichiersDEntete/Librairie.h:12,
from FichiersDEntete/Repertoire.h:10,
from FichiersDEntete/Fichier.h:10,
from FichiersDEntete/FichierImage.h:10,
from main.cpp:11:
../../../../OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv:Ptr<_Tp>::addref()':
../../../../OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
../../../../OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
../../../../OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv:Ptr<_Tp>::release()':
../../../../OpenCV2.0/include/opencv/cxoperations.hpp:1446: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
(...My message is too long...)
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project testSeb
When executing build step 'Make'

I did not paste all the message because it was too long. Please tell me how to post it if it is necessary.

I must say I don't understand at all... I am just a beginner, so it is quite difficult for me, sorry if my question is ridiculous...

Thank you in advance for your answers !

(I am sorry, I know my English is not good, but French is my mother tongue)

malorie
21st November 2009, 16:15
(Sorry, I do not find how to edit my thread).

In fact, my problem is solved ! I was using OpenCV 2.0 while the code was for version 1.0. Now everything is working well. There was no error in my project file, it was correct to do:


INCLUDEPATH += "D:\Program Files\OpenCV\cv\include" "D:\Program Files\OpenCV\cvaux\include" "D:\Program Files\OpenCV\cxcore\include" "D:\Program Files\OpenCV\otherlibs\highgui"
LIBS += -L"D:\Program Files\OpenCV\lib" -lcv -lcvaux -lhighgui -lcxcore

# Input
HEADERS += "D:\Program Files\OpenCV\cv\include\cv.h" "D:\Program Files\OpenCV\otherlibs\highgui\highgui.h"

arpspatel
7th March 2010, 14:57
Hi ! I know there are other threads about "Qt and OpenCV" but I didn't find any understable solution for my problem. Sorry if my search was not well done.

Here is my problem: I try to use someone else's code to create an UI (now it is just a console application). I never tried to run this code on my computer, I am not sure there is no problem but there wasn't problem on other computers, it was running well. The problem is that code uses some OpenCV functions, it uses:

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

I tried to follow some advices and to search on this forum.

Until now, I wrote in my .pro file:


QT -= gui
TARGET = testSeb
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
FichiersSources/SignatureImage.cpp \
FichiersSources/Repertoire.cpp \
FichiersSources/Librairie.cpp \
FichiersSources/FichierImage.cpp \
FichiersSources/Fichier.cpp \
FichiersSources/Description.cpp \
FichiersSources/BaseDImages.cpp
HEADERS += FichiersRessources/dirent.h \
FichiersDEntete/SignatureImage.h \
FichiersDEntete/Repertoire.h \
FichiersDEntete/Librairie.h \
FichiersDEntete/FichierImage.h \
FichiersDEntete/Fichier.h \
FichiersDEntete/Description.h \
FichiersDEntete/BaseDImages.h
INCLUDEPATH += "C:\OpenCV2.0\include\opencv"
LIBS += "C:\OpenCV2.0\lib\libcv200.dll.a" "C:\OpenCV2.0\lib\libcvaux200.dll.a" "C:\OpenCV2.0\lib\libcxcore200.dll.a" "C:\OpenCV2.0\lib\libhighgui200.dll.a" "C:\OpenCV2.0\lib\libcxts200.dll.a"


"C:\OpenCV2.0\include\opencv" is the repertory where cv.h and highgui.h are.

But I obtained 17 errors and 45 warnings when compiling:



"Running build steps for project testSeb...
Starting: C:/Qt/2009.04/qt/bin/qmake.exe C:/Documents and Settings/Malorie/qtprojects/testSeb/testSeb.pro -spec win32-g++ -r
Exited with code 0.
Starting: C:/Qt/2009.04/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Documents and Settings/Malorie/qtprojects/testSeb'
C:/Qt/2009.04/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/Malorie/qtprojects/testSeb'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\..\..\..\Qt\2009.04\qt\include\QtCore" -I"..\..\..\..\Qt\2009.04\qt\include" -I"..\..\..\..\OpenCV2.0\include\opencv" -I"..\..\..\..\Qt\2009.04\qt\include\ActiveQt" -I"debug" -I"..\..\..\..\Qt\2009.04\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
In file included from ../../../../OpenCV2.0/include/opencv/cxcore.hpp:2243,
from ../../../../OpenCV2.0/include/opencv/cxcore.h:2123,
from ../../../../OpenCV2.0/include/opencv/cv.h:58,
from FichiersDEntete/Librairie.h:12,
from FichiersDEntete/Repertoire.h:10,
from FichiersDEntete/Fichier.h:10,
from FichiersDEntete/FichierImage.h:10,
from main.cpp:11:
../../../../OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv:Ptr<_Tp>::addref()':
../../../../OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
../../../../OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
../../../../OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv:Ptr<_Tp>::release()':
../../../../OpenCV2.0/include/opencv/cxoperations.hpp:1446: error: there are no arguments to `__exchange_and_add' that depend on a template parameter, so a declaration of `__exchange_and_add' must be available
(...My message is too long...)
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project testSeb
When executing build step 'Make'

I did not paste all the message because it was too long. Please tell me how to post it if it is necessary.

I must say I don't understand at all... I am just a beginner, so it is quite difficult for me, sorry if my question is ridiculous...

Thank you in advance for your answers !

(I am sorry, I know my English is not good, but French is my mother tongue)

This error is because you are using mingw gcc version less than 4.
you can check the version by going to qt command prompt and typing

g++ --version

if version less than 4 , install the latest gcc/g++ 4.x.x for mingw.

and also try changing line 68 in cxoperations.hpp from
#if __GNUC__ >= 4
to
#if __GNUC__ >= 4 || __MINGW32__