OpenMP relies on #pragma directives. Telling compiler to parallelize loops / code blocks. Change of existing code is small compare to other methods.
_OPENMP will be defined by compiler that supports OpenMP.
Searching _OPENMP from source code discover current 'leftover' implementations here:
contrib
- selfsimilarity.cpp (disabled with #if 0 block)
- spinimages.cpp ( parallel for in computeSpinImages() )
features2D
- stardetector.cpp ( parallel for in icvStarDetectorComputeResponses() )
- system.cpp (getNumThreads(),...)
- cvboost.cpp ( parallel private in cvCreateMTStumpClassifier() )
- cvhaartraining ( uses CV_OPENMP instead of _OPENMP. Moreover, it's only enabled with MSVC and ICC compilers, not GCC )
- blobtrackanalysisior.cpp: parallel CvBlobTrackAnalysisIOR:Process()
- blobtrackingmsfg.cpp: parallel UpdateWeightsMS(), UpdateWeightsCC()
Experiment with haartraining
- Used Linux Build too take advantage of GCC 4 OpenMP support. There are OpenMP options in MSVC 2010 Express. But Microsoft webpage states there is no support. (http://msdn.microsoft.com/en-us/library/tt15eb9t.aspx)
- Recovered ENABLE_OPENMP in OpenCV 2.2 CMakeFiles by un-commenting such occurrences.
- Used CMake-GUI to configure build with ENABLE_OPENMP turned on.
- Called CvGetNumThreads() in haartraining.cpp to see if both CPU cores are available for use.
- Took half the time to perform the same training. The results are basically the same. Noticeable differences are the node-split threshold values differs from the 5th decimal points on.
- cvhaartraining.cpp uses a variant of the OPENMP define - CV_OPENMP. Training terminated with SegFault with that turned on.
so, in linux command instead of using opencv-haartraining -data data/cascade -vec data/muestra.vec
ReplyDelete-bg negativas.txt -nstages 30 -nsplit 2 -minhitrate 0.999
-maxfalsealarm 0.5 -npos 1500 -nneg 5000 -w 20 -h 20 -mem 1300
-mode ALL
command i should use the "opencv cvhaartraining" command if exist?
Hi Christian, the executable for haartraining is opencv_haartraining on Linux build. Use the same command for OpenMP build. The cvhaartraining.cpp is located in the haartraining module. And there is no need to change it.
ReplyDelete