ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.28k stars 13.48k forks source link

Lag between Frames and getting error Locations #437

Open dizyant opened 6 years ago

dizyant commented 6 years ago

I am running code through WebCam live. Code runs fine until it detects a face. As soon as a face is detected and rectangle is formed around that face, there comes lag of 1-1.5 secs for displaying next frame. Looks as if someone paused the video for a moment. One more problem: It is not giving me face Locations or Encodings for faces with spectacles. Help me with these problems.

band79 commented 6 years ago

I have the same problem, the face_recognition.face_encodings line takes 0.6 seconds here (Windows 10, Python 3.6.5, face_recognition 1.2.2).

@ageitgey How did you make your Will Farrell/Chad Smith example so fast?

ageitgey commented 6 years ago

First, if you are generating a gif or video, you don't have to process it in real time. So there's no delay in the case of the Chad Smith example because it wasn't generated in real time.

But that's not to say you can't do it in real time. You can improve speed lots ways - like reducing input image size, scaling detected faces down to a fixed max size, using a more powerful CPU, using a GPU, trying to parallelize some calculations over multiple cpus, making sure your code is generally efficient, etc.

For example, making sure you are using a modern CPU with AVX extensions and making sure all your libraries are compiled with support for AVX is important. Same with making sure you have a good BLAS library installed. But it's really hard to give suggestions to people on different operating systems and different CPU versions of exactly how to make sure they are compiling things in the optimal way.

band79 commented 6 years ago

Reducing the input image size doesn't help much. My webcam is already at 640x480 and I can go down to cv2.resize - fx=0.12, fy=0.12, but it's still laggy.

There must be a general speed bottleneck, when one single call of the face_encodings method takes 0.6 second on a Intel i7 processor (AVX). One of the leading face recognition companies CyberExtruder guarantees 25 million facial compares per second per single 3.4 GHz core.

Mars212 commented 6 years ago

the same problem! any solution?