Reputation: 822
I am actually having trouble with the following OpenCV sample:
http://docs.opencv.org/2.4.5/modules/highgui/doc/qt_new_functions.html
(I updated path for my env & added the callbacks functions that are not in the sample).
I compiled Opencv setting Qt On:
GUI: -- QT 4.x: YES (ver 4.8.2 EDITION = OpenSource) -- QT OpenGL support: NO -- OpenGL support: NO
When I try the code I found in Qt doc: I have the following backtrace:
(gdb) backtrace #0 0x00007ffff14f53e8 in QAction::setEnabled(bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4 #1 0x00007ffff67bf0db in GuiReceiver::enablePropertiesButtonEachWindow() () from /usr/local/lib/libopencv_highgui.so.2.4 #2 0x00007ffff67c02db in GuiReceiver::addButton(QString, int, int, void*, void*) () from /usr/local/lib/libopencv_highgui.so.2.4 #3 0x00007ffff67c5e9a in GuiReceiver::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/local/lib/libopencv_highgui.so.2.4 #4 0x00007ffff0fcef77 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #5 0x00007ffff0fd134c in QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4 #6 0x00007ffff67b23a7 in cvCreateButton () from /usr/local/lib/libopencv_highgui.so.2.4 #7 0x0000000000400f6c in main (argc=, argv=) at main.cpp:20
Does Anyone has the same issue ? I just want to precise that I don't want to embed Opencv in Qt but just use Qt features provided by opencv.
I found a start of answer here: How to use cv::createButton prototype in OpenCV
But this was not relevant...
Thanks for your help.
Still having some problems there is a piece of code:
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
void callbackButton(int state, void* userdata){}
int main(int ac, char **av){
namedWindow("main1",CV_WINDOW_NORMAL);
namedWindow("main2",CV_WINDOW_AUTOSIZE | CV_GUI_NORMAL);
int a = 0;
createButton("test",callbackButton, &a, CV_CHECKBOX,1);
return 0;
}
Upvotes: 3
Views: 3310
Reputation: 1
I also could not create a button with OpenCV 2.4.5 / Qt 4.8.0. I downloaded OpenCV 2.4.9 and installed it under the same settings, and now it works.
Upvotes: 0
Reputation: 93410
I cannot confirm nor deny that this problem is real since I have a different setup on my machine (OpenCV 2.4.9 and Qt 5.0.2).
But I found that creating a window with CV_GUI_NORMAL
crashes the application. The docs states:
CV_GUI_NORMAL or CV_GUI_EXPANDED: CV_GUI_NORMAL is the old way to draw the window without statusbar and toolbar, whereas CV_GUI_EXPANDED is the new enhance GUI.
I suggest you create your windows with CV_GUI_EXPANDED
for the time being.
Upvotes: 1