Ask Your Question

Marco Leopardi's profile - activity

2016-09-27 06:24:48 -0600 received badge  Notable Question (source)
2016-09-27 06:24:48 -0600 received badge  Popular Question (source)
2014-03-25 06:50:31 -0600 commented answer imshow() not working in pthread MacOSX 10.9

Thanks for your answer, this help but do not solve the problem, because i'm now able to show the image, but if i call waitKey() it hangs like before, so there is still something wrong...

2014-03-25 06:23:04 -0600 commented answer imshow() not working in pthread MacOSX 10.9

Thanks for your answer, unfortunately i need this for a video stream, i cannot call it after thread termination. Can you propose something that might work? (i repeat in Ubuntu that code work flawlessly)

2014-03-25 06:20:38 -0600 received badge  Supporter (source)
2014-03-24 21:12:49 -0600 received badge  Editor (source)
2014-03-24 21:12:04 -0600 asked a question imshow() not working in pthread MacOSX 10.9

Hello guys, here's my problem: on ubuntu 12.04 LTS with OpenCV 2.4.8 the following code works at 100%, in MacOSX (10.9.1), lastest version of Xcode (5.1) and OpenCV 2.4.8 i get a fully blank image and the program hang, if i move the cursor over the blank image i can see it "spinning" and the only way to stop the program is pushing the stop button on the Xcode interface. Another info: imwrite() within a thread works perfectly.

 void* test(void* arg);

 int main( int argc, char **argv )
 {

 Mat I = imread("/Users/Admin/Documents/X-Code/TestOpenCV/coin1.jpg", 1);
 imshow("1", I);
 waitKey();

 Mat I2 = imread("/Users/Admin/Documents/X-Code/TestOpenCV/coin2.jpg", 1);

 pthread_t h;
 pthread_create(&h, NULL, test, (void*)&I2);
 pthread_join(h, NULL);


 return 0;
 }

void* test(void* arg){

    imwrite("/Users/Admin/Documents/debug.jpg", *((Mat*)arg)); // WORKS!
    imshow("2", *((Mat*)arg)); // HANGS ON MACOSX
    waitKey();

    return NULL;
}