Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. is it possible to use QtConcurrent::mapped inside a QThread ?

is it possible to use QtConcurrent::mapped inside a QThread ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 481 Views
  • 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.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by
    #1

    Hi,

    I want to process my my opencv captured frames in 4 threads.

    one producer (opencv capture ) is very fast

    four worker (detection cpu based) slower than producer (4 times almost)

    I created producer thread and moved a thread.

    1 - Can I create a QtConcurred::mapped in this producer Thread ?

    what is the best practices for this multithreaded video processing in Qt ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, yes you can.

      You have to benchmark the processings you need before designing a pipeline for your video application.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RahibeMeryem
        wrote on last edited by RahibeMeryem
        #3

        @SGaist

        I have below error:

        struct frames_facePhotos
            {
                cv::Mat frames;
                cv::Mat face_photo;
            };
        QVector<frames_facePhotos> framesVector;
        
                   frames_facePhotos process_request;
        
                    process_request.face_photo = face_photo;
                    process_request.frames = image;
                    framesVector.push_back (process_request);
                    cap>>image;
                    process_request.frames = image;
                    framesVector.push_back (process_request);
        
                    auto res  = QtConcurrent::mapped(framesVector , &detecFaceModifyFrames );
        
        void FaceDetector::detecFaceModifyFrames(frames_facePhotos frames_faces)
        {
            int frame_count = 111;
        
        
                QString find_face = bc_face->findFace(frames_faces.frames, frames_faces.face_photo,frame_count);
        
        
        
        //    return frames_faces;
        
        }
        
        
        1. Error
          ../BC_DETECTOR/face_detector.cpp:165:60: error: must explicitly qualify name of member function when taking its address
          auto res = QtConcurrent::mapped(framesVector , &detecFaceModifyFrames );
          ^~~~~~~~~~~~~~~~~~~~~~
          FaceDetector::

        2nd Error
        /Users/xx/Qt5.12.1/5.12.1/clang_64/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:175:19: error: no matching function for call to object of type 'QtConcurrent::MemberFunctionWrapper1<void, FaceDetector, FaceDetector::frames_facePhotos>'
        *result = map(*it);
        ^~~

        when I change to :

                    auto res  = QtConcurrent::mapped(framesVector , &FaceDetector::detecFaceModifyFrames );
        
        

        first error gone but second is there.

        jsulmJ 1 Reply Last reply
        0
        • R RahibeMeryem

          @SGaist

          I have below error:

          struct frames_facePhotos
              {
                  cv::Mat frames;
                  cv::Mat face_photo;
              };
          QVector<frames_facePhotos> framesVector;
          
                     frames_facePhotos process_request;
          
                      process_request.face_photo = face_photo;
                      process_request.frames = image;
                      framesVector.push_back (process_request);
                      cap>>image;
                      process_request.frames = image;
                      framesVector.push_back (process_request);
          
                      auto res  = QtConcurrent::mapped(framesVector , &detecFaceModifyFrames );
          
          void FaceDetector::detecFaceModifyFrames(frames_facePhotos frames_faces)
          {
              int frame_count = 111;
          
          
                  QString find_face = bc_face->findFace(frames_faces.frames, frames_faces.face_photo,frame_count);
          
          
          
          //    return frames_faces;
          
          }
          
          
          1. Error
            ../BC_DETECTOR/face_detector.cpp:165:60: error: must explicitly qualify name of member function when taking its address
            auto res = QtConcurrent::mapped(framesVector , &detecFaceModifyFrames );
            ^~~~~~~~~~~~~~~~~~~~~~
            FaceDetector::

          2nd Error
          /Users/xx/Qt5.12.1/5.12.1/clang_64/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:175:19: error: no matching function for call to object of type 'QtConcurrent::MemberFunctionWrapper1<void, FaceDetector, FaceDetector::frames_facePhotos>'
          *result = map(*it);
          ^~~

          when I change to :

                      auto res  = QtConcurrent::mapped(framesVector , &FaceDetector::detecFaceModifyFrames );
          
          

          first error gone but second is there.

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @RahibeMeryem Try to use lambda instead of detecFaceModifyFrames. detecFaceModifyFrames is a non static method and cannot be used without class instance.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • R Offline
            R Offline
            RahibeMeryem
            wrote on last edited by
            #5

            @jsulm

            when I think that I started to capture C++ something like this happening. as a being decent java girl its make me crazy :)

            how can I write its as a lamba ?

            jsulmJ 1 Reply Last reply
            0
            • R RahibeMeryem

              @jsulm

              when I think that I started to capture C++ something like this happening. as a being decent java girl its make me crazy :)

              how can I write its as a lamba ?

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @RahibeMeryem

              auto res  = QtConcurrent::mapped(framesVector , [this](frames_facePhotos frames_faces) {
                      detecFaceModifyFrames(frame_faces);
                  });
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved