How to make OpenCV Detect method safe for threads?

I call the following OpenCV method (Emgu CV wrapper), which detects faces in multiple threads at the same time:

IntPtr objects = CvInvoke.cvHaarDetectObjects( img.Ptr, haarObj.Ptr, stor.Ptr, scaleFactor, minNeighbors, flag, minSize); 

I get an AccessViolationException. The standard .NET lock is not acceptable here, since this method takes up almost the entire lifetime of the thread. Any ideas how to make this method work at the same time?

+4
source share
1 answer

The solution is to use internal multithreading in OpenCV. For this, OpenCV must be built with Intel TBB . Then, when the Detect method is called, it uses several threads internally.

+3
source

All Articles