Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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;

}

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);

arg);

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

{

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

waitKey();

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

1);

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

NULL);

return 0; }

}

void* test(void* arg){

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

 return NULL;
}

}