I’ve write a lot about how to use AI models in C# to perform tasks like Face recognition, speech analysis, and more. During the Chicago CodeCamp, someone ask me about how to perform Face Recognition in Python. I didn’t have any working sample to showcase this, and I failed in try to write a 2 min app. So I added this into my ToDo list.
For this demo I’ll use Anaconda as the base Python distribution and Visual Studio Code as the code editor. There are several packages to perform face detection in Python. I’ll use a mix between OpenCV and Adam Geitgey Face Recognition package to use the camera and detect and recognize faces.
I’ll start by installing some packages to use in python app: dlib, openCV and face_recognition
"C:/Program Files (x86)/Microsoft Visual Studio/Shared/Anaconda3_86/python.exe" -m pip install dlib --user "C:/Program Files (x86)/Microsoft Visual Studio/Shared/Anaconda3_86/python.exe" -m pip install face_recognition --user "C:/Program Files (x86)/Microsoft Visual Studio/Shared/Anaconda3_86/python.exe" -m pip install opencv-python --user
And, the first step will be to detect faces and draw frames around them. All of this in 20 lines of code
When we run the app, we will see the camera feed and frames around the detected faces. In my next post I’ll add some extra code to perform face recognition.
Greetings @ Toronto
- Anaconda Distribution, https://www.anaconda.com/distribution/
- Visual Studio Code, https://code.visualstudio.com/
- Adam Geitgey, https://github.com/ageitgey/face_recognition