Is OpenCv already streaming?

I want to use OpenCV to record video and send it as a stream. I'm new and I need to know if OpenCV is blocking the main thread or is it threading itself?

I read the OpenCV documentation (2.4.9) and I could not find the answer.

Thanks for reading.

+7
c ++ multithreading opencv
source share
3 answers

OpenCV can generate threads when a function is called. However, all work is done before the control is returned to the calling thread . For a number of reasons, asynchronous processing would add a significant extra bit of complexity. (Consider, for example: how does your program know when the calculation was done?) This would also lead to some undesirable overhead if the program did not need to be asynchronous.

You can do asynchronous processing yourself with minimal effort, but the C ++ 11 streaming API .

+5
source share

OpenCV can be built with OpenMP support to force computing functions to use all available kernels on your computer. It can also be built with OpenCL and CUDA. In addition, it has various SIMD optimization flags.

If you do not create it with such support, it will work with a single thread.

In both versions, calling the OpenCV function blocks the startup thread until it computes all operations. This is true even when offloading computing to a GPU.

+3
source share

OpenCV parallel_for operations create multiple threads for operation. It creates a thread pool and distributes work through it.

The number of threads is determined by the setNumThreads function. Set it to zero for consistent operation. [This changes based on the thread library with which opencv is built with. For some, this is 1]

Note. I had some threading issues when I was managing my own thread pool.

0
source share

All Articles