I was wondering if there is multi core support for the OpenCV library. I am experimenting with Haar cascading and it's pretty slow on my Raspberry 2 which would have four cores, but my application is currently running only on a single one.
Any ideas?
CascadedDetect
has multi core support.
Recompile OpenCV with the WITH_TBB
or WITH_OPENMP
(or any other threading framework supported by OpenCV) flag on to enable it.
I've had a brief look at the class CascadeClassifier
in modules\objdetect\src\cascadedetect.cpp
, and there seems to be a reasonable amount of implementation done with parallel_for_
, the built-in OpenCV multithreading facility.
Your mileage may vary, though. At least for the training phase there seems to be a lot of sequential code, as this thread in the OpenCV support forums suggests.
So if you can get OpenCV to compile with OpenMP (might be easiest to set up), TBB, or similar, you should be good to go.
Hope that helps!
Recently I had found a Simd Library, which has an implementation of HAAR and LBP cascade classifiers. It can use standard HAAR and LBP casscades from OpenCV. This implementation has SIMD optimizations with using of SSE4.1, AVX2 and NEON(ARM).
I haven't checked it for Raspberry 2, but I have checked it for Raspberry 3 (it works in ~2 times faster than original OpenCV implementation).