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. why there is difference between standalone vs QTthread app which is threade one is slower?
QtWS25 Last Chance

why there is difference between standalone vs QTthread app which is threade one is slower?

Scheduled Pinned Locked Moved Unsolved General and Desktop
opencv cppdnn threads
3 Posts 3 Posters 458 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 have a mtcnn face detection app which is like :

    double t = (double) cv::getTickCount();
    auto faceInfo = detector.Detect_mtcnn(image, minSize, threshold, factor, 3); std::cout << "Detect" << " time is: " << (double) (cv::getTickCount() - t) / cv::getTickFrequency() << std::endl;
    

    which is running around 200msec for each frame if I run this pure c++ and no threads.

    When I put this a Qt thread :

        detector_thread = new QThread;
        face_detector = new FaceDetector;
        face_detector->moveToThread(detector_thread);
        connect(detector_thread , SIGNAL(started()) , face_detector, SLOT(requestWork()));
        connect(face_detector , &FaceDetector::frame_Changed ,  this , &MainWindow::refreshFrame);
        connect(face_detector , &FaceDetector::face_found_sig , this , &MainWindow::updateLog);
        connect(face_detector , &FaceDetector::face_photo_sig , this , &MainWindow::update_face_photo);
    

    and runned the detection times incrased to the 340msec ! . the code is same code as above.

    Detection using the opencv dnn :

    cv::dnn::blobFromImages
    
    Best
    
    
    
    jsulmJ 1 Reply Last reply
    0
    • R RahibeMeryem

      Hi I have a mtcnn face detection app which is like :

      double t = (double) cv::getTickCount();
      auto faceInfo = detector.Detect_mtcnn(image, minSize, threshold, factor, 3); std::cout << "Detect" << " time is: " << (double) (cv::getTickCount() - t) / cv::getTickFrequency() << std::endl;
      

      which is running around 200msec for each frame if I run this pure c++ and no threads.

      When I put this a Qt thread :

          detector_thread = new QThread;
          face_detector = new FaceDetector;
          face_detector->moveToThread(detector_thread);
          connect(detector_thread , SIGNAL(started()) , face_detector, SLOT(requestWork()));
          connect(face_detector , &FaceDetector::frame_Changed ,  this , &MainWindow::refreshFrame);
          connect(face_detector , &FaceDetector::face_found_sig , this , &MainWindow::updateLog);
          connect(face_detector , &FaceDetector::face_photo_sig , this , &MainWindow::update_face_photo);
      

      and runned the detection times incrased to the 340msec ! . the code is same code as above.

      Detection using the opencv dnn :

      cv::dnn::blobFromImages
      
      Best
      
      
      
      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @RahibeMeryem Well, you create a QThread instance, then you create a FaceDetector instance on heap (heap allocation is not cheap!) and then you call moveToThread - all of these costs time.
      It would be especially interesting to know how heavy FaceDetector constructor is.
      Why don't you use already existing FaceDetector instance like you do in the version without thread to have a more valid comparision?

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

      1 Reply Last reply
      1
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        What does requestWork() do? How is the thread acquiring new frames?

        (Z(:^

        1 Reply Last reply
        1

        • Login

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