Seite 1 von 2
QT und OpenCV
Verfasst: 3. August 2009 19:52
von soerdgod
Hallo zusammen!
Ich habe folgendes Problem:
Ich habe sowohl OpenCV installiert und getestet als auch QT samt QTCreator.
Jetzt würde ich gerne mit dem QTCreator als Entwicklungumgebung OpenCV benutzen.
Dann habe ich den Beispielcode vom 'Qt Opencv webcam viewer' gefunden und wollte den builden. Allerdings sagt mir der Compiler, dass die includes opencv/cv.h und opencv/highgui.h nicht gefunden werden können.
Die Pathvariable habe ich um den Pfad zu OpenCV ergänzt.
Was habe ich denn vergessen, dass ich das alles benutzen kann?
mfG. soerdgod
Verfasst: 3. August 2009 23:03
von Christian81
Das ggleiche Problem wie
hier.
Verfasst: 7. August 2009 12:53
von soerdgod
danke, aber da ist ja auch nicht beantwortet, wie ich dieses Problem beheben kann.
Könnte mir das einer erklären?
Verfasst: 7. August 2009 13:06
von Mani99
Poste doch mal deine *.pro datei!
Und event. einen allgemeinen pfad wo die header liegen!
Verfasst: 7. August 2009 18:24
von soerdgod
Die *.pro Datei sieht wie folgt aus:
Code: Alles auswählen
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += "C:\OpenCV\cxcore\include" \ "C:\OpenCV\cv\include" \ "C:\OpenCV\cvaux\include"
LIBS += -L"C:\OpenCV\lib"
LIBS += -lcv -lhighgui
SOURCES += main.cpp QOpenCVWidget.cpp MyCameraWindow.cpp
HEADERS += QOpenCVWidget.cpp MyCameraWindow.h
Die Header Dateien liegen unter:
- C:\OpenCV\cv\include
C:\OpenCV\cxcore\include
C:\Qt\2009.03\qt\include
mfG.
soerdgod
Verfasst: 7. August 2009 19:18
von Christian81
Backslashes in Pfaden machen sich nicht gut...
Verfasst: 7. August 2009 19:21
von soerdgod
Das behebt das Problem aber leider auch nicht....
Verfasst: 7. August 2009 19:56
von Christian81
Dann zeig mal die Ausgabe von make wenn eine Source-Datei kompiliert wird. Dort müssten die angegebenen Pfade mit drin sein. Und wenn in den Pfaden auch irgendwo opencv/highgui.h und opencv/cv.h drin sind wird es auch klappen.
Verfasst: 7. August 2009 20:13
von soerdgod
Das is die Ausgabe im QTCreator unter Kimpilierung:
Code: Alles auswählen
Führe Build-Schritte für Projekt QtOpenCV aus...
Starte: C:/Qt/2009.03/qt/bin/qmake.exe C:/Users/soerdgod/Documents/QTWorkspace/QtOpenCV/QtOpenCV.pro -spec win32-g++ -r
Beendet mit Rückgabewert 0.
Starte: C:/Qt/2009.03/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Users/soerdgod/Documents/QTWorkspace/QtOpenCV'
C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/soerdgod/Documents/QTWorkspace/QtOpenCV'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\Qt\2009.03\qt\include\QtCore" -I"c:\Qt\2009.03\qt\include\QtGui" -I"c:\Qt\2009.03\qt\include" -I"c:\OpenCV\cv\include" -I"c:" -I"c:\OpenCV\cvaux\include" -I"c:" -I"c:\OpenCV\cxcore\include" -I"c:\Qt\2009.03\qt\include\ActiveQt" -I"debug" -I"c:\Qt\2009.03\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
mingw32-make[1]: Leaving directory `C:/Users/soerdgod/Documents/QTWorkspace/QtOpenCV'
mingw32-make: Leaving directory `C:/Users/soerdgod/Documents/QTWorkspace/QtOpenCV'
main.cpp:1:23: opencv/cv.h: No such file or directory
main.cpp:2:28: opencv/highgui.h: No such file or directory
In file included from main.cpp:8:
QOpenCVWidget.h:22: error: `IplImage' has not been declared
QOpenCVWidget.h:22: error: ISO C++ forbids declaration of `parameter' with no type
In file included from main.cpp:9:
MyCameraWindow.h:16: error: ISO C++ forbids declaration of `CvCapture' with no type
MyCameraWindow.h:16: error: expected `;' before '*' token
MyCameraWindow.h:19: error: expected `)' before '*' token
main.cpp: In function `int qMain(int, char**)':
main.cpp:12: error: `CvCapture' was not declared in this scope
main.cpp:12: error: `camera' was not declared in this scope
main.cpp:12: error: `cvCreateCameraCapture' was not declared in this scope
main.cpp:14: error: `IplImage' was not declared in this scope
main.cpp:14: error: `image' was not declared in this scope
main.cpp:14: error: `cvQueryFrame' was not declared in this scope
main.cpp:26: error: `cvReleaseCapture' was not declared in this scope
main.cpp:12: warning: unused variable 'CvCapture'
main.cpp:12: warning: unused variable 'cvCreateCameraCapture'
main.cpp:14: warning: unused variable 'IplImage'
main.cpp:14: warning: unused variable 'cvQueryFrame'
main.cpp:26: warning: unused variable 'cvReleaseCapture'
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make: *** [debug] Error 2
Beendet mit Rückgabewert 2.
Fehler beim Erstellen des Projekts QtOpenCV
Beim Ausführen des Build-Schritts 'Make'
Verfasst: 7. August 2009 20:25
von Christian81
Dann eben nochmal:
ist in c:\OpenCV\cvaux\include auch wirklich eine Datei opencv/cv.h ? Ich glaube nicht...
/edit: Außerdem - hast Du openCV selbst kompiliert? Die vorkompilierte Download-Version ist für msvc gebaut...
Verfasst: 7. August 2009 20:29
von soerdgod
Nein, die Datei cv.h ist im Ordner
C:\OpenCV\cv\include
Muss ich dann also das include auf "cv.h" ändern, oder was meinst du damit?
Verfasst: 7. August 2009 20:31
von Christian81
soerdgod hat geschrieben:
Muss ich dann also das include auf "cv.h" ändern, oder was meinst du damit?
Nein - der Compiler weiss von allein dass er opencv weglassen muss ...

Verfasst: 7. August 2009 20:37
von soerdgod
Ok.
Nein, ich habe OpenCV nicht selbst kompiliert. Ich wusste nicht, dass das nicht mit dem QTCreator funktioniert.
Habe erst neu angefangen mit QT und keine Ahnung und in dem Tutorial, dass ich gefunden hatte stand dazu auch nichts.
Dann werde ich da nochmal nach schaun.
danke soweit
mfG
soerdgod
Verfasst: 10. August 2009 09:09
von RavenIV
Der QWt-Creator nutzt als Compiler doch den MinGW.
Da dieser ein Windows-Clone des gcc ist, braucht er auch die Libs im entsprechenden Format.
Also musst Du OpenCV und evtl. Qt mit MinGW neu compilieren.
OpenCV mit MinGW kompilieren verursacht Error
Verfasst: 8. Oktober 2009 12:13
von Florian F.
Hallo,
ich habe auch einen ähnlichen Fehler wie der Threadstarter hier. Und zwar bekomme ich wenn ich ein kleines QT-Programm (welches einfach nur die cv.h-Datei inkludiert) erstellen möchte immer einen Kompilerfehler. Nachdem ich unteranderem Hier gelesen habe, das man die Libraries für die Verwendung von Qt und MinGW erst noch mit MinGW kompilieren muss, habe ich das gemacht. Nach der Anleitung auf der OpenCV-Webseite. Doch bekomme ich immer beim Kompilieren von OpenCV denselben Fehler wie schon bei dem Versuch das Programm zu kompilieren. Der Fehler sieht wie folgt aus:
Code: Alles auswählen
[ 41%] Building CXX object src/cxcore/CMakeFiles/cxcore_pch_dephelp.dir/cxcore_pch_dephelp.obj
In file included from c:/Programme/OpenCV2.0/include/opencv/cxcore.hpp:2243,
from c:/Programme/OpenCV2.0/include/opencv/cxcore.h:2123,
from C:/Programme/OpenCV2.0/src/cxcore/_cxcore.h:60,
from c:/temp_edb/opencv2/src/cxcore/cxcore_pch_dephelp.cxx:1:
c:/Programme/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv::Ptr<_Tp>::addref()':
c:/Programme/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
c:/Programme/OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: (if you use `-fpermissive', G++ will accept your cod
e, but allowing the use of an undeclared name is deprecated)
c:/Programme/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv::Ptr<_Tp>::release()':
c:/Programme/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
c:/Programme/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `cv::Vec<_Tp, cn>& cv::Ptr<_Tp>::operator=(co
nst cv::Ptr<_Tp>&)':
c:/Programme/OpenCV2.0/include/opencv/cxoperations.hpp:1473: 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
In file included from c:/Programme/OpenCV2.0/include/opencv/cxcore.hpp:2244,
from c:/Programme/OpenCV2.0/include/opencv/cxcore.h:2123,
from C:/Programme/OpenCV2.0/src/cxcore/_cxcore.h:60,
from c:/temp_edb/opencv2/src/cxcore/cxcore_pch_dephelp.cxx:1:
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In copy constructor `cv::Mat::Mat(const cv::Mat&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:102: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:102: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In constructor `cv::Mat::Mat(const cv::Mat&, const cv::Range&, const cv
::Range&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:174: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:174: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In constructor `cv::Mat::Mat(const cv::Mat&, const cv::Rect&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:189: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:189: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::Mat& cv::Mat::operator=(const cv::Mat&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:239: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:239: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::Mat::addref()':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:342: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:342: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::Mat::release()':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:346: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:346: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In copy constructor `cv::MatND::MatND(const cv::MatND&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3648: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3648: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::MatND& cv::MatND::operator=(const cv::MatND&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3677: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3677: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::MatND::addref()':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3717: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3717: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::MatND::release()':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3722: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:3722: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::SparseMat& cv::SparseMat::operator=(const cv::S
parseMat&)':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:4081: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:4081: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::SparseMat::addref()':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:4112: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:4112: warning: unused variable '__exchange_and_add'
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::SparseMat::release()':
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:4116: error: `__exchange_and_add' was not declared in this scope
c:/Programme/OpenCV2.0/include/opencv/cxmat.hpp:4116: warning: unused variable '__exchange_and_add'
make[2]: *** [src/cxcore/CMakeFiles/cxcore_pch_dephelp.dir/cxcore_pch_dephelp.obj] Error 1
make[1]: *** [src/cxcore/CMakeFiles/cxcore_pch_dephelp.dir/all] Error 2
make: *** [all] Error 2
Als Umgebung verwende ich Qt 4.5.2 (versucht auch mit 4.5.3), MinGW aktuellste Version, MSys (aktuellste Version), OpenCV 2.0.
Hat da jemand vielleicht eine Idee was ich falsch mache? Oder ist es schon mal jemandem gelungen OpenCV 2.0 erfolgreich unter diesen Bedingungen zu kompilieren?
Vielen Dank schon im Voraus!
Florian Freitag