OpenCV多线程错误[使用Qt] [英] OpenCV Multithreading error [using Qt]
问题描述
到目前为止,我已经了解到一件事,我在使用OpenCV时出错了,Qt在错误中没有任何作用
我试图在不同的线程中运行两个方法,但这给了我错误:
I'm trying to run two methods in different threads, but it gives me error:
[xcb]出队时队列中的未知请求
[xcb]这很可能是多线程客户端,尚未调用XInitThreads
[xcb]正在中止,对此感到抱歉.
Blurring_Images:../../src/xcb_io.c:178:dequeue_pending_request:断言'!xcb_xlib_unknown_req_in_deq'失败.
该程序意外完成.
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
Blurring_Images: ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
The program has unexpectedly finished.
这是我的代码:
Here's my code:
void Dialog::blurImages(int b)
{
QtConcurrent::run(this,&Dialog::homogenour_blur,b);
QtConcurrent::run(this,&Dialog::gaussianBlur,b);
}
void Dialog::homogenour_blur(int b)
{
cv::blur(img,img1,cv::Size(b,b));
showImage("Homogenous Blur",img1);
}
void Dialog::gaussianBlur(int b)
{
cv::GaussianBlur(img,img2,cv::Size(b,b),b);
showImage("Gaussian Blur",img2);
}
而如果我注释掉一个电话(如下所示),则运行正常
whereas if i comment out one call(shown below), it runs fine
void Dialog::blurImages(int b)
{
QtConcurrent::run(this,&Dialog::homogenour_blur,b);
//QtConcurrent::run(this,&Dialog::gaussianBlur,b);
}
这真是令人讨厌的家伙,请帮忙!
It's really annoying guys, please help !!
我没有调用showImage(),而是将其替换为实际的OpenCV调用(见下文):
Instead of calling showImage(), I replaced it with the actial OpenCV call(see below):
void Dialog::homogenour_blur(int b)
{
cv::blur(img,img1,cv::Size(b,b));
//showImage("Homogenous Blur",img1);
cv::imshow("Homogenous Blur",img1);
}
void Dialog::gaussianBlur(int b)
{
cv::GaussianBlur(img,img2,cv::Size(b,b),b);
//showImage("Gaussian Blur",img2);
cv::imshow("Gaussian Blur",img2);
}
现在我得到的错误是:
原始图像:X服务器:0上的致命IO错误11(资源暂时不可用).
原始图像:X服务器:0上的致命IO错误0(成功).
致命错误:销毁后访问了全局静态'KGlobalSettings * s_self()'.定义于../../kdeui/kernel/kglobalsettings.cpp:190
该程序意外完成.
Original Image: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.
Original Image: Fatal IO error 0 (Success) on X server :0.
Fatal Error: Accessed global static 'KGlobalSettings *s_self()' after destruction. Defined at ../../kdeui/kernel/kglobalsettings.cpp:190
The program has unexpectedly finished.
推荐答案
线程已关闭.
我不知道为什么会出现此问题,但是我已经解决了..
I don't know why the problem occurred but I have got it fixed..
感谢RA.表现出极大的兴趣:)
Thanks to RA. for showing great interest :)
这篇关于OpenCV多线程错误[使用Qt]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!