OpenCV Multithreading error [using Qt]

Till now I have learnt one thing, there's something wrong I'm doing with OpenCV, Qt has no role in the error

I'm trying to run two methods in different threads, but it gives me error:

[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 !!

EDIT: 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);
}

Now the error I get is:

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.

Answers


To all concerned:

fix Jaydeep's problems

[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.

and

error: ‘XInitThreads’ was not declared in this scope

by linking X11, including xlib, and calling XInitThreads.

Example for including xlib and calling XInitThreads:

// main.cpp
#include <thread> 
#include <X11/Xlib.h>

int main() {
   XInitThreads();
   // . . . 
}

Example for linking:

g++ main.cpp -o my_program -std=c++0x -pthread -lX11 /* -pthread if you're on Linux */

Of course, don't forget to link the other files that may be necessary to your application


Thread closed.

I don't know why the problem occurred but I have got it fixed..

Thanks to RA. for showing great interest :)


Need Your Help

Assetic CSS not respected in Symfony2

css symfony assetic

I'm using Assetic to load CSS files for my Symfony2 project. The CSS loads properly, I can view it when I inspect element/sources in Chrome, but the page is still not styled. The only thing in the

Mod_Rewrite Redirect

html mod-rewrite redirect http-status-code-301

I'm having a problem with mod_rewrite on my hosting. All is working fine, but I changed my directories organization and so now all pages Google indexed before the change have the wrong extension (I