OpenCV  4.6.0
Open Source Computer Vision
Classes | Functions
Parallel backends API

Classes

class  cv::parallel::ParallelForAPI
 
class  cv::parallel::tbb::ParallelForBackend
 
class  cv::parallel::openmp::ParallelForBackend
 

Functions

void cv::parallel::setParallelForBackend (const std::shared_ptr< ParallelForAPI > &api, bool propagateNumThreads=true)
 Replace OpenCV parallel_for backend. More...
 
bool cv::parallel::setParallelForBackend (const std::string &backendName, bool propagateNumThreads=true)
 Change OpenCV parallel_for backend. More...
 

Detailed Description

API below is provided to resolve problem of CPU resource over-subscription by multiple thread pools from different multi-threading frameworks. This is common problem for cases when OpenCV compiled threading framework is different from the Users Applications framework.

Applications can replace OpenCV parallel_for() backend with own implementation (to reuse Application's thread pool).

Backend API usage examples

Intel TBB

OpenMP

Plugins support

Runtime configuration options:

Function Documentation

◆ setParallelForBackend() [1/2]

void cv::parallel::setParallelForBackend ( const std::shared_ptr< ParallelForAPI > &  api,
bool  propagateNumThreads = true 
)
Python:
cv.parallel.setParallelForBackend(backendName[, propagateNumThreads]) -> retval

#include <opencv2/core/parallel/parallel_backend.hpp>

Replace OpenCV parallel_for backend.

Application can replace OpenCV parallel_for() backend with own implementation.

Note
This call is not thread-safe. Consider calling this function from the main() before any other OpenCV processing functions (and without any other created threads).

◆ setParallelForBackend() [2/2]

bool cv::parallel::setParallelForBackend ( const std::string &  backendName,
bool  propagateNumThreads = true 
)
Python:
cv.parallel.setParallelForBackend(backendName[, propagateNumThreads]) -> retval

#include <opencv2/core/parallel/parallel_backend.hpp>

Change OpenCV parallel_for backend.

Note
This call is not thread-safe. Consider calling this function from the main() before any other OpenCV processing functions (and without any other created threads).