Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Threading issue

Threading issue

Scheduled Pinned Locked Moved Managed C++/CLI
comxmlhelpquestionlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bubuzzz
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • B bubuzzz

      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

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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:

      B 1 Reply Last reply
      0
      • M Mark Salsbery

        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:

        B Offline
        B Offline
        bubuzzz
        wrote on last edited by
        #3

        thank you very much

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups