Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow face detection on OpenCV?

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.

like image 949
Matthieu Napoli Avatar asked Sep 21 '10 19:09

Matthieu Napoli


People also ask

How accurate is OpenCV face detection?

Use OpenCV's DNN face detector as a good balance. As a deep learning-based face detector, this method is accurate — and since it's a shallow network with an SSD backbone, it's easily capable of running in real-time on a CPU. Furthermore, since you can use the model with OpenCV's cv2.

How can I improve my face detection?

In a study published today, UNSW scientists have shown focusing on someone's ears and facial marks improves accuracy by 6 percent. This is a significant increase because even experienced face identification staff can get as many as one in two wrong when it comes to comparing photos with unfamiliar faces.

Which one is better for face recognition OpenCV or TensorFlow?

Every reason points towards TensorFlow as the better framework for building face detection and recognition. Still, we must know how the TensorFlow face detector works in building models.

Is Mtcnn the best face detection?

Com- pared to all methods above, MTCNN has the best and in- credibly high accuracy. Although it takes some time for training, we can save time by using pre-trained model and keep the relatively high accuracy. MTCNN even supports for real time face detection. Hence, MTCNN is a very good method for face detection.


2 Answers

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.

like image 50
Krish Avatar answered Sep 22 '22 05:09

Krish


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.

like image 24
Barney Szabolcs Avatar answered Sep 22 '22 05:09

Barney Szabolcs