Threading issue
-
Hi all, Recently, I am trying openCV to detect the face. All the methods work well. Now I want to compare all the methods at the same time, that means i have to use multi thread to archieve this purpose. Here is my code In my form (Form1.h), i declared :
private: System::Threading::Thread^ trd;
and initialized the thread:
trd = gcnew Thread( gcnew ThreadStart( this->compareAlg));
and this is the compareAlg function:
private: static System::Void compareAlg ()
{
SCM *objSCM = new SCM ();
VAJ *objVAJ = new VAJ();
// MHI *objMHI = new MHI();objVAJ ->showFaceDetect\_Cam("Resource\\\\face.xml"); objSCM ->showFace\_SkinDetect\_Cam(); Thread::Sleep (0); //objMHI ->showFace\_MHI (); }
i also used a button to start the thread:
private: System::Void btnCompare_Click(System::Object^ sender, System::EventArgs^ e) {
trd->Start ();
}The code compile well but the methods (showFaceDetect_Cam and showFace_SkinDetect) run sequently. What i want is the output of these methods appear at the same time on the screen. Can you suggest some advices, please? The thread code is found from http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx Thanks
-
Hi all, Recently, I am trying openCV to detect the face. All the methods work well. Now I want to compare all the methods at the same time, that means i have to use multi thread to archieve this purpose. Here is my code In my form (Form1.h), i declared :
private: System::Threading::Thread^ trd;
and initialized the thread:
trd = gcnew Thread( gcnew ThreadStart( this->compareAlg));
and this is the compareAlg function:
private: static System::Void compareAlg ()
{
SCM *objSCM = new SCM ();
VAJ *objVAJ = new VAJ();
// MHI *objMHI = new MHI();objVAJ ->showFaceDetect\_Cam("Resource\\\\face.xml"); objSCM ->showFace\_SkinDetect\_Cam(); Thread::Sleep (0); //objMHI ->showFace\_MHI (); }
i also used a button to start the thread:
private: System::Void btnCompare_Click(System::Object^ sender, System::EventArgs^ e) {
trd->Start ();
}The code compile well but the methods (showFaceDetect_Cam and showFace_SkinDetect) run sequently. What i want is the output of these methods appear at the same time on the screen. Can you suggest some advices, please? The thread code is found from http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx Thanks
bubuzzz wrote:
The code compile well but the methods (showFaceDetect_Cam and showFace_SkinDetect) run sequently.
That's because you call them sequentially. If you want them to run in parallel, you need a separate thread for each. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
bubuzzz wrote:
The code compile well but the methods (showFaceDetect_Cam and showFace_SkinDetect) run sequently.
That's because you call them sequentially. If you want them to run in parallel, you need a separate thread for each. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: