Important: Please read the Qt Code of Conduct -

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

  • 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;
        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 :


  • Lifetime Qt Champion

    @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?

  • Moderators

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

Log in to reply