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
if you want to test :
In your test there is a bottleneck : grabbing an image
please don't post duplicate question
Thank you for your answer.
getNumThread() gives 5. What should I do with this information ?
With setNumThreads(1) I get CPU at 6%. I don't get why CPU is lower than with setNumThreads(2) or setNumThreads(4) ???
I know there is a bottleneck for the time (30ms) with grabbing an image. That's ok. My concern is really for the CPU usage.
Thank you very much,
Alex