Face Recognition Real Time DB
π Overview
Take real-time face recognition a step further and wire it to a database: member details (name, photo, face encoding) live in a database with online create, read, update, and delete, giving you a manageable face-based attendance or access-control system.
Unlike the simple version where photos are hard-coded in the source, the database version maintains member records dynamically - close to how a production face recognition application is architected.
π§° What you need
- Computer + camera
- Python 3.7+ environment
- pip install: opencv-python, face-recognition (or an alternative), sqlite3 (built in) / pymysql
- Optional: a GUI tool for viewing SQLite data
π§ Step by step
Design the table
Create a members table: id, name, photo path, face encoding (BLOB)
SQLite is plenty for a single-machine demo; swap in MySQL for production
Enroll faces
Provide an 'add member' flow: take a photo or upload one, then enter the name
Extract the encoding and store it in the database
Compare in real time
The camera detects a face and extracts its encoding
Compare it against every encoding in the database and take the nearest match
Recognition feedback
On a match, show the name and write a record to the log table
On no match, show 'unknown' and offer the new-member enrolment flow
Management features
Create, read, update, delete: rename, remove members, export records
A simple command-line menu or a Flask web UI works well
Bring it together
Chain enrolment, recognition, and management into one complete flow
Document how to back up and restore the data
π‘ Tips
- Save encodings with numpy and keep the dtype consistent when reading them back
- The quality of the enrolment photos directly drives the recognition rate, so keep them frontal and well lit
- Control the recognition rate: comparing every frame is CPU heavy, so run it 1-2 times a second