[boost::thread] Function doesn't work out of the main thread
Hi Everyone I have a problem with threads which I don't understand. Well, it might be also connected to OpenCV, because it only occured while calling certain OpenCV functions so far: void callCvShowImage() { // OpenCV function to display an image in a window. cvShowImage("WindowName", image); } void callCvQueryFrame() { // OpenCV function to grab an image from a camera. frame = cvQueryFrame( capture ); } In a single thread program they work as expected: ... callCvShowImage(); //Works well callCvQueryFrame(); //Works well ... In the multithreaded version they don't work. In my oppinion, exactly the same thing should happen as above. But surprisingly the functions suddenly don't execute anymore. thrdXX.join() block the program forever... ... boost::thread thrdSI(&callCvShowImage()); thrdSI.join(); // the program never gets to this point ... ... boost::thread thrdQF(&callCvQueryFrame()); thrdQF.join(); // the program never gets till here ... Is there a way to fix this? I could also use the thread library from Microsoft if you think this would help... Obviously, I'm not much into threads. So please try to give me some examples together with your answer Thanks to you people once more Gabriel -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
Hi Gabriel,
The problem might be with the OpenCv (library?? - I don't know what it
is). Is OpenCV multithreaded? Some libraries are sensitive if you
initialize them on one thread but you make calls into it from
another....
To see if the boost::thread actually calls callCvShowImage, put a
breakpoint in callCvShowImage (or an ASSERT(false)) to see that the
function actually gets called.
Florin.
On 9/27/07, Gabriel Weilenmann
Hi Everyone
I have a problem with threads which I don't understand. Well, it might be also connected to OpenCV, because it only occured while calling certain OpenCV functions so far:
void callCvShowImage() { // OpenCV function to display an image in a window. cvShowImage("WindowName", image); }
void callCvQueryFrame() { // OpenCV function to grab an image from a camera. frame = cvQueryFrame( capture ); }
In a single thread program they work as expected:
... callCvShowImage(); //Works well callCvQueryFrame(); //Works well ...
In the multithreaded version they don't work. In my oppinion, exactly the same thing should happen as above. But surprisingly the functions suddenly don't execute anymore. thrdXX.join() block the program forever...
... boost::thread thrdSI(&callCvShowImage()); thrdSI.join(); // the program never gets to this point ...
... boost::thread thrdQF(&callCvQueryFrame()); thrdQF.join(); // the program never gets till here ...
Is there a way to fix this? I could also use the thread library from Microsoft if you think this would help... Obviously, I'm not much into threads. So please try to give me some examples together with your answer
Thanks to you people once more Gabriel
-- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Florin Trofin
-
Gabriel Weilenmann