Pergunta

I compiled and installed OpenCV (last version from the SVN) on Mac Os X (this is maybe the source of the problem).

The sample works, but the face detection algorithm seems slow to me. The detection time for a face is around 400ms (I just used the example included). The FPS is then quite low.

On youtube and all, I see super-smooth video with real time face detection (even on the iPhone) so I feel confuse. I remember it being even faster on my old Windows PC.

Is 400 ms a correct detection time ?

Note : my Macbook is not old (2009) and everything runs fine on it. I use the iSight webcam (integrated webcam). I have just one face (my face) on the webcam. And it is around the same time if there is no face.

Foi útil?

Solução

What is the size of the input image. I am guessing 640x480. Generally people who post YouTube videos resize the image to 160x120. IN full resolution of 640x480 it is very difficult to get more than 2-3 fps. Try to send 160x120 image. You should be getting at least 10fps.

Outras dicas

Adding to the previous answers:

you can also speed things up by setting the Max and most importantly the Min size for detectMultiScale.

[Also, as the previous answers say, heavy scaling-down is in order as Haar detector uses very simple features (for the relations of upto 6 pixels; on larger scales you add up rectangle-like areas as if it was just one pixel). On standard mac/mbp2011 I could get around 60fps that is more than enough.]

For an even better speedup you could also eliminate non-changing areas, using say templateMatching.

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), so it works in 2-3 times faster then original OpenCV implementation.

I was having the same problem, on a Quad Core machine with 4GB RAM was 500ms per detection, however I've noticed there is a Scale option....getting this to:

./facedetect --scale=4

I get detection rates of <20ms

Hope that helps,

Keukpa

When running on image, you should downscale to certain limits. In case of videos, along with Face detection, you can also try tracking. You can do face detection every alternate frames and track the position of face in between frames.

Also, OpenCv supports use of Canny to discard regions where chances of finding Face is none.

Does anybody know why face detection in OpenCV 3.4.5 is so slow? I think it was a lot faster in version 3.4.3 I have not done any benchmarking but it seemed a lot faster.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top