
Face Recognition and Face Detection series in Python
- Detecting Faces with 20 lines in Python
- Face Recognition with 20 lines in Python
- Detecting Facial Features with 20 lines in Python
- Facial Features and Face Recognition with 20 lines in Python
- Performance improvements with code
- Resize the camera input with OpenCV
- Working with Haar Cascades and OpenCV
- Detect and blur faces 😁 using haar cascades
- Detect and blur faces 😁 using DNN
Hi!
And after yesterday’s post I realize that the code is working, but there is room for performance improvement. So, I went back to my 1st sample, the one for face detection and I added some code to get some times for Frames per Second (FPS).
In my initial code, the app was working processing almost 6 FPS. Then I started to read the code and think on improvements and I manage to get an amazing +30FPS.

So, before moving forward, I want to remark this StackOverflow post that quickly pointed me in the easiest way to do a StopWatch in Python.
My original code, was this one:
And then, I realize that I may use some of the OpenCV functions to increase the face detection process. I really don’t need to process a full HD image (1920 x 1080), I may resize the frame to a quarter size and work with this. That’s how, based on some of the samples, I got the following code:
The line 12 perform the initial resize and then I recalculate back the positions before drawing the face frame. This process works almost 6 times faster than the original one.
I’ll continue improving the code and samples, and sharing my learning path !
Happy Coding!
Greetings @ Burlington
El Bruno
Resources
- Anaconda Distribution, https://www.anaconda.com/distribution/
- Visual Studio Code, https://code.visualstudio.com/
- Adam Geitgey, https://github.com/ageitgey/face_recognition
- StackOverflow, fps – how to divide count by time function to determine fps
2 comments