问题
I'm trying and failing to make opencv_traincascade
use multiple threads. The only documentation I can find says to "build OpenCV with TBB". I'm not sure if I'm failing to successfully build OpenCV with TBB, or whether there's some flag I need to set for opencv_traincascade
.
I've downloaded the OpenCV version 2.3.1 windows superpack and tbb40_20111003oss_win.zip
, which I extracted to C:\tbb40_20111003oss
. I then generated VC8 .sln
and .proj
files using CMake, setting
WITH_TBB: ON
TBB_INCLUDE_DIR:PATH=C:\tbb40_20111003oss\include
TBB_LIB_DIR:PATH=C:/tbb40_20111003oss/lib/intel64/vc8
OpenCV then builds without errors, but when I run opencv_traincascade
it's singlethreaded. Does anyone know what I'm doing wrong?
回答1:
If you are on Mac you can do this with homebrew:
brew tap homebrew/science
brew install opencv --with-tbb
Or if you have already installed with homebrew:
brew uninstall opencv
brew install opencv --with-tbb
Also, the info
command tells you about other flags you might be interested in, e.g. --with-java
brew info opencv
回答2:
I know this is an old thread but I think the problem is that you are using Traincascade with Haart feature insdead of using with the LBP features which uses integer instead of floating point and are working 3 times faster.
See the comment in this question for more information from the author about this. Quick summary: Haart training is difficult to paralelize but LBP is much easier and take advantage of a lot of processors.
Hope it help!
回答3:
Try setNumThreads(), with the number of your processor cores as parameters. There is a helper function to find the optimum number of threads (equals the number of cores), but I cannot remember it.
And make sure you also rebuild the train_cascade exe
回答4:
For linux, do:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON BUILD_TBB=ON ..
回答5:
Instructions here: http://devel-open.blogspot.com.ar/2012/06/instalando-opencv-240-en-ubuntu.html
回答6:
After building the tbb binaries, make sure your path is correctly directing your executable to the tbb dlls. It is possible that you are loading the non-tbb dlls (this happened to me) and these will provide no multithreading.
回答7:
Also, one touch point is the installation of Intel TBB on the system:
$ sudo apt-get install libtbb-dev
来源:https://stackoverflow.com/questions/7994261/how-do-i-build-opencv-with-tbb