gpt4 book ai didi

c++ - 在OpenCV中使用Qt控制面板函数报错NULL指针

转载 作者:太空宇宙 更新时间:2023-11-03 23:00:38 26 4
gpt4 key购买 nike

我试着在几个网站上用谷歌搜索我的问题,但仍然没有答案。我的问题是这样的 http://opencv-users.1802565.n2.nabble.com/Runtime-error-for-createTrackbar-in-control-panel-td7550203.html

我尝试使用 Qt 集成在 OpenCV 窗口中创建控制面板,如 OpenCV 文档示例所示:http://docs.opencv.org/modules/highgui/doc/qt_new_functions.html

通过这个函数,它应该在图像窗口(用'imshow()')和控制面板(在其他窗口中,称为控制面板)之间分开。

但是,当运行代码 'createTrackbar(num1, NULL, &val1 , 255, NULL);' 时它不起作用显示错误消息“空指针”。但是,如果我将参数更改为窗口名称,它就可以工作了!

我的代码是这样的:

#include <...opencv.hpp>
#include <...highgui.hpp>

char* num1 = "testTrack";
int val1 = 100;
const string mainwin = "show";

int main()
{
while (true)
{
frame = capture();
createTrackbar(num1, NULL, &val1 , 255, NULL);
process_frame = image_processing(frame);
imshow(mainwin, process_frame);

// [Exit the system]
if (condition)
break;
}
}

你有什么想法吗?

最佳答案

我不知道这个答案在这么久之后是否有用,但你需要使用空字符串而不是空指针。

尝试:

 createTrackbar(num1, "", &val1 , 255, NULL);

关于c++ - 在OpenCV中使用Qt控制面板函数报错NULL指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19442523/

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