I'm writing a multithreaded application (Linux, OpenCV 3.4), where the captured image is processed in parallel threads, each doing a different type of processing on a copy of the image. The two threads don't share any variables, so normally there is no concurrence problem.
One of the threads calculates a optical flow (using calcOpticalFlowPyrLK
), the other contains a connectedComponentsWithStats
function.
However, if during the processing the CPU usage reaches 100%, the calcOpticalFlowPyrLK
function hangs (it won't return).
If I comment either the calcOpticalFlowPyrLK
or the connectedComponentsWithStats
function (or disable one of the two threads), I don't have any hangups, so I suspect this might be the problem. The other OpenCV functions I use are not multithreaded AFAIK.
I compiled OpenCV with TBB support for parallelization (OpenCL, Cuda and OpenMP are not enabled). As my program is in C++/Qt, I use QThread for multithreading.
Do you have any ideas what can be the problem?