OpenCV in parallel threads

asked 2018-10-29 09:34:52 -0600

kbarni gravatar image

updated 2018-10-29 11:28:18 -0600

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.]

EDIT The problem persists if OpenCV is compiled without TBB support...

Do you have any ideas what can be the problem?

edit retag flag offensive close merge delete

Comments

1

Can you specify compiler, exact version (if it's 3.4.3 ect), did you build it yourself from source, exact compiler flags.

If possible, can you make a tiny sample that produces the same result?

Tetragramm gravatar imageTetragramm ( 2018-10-29 16:59:49 -0600 )edit