我试图在几个网站上查询我的问题,但仍然没有答案。 我的问题看起来像http://opencv-users.1802565.n2.nabble.com/Runtime-error-for-createTrackbar-in-control-panel-td7550203.html
我尝试使用Qt集成在OpenCV窗口中创建控制面板,如OpenCV Document示例所示: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;
}
}
你有什么想法吗?
答案 0 :(得分:1)
我不知道这个答案在这段时间后是否有用,但你需要使用空字符串而不是空指针。
尝试:
createTrackbar(num1, "", &val1 , 255, NULL);