Jay*_*nki 0 qt multithreading opencv
直到现在我已经学到了一件事,我在用OpenCV做错了,Qt在错误中没有任何作用
我试图在不同的线程中运行两个方法,但它给了我错误:
[xcb]出队时队列中的未知请求
[xcb]很可能这是一个多线程客户端,并且没有调用
XInitThreads [xcb]正在中止,对不起.
Blurring_Images:../../ src/xcb_io.c:178:dequeue_pending_request:断言`!xcb_xlib_unknown_req_in_deq'失败.
该计划意外完成.
这是我的代码:
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);
}
Run Code Online (Sandbox Code Playgroud)
如果我注释掉一个电话(如下所示),它运行正常
void Dialog::blurImages(int b)
{
QtConcurrent::run(this,&Dialog::homogenour_blur,b);
//QtConcurrent::run(this,&Dialog::gaussianBlur,b);
}
Run Code Online (Sandbox Code Playgroud)
这真是很烦人,请帮忙!
编辑: 我没有调用showImage(),而是将其替换为真正的OpenCV调用(见下文):
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);
}
Run Code Online (Sandbox Code Playgroud)
现在我得到的错误是:
原始映像:X服务器上的致命IO错误11(资源暂时不可用):0.
原始映像:X服务器上的致命IO错误0(成功):0.
致命错误:破坏后访问全局静态'KGlobalSettings*s_self()'.定义为../../kdeui/kernel/kglobalsettings.cpp:190
该程序意外完成.
对所有有关方面:
解决Jaydeep的问题
[xcb]出队时队列中的未知请求
[xcb]这很可能是一个多线程客户端,而且还没有调用XInitThreads
[xcb]中止,对不起.
和
错误:未在此范围内声明'XInitThreads'
通过链接X11(包括xlib)和调用XInitThreads.
包含xlib和调用XInitThreads的示例:
// main.cpp
#include <thread>
#include <X11/Xlib.h>
int main() {
XInitThreads();
// . . .
}
Run Code Online (Sandbox Code Playgroud)
链接示例:
g++ main.cpp -o my_program -std=c++0x -pthread -lX11 /* -pthread if you're on Linux */
Run Code Online (Sandbox Code Playgroud)
当然,不要忘记链接您的应用程序可能需要的其他文件
| 归档时间: |
|
| 查看次数: |
5256 次 |
| 最近记录: |