gpt4 book ai didi

c++ - 在 opencv2.4.5 中使用 createButton(Qt gui 功能)段错误

转载 作者:太空狗 更新时间:2023-10-29 23:06:15 26 4
gpt4 key购买 nike

我实际上在使用以下 OpenCV 示例时遇到了问题:

http://docs.opencv.org/2.4.5/modules/highgui/doc/qt_new_functions.html

(我更新了我的环境的路径并添加了示例中没有的回调函数)。

我编译 Opencv 设置 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;
}

最佳答案

不能确认也不能否认这个问题是真实的,因为我的机器上有不同的设置(OpenCV 2.4.9 和 Qt 5.0.2)。

但我发现使用 CV_GUI_NORMAL 创建窗口会使应用程序崩溃。文档指出:

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.

我建议您暂时使用 CV_GUI_EXPANDED 创建窗口。

关于c++ - 在 opencv2.4.5 中使用 createButton(Qt gui 功能)段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16479776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com