Important: Please read the Qt Code of Conduct -

Best way to process cv::Mat 's in threads? intell tbb & QThread with event messaging or QThrealPoll ?

  • Hi,

    I am getting mp4 stream from my source permanently . And processing each frame .

    My current processing speed is almost 1/4 of the frame per second of the stream.

    So I can get benefit from using 4 or more threads to distribute the images for processing.

    I need a simple examle and direction to follow :

    1 - create 5 threads and move the process class to them and use signal / slot mechanism to send receive images/results ?

    2 - Create thread pool and use it ?

    3 - try to dive intel tbb

    any simple example very appreciated.


  • Lifetime Qt Champion


    You have to give more information about what you are doing.

    What are the properties of your video streams ? mp4 has a lot of possibilities.

    What processing are you doing ?
    Are you just showing the result or also recording it ?

  • @SGaist Hi,

    I am extracting frames as Mat object and making object detection on each frame. It is mostly mp4 sometimes rtsp streams.

    I am detection object and signalling the resulting coordinates and the detected square location.

  • Lifetime Qt Champion

    That I understood but extracting/processing frames from small sized streams is not the same as doing in for 4k streams.

    IIRC, OpenCV provides support for GPU processing, that might be an interesting option.

    QThreadPool might be more interesting as it will use as much threads as it makes sense.

    In any case, TBB might be a nice tool to learn.

  • @SGaist

    I am trying signal slot connection to distribute frames :) little stupid.

    one idea is the putting a shared QQueue and pulling frames from threads to process

    What is the best approach to wait Queue is not empty without wasting cpu time ?

  • Lifetime Qt Champion

    A QWaitCondition might be interesting.

Log in to reply