This project implements a real-time face recognition system using computer vision and deep learning techniques. The application identifies individuals based on a small dataset of three images and performs live video processing using a webcam. The purpose is to demonstrate the fundamentals of face recognition using pre-encoded face images.
Project Features
Real-Time Face Recognition: Captures live video feed from a webcam and processes each frame to detect and recognize faces.
Simple, Small Dataset: The system is trained on only three images: an image of the project owner, Lionel Messi, and Cristiano Ronaldo. These images serve as the “authorized” dataset for recognition.
Bounding Box and Label Display: Detected faces are highlighted with bounding boxes and labeled with the corresponding name or “Unknown” if the face is not recognized.
Efficient Frame Processing: The system optimizes frame processing by reducing the image size and skipping alternate frames to balance performance and speed.
Technical Details
Technology Stack: Python, OpenCV, NumPy, and the face_recognition library (built on dlib).
Face Encoding: Each image is pre-processed to generate a unique numerical face encoding, which is stored for later comparison.
Face Matching: During real-time processing, detected faces are matched with the stored encodings based on a distance threshold. If the distance is within the threshold, the face is considered a match.
Display: Uses OpenCV to draw bounding boxes around detected faces and labels them with the identified name.
How It Works
Image Preprocessing: The system reads the known images, extracts facial features, and encodes them into numerical vectors. For this project, the dataset consists of the following images:
My Image
Lionel Messi’s Image
Cristiano Ronaldo’s Image
These encodings serve as a reference for recognizing faces in the webcam feed.
Real-Time Face Detection: The application captures video frames from the webcam and scales them down to speed up processing. It converts the frames to RGB format for the face recognition library.
Face Recognition: For each frame:
Face Locations are detected.
Face Encodings are generated for the detected faces.
The system compares the detected face encodings with the known encodings and calculates the distance.
If a match is found (i.e., the distance is below a defined threshold), it displays the person’s name (e.g., “Messi” or “Ronaldo”). Otherwise, it labels the face as “Unknown.”
Output Display: Bounding boxes and labels are drawn around the recognized faces in real-time. This allows users to visually confirm the recognition results on their screen.
Demo
Conclusion
This project serves as a simple yet effective demonstration of face recognition using a small dataset. By focusing on a real-time application, it showcases the potential of computer vision and deep learning technologies in building intelligent recognition systems. Although trained on only three images, the system successfully distinguishes between authorized faces and unfamiliar faces.
Future Improvements
Expand Dataset: Increase the number of known faces to improve the system’s utility and test its scalability.
Fine-Tune the Model: Experiment with different distance thresholds to enhance recognition accuracy.
Add Logging and Alert Features: Record recognized faces or notify users of unrecognized individuals.
For the complete code and further details, you can visit the GitHub repository.