Function opencv::core::set_num_threads
source · pub fn set_num_threads(nthreads: i32) -> Result<()>
Expand description
OpenCV will try to set the number of threads for subsequent parallel regions.
If threads == 1, OpenCV will disable threading optimizations and run all it’s functions sequentially. Passing threads < 0 will reset threads number to system default. The function is not thread-safe. It must not be called in parallel region or concurrent threads.
OpenCV will try to run its functions with specified threads number, but some behaviour differs from framework:
TBB
- User-defined parallel constructions will run with the same threads number, if another is not specified. If later on user creates his own scheduler, OpenCV will use it.OpenMP
- No special defined behaviour.Concurrency
- If threads == 1, OpenCV will disable threading optimizations and run its functions sequentially.GCD
- Supports only values <= 0.C=
- No special defined behaviour.
§Parameters
- nthreads: Number of threads used by OpenCV.
§See also
getNumThreads, getThreadNum