[SOLVED][ERROR] [HELP] Using Qt + OpenCV to get what does webcam see
-
Hi,
Did you start you project from a QMainWindow and then changed manually the class to a QDialog ?
-
Hi.
For dialog I din change. But I change the cameradevice to QObject -
How did you create your dialog ?
-
Qt GUI application. Qmainwindow
-
Then how did it become a QDialog ?
-
errr, I changed the QMainwindow to QDialog manually, i should use QMainwindow or QDialog to create Dialog class?
-
[UPDATE]
After correction, I get another error as following:ERROR
@pi@raspberrypi:~/qt/Dialog$ qmake -project
pi@raspberrypi:~/qt/Dialog$ qmake Dialog.pro
pi@raspberrypi:~/qt/Dialog$ make
g++ -Wl,-O1 -o Dialog cameradevice.o dialog.o main.o moc_cameradevice.o moc_dialog.o -L/usr/lib/arm-linux-gnueabihf -lQtGui -lQtCore -lpthread
cameradevice.o: In functionCameraDevice::CameraDevice(QObject*)': cameradevice.cpp:(.text+0x24): undefined reference to
cv::VideoCapture::VideoCapture()'
cameradevice.o: In functioncv::Mat::~Mat()': cameradevice.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x70): undefined reference to
cv::fastFree(void*)'
cameradevice.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x7c): undefined reference to `cv::Mat::deallocate()'
collect2: ld returned 1 exit status
make: *** [Dialog] Error 1@ -
The error is because the CameraDevice class is unable to find the cv class when calling it's static member function: VideoCapture. What type of library do you include? Or do you use the QLibrary for that??
-
i include
- highgui
- cv
- cxcore
-
From my knowledge,
VideoCapture is under highgui.hpp.
i have include this file already.
anyone knwo what is happening?
-
You are not linking to the OpenCV libraries
-
Do you mean in XXX.pro file ?
-
Yes indeed, in you project pro file
-
@OPENCV_PATH = /usr/local/include/opencv2/
LIBS_PATH = /usr/local/include/opencv/
LIBS += -L$$LIBS_PATH
-lcv
-lhighgui
-lcxcoreINCLUDEPATH += $$OPENCV_PATH/core
$$OPENCV_PATH/highgui/@This is how my linking look like
-
Are you sure you are linking to all the needed libraries ?
-
no, i am nt sure, but i checked many times if i left out any.
Should not be left out...
if this is not left out of libraries, what is the problem ? -
Just a missing library. You can check with pkg-config what you need. You can even use it within your pro file (have a look at qmake's documentation)
-
Ok. I give it a try and looh. Thx a lot SGaist
-
[quote author="SGaist" date="1403731430"]Just a missing library. You can check with pkg-config what you need. You can even use it within your pro file (have a look at qmake's documentation) [/quote]
Don't really know how to do....
I just have a look at the qmake genarated makefile. The INCPATH inside should be the openCV path ? It is different.
the another thing to mention is, after i qmake project, my Dialog.pro file will changed. the coding will all replaced.i am new to Qt and OpenCV, i just could not link them up.
Thanks to SGaist again,
-
Hi SGaist,
Finally I did it!
I make a slightly change in "qmake.conf" file which is under @/usr/share/qt4/mkspecs/default/qmake.conf@
I added in the INCLUDEPATH and LIBS.
Then it Works!!