Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

setNumThreads

Hello,

I have questions about cv::setNumThreads(int nthreads) that I don't understand even by reading the documentation (with OpenCV 2.4 on Windows).

1- First of all, what should I put as nthreads ? I want my program to work on different computers so I don't want to hardcode a value (ex. 2). Can I set a number that will take all the available cores ?

2- What if I have two threads running my program where there is OpenCV code in both of them. Should I declare this in each thread ? Will it work even with my two threads ?

3- a) With no cv::setNumThreads(), CPU is 20%. b) With cv::setNumThreads(2), CPU is 10%. c) With cv::setNumThreads(4), CPU is 17% (???)

For information, I simply grab an image and apply an optical flow.

Thank you so much,

Alex