Facial recognition module for the CrowdEye Smart Passenger Monitoring System.
This Python application performs real-time identification using webcam video feed and a directory of known face images.
β
Detects faces using webcam (OpenCV)
β
Recognizes known individuals using deep learning encodings
β
Marks labels directly on the live video stream
β
Shows Unknown for unmatched faces
β
Easy to update β just add images to known_faces/
β
Supports multiple people in a single frame
facial_recognition-for-CrowdEye/ βββ facial_recognition.py # Main script βββ known_faces/ # Image database of known users
π To add a new person, simply drop 1 or more of their photos into
known_faces/.
Webcam Feed β Face Detection β Face Encoding β Matching β Display with Labels
A 128-dimensional facial encoding is generated and compared against known encodings in memory.
Ensure Python 3.8+ is installed.
Install dependencies:
pip install --upgrade pip
pip install opencv-python face_recognition numpy
β οΈ If installation errors occur for face_recognition, install CMake & C++ Build Tools:
β’ Windows: Visual Studio Build Tools
β’ macOS/Linux: cmake g++ packages
βΈ»
βΆοΈ Run the Program
python facial_recognition.py
β’ A webcam window opens
β’ Press Q to exit
βΈ»
π€ Adding New Faces
Add images into known_faces/ using either method:
β
All images in the root folder
known_faces/
βββ Aeshan_1.jpg
βββ Aeshan_2.jpg
βββ John.jpg
OR
β
Separate folders per person
known_faces/
βββ Aeshan/
β βββ 1.jpg
β βββ 2.jpg
βββ John/
βββ 1.jpg
Better results come from front-facing images with good lighting.
βΈ»
βοΈ Performance & Matching Settings
You can modify these inside the script:
Config Purpose
tolerance Lower = stricter match (0.4β0.6 recommended)
model hog (CPU-fast) or cnn (GPU-accurate)
Frame resize Improves FPS during livestream
βΈ»
π Updating the System
Pull the latest version:
git pull origin main
To update face profiles:
β
Add/remove images in known_faces/
β
Re-run program β it automatically re-encodes
βΈ»
π Troubleshooting
Issue Solution
Black screen / no camera Change webcam index (0 β 1)
Slow performance Resize frames, use hog model
Incorrect recognition Add more photos per person / adjust tolerance
dlib failing to install Install CMake & C++ build tools
βΈ»
π Ethical & Privacy Considerations
This system processes biometric identity data.
Use responsibly:
β
Obtain consent
β
Protect stored face images
β
Follow local data protection rules
βΈ»
π± Future Improvements (Planned)
β’ Face encoding caching (faster startup)
β’ Live backend sync with CrowdEye central system
β’ Liveness / anti-spoofing detection
β’ Full hardware deployment for bus entry validation
β’ GPU support for high throughput
βΈ»
π‘ Credits
β’ face_recognition (dlib encodings)
β’ OpenCV (video capture)
β’ NumPy (array operations)
βΈ»