Face Recognition Attendance (KNN)
Attendance taken from a face, with blink and smile checks so a photograph cannot sign in on someone’s behalf.
- My role
- Recognition model, camera program, Flask admin and PHP API.
- Field
- Machine Learning & AI, IoT & Embedded, Web Development
Overview
Every attendance system is really an anti-cheating system wearing a friendly interface. Recognition alone does not get you there — a printed photo held up to a webcam recognises perfectly well. So the system asks the face to do something a photograph cannot: blink, and smile. Only then does it accept the match.
The rest is bookkeeping done honestly. Check-in up to the start time counts as on time; after that it is recorded as late, with exactly how late; once closing time has passed, a check-in is refused. A check-out before closing is accepted but recorded as early, with the duration, rather than quietly passing as a normal day. The result is read aloud so the person knows what was stored.
A Flask web interface sits on top so an administrator can enrol people, capture or re-capture their face data, edit or remove them, and export a daily recap to Excel. Both the camera program and the admin reach MySQL through a small PHP API that requires an API key, and the face samples themselves never leave the machine.
In pictures





Function
- Model
- KNN (k = 3) on 128 × 128 face pixels, with a cosine-distance gate for strangers
- Liveness
- Blink (eye aspect ratio from dlib landmarks) and smile, both required
- Rules
- On time or late with duration; early check-out recorded as such
What it does
- 01Face detection with a Haar cascade and recognition with KNN; unknown faces are turned away by a cosine-distance threshold.
- 02Blink and smile detection as a liveness check.
- 03Check-in and check-out decided by one pure, unit-tested rules function.
- 04Spoken feedback in Indonesian for every result.
- 05Enrolment capturing personal data and 100 face samples, with re-capture later.
- 06Editing and deletion of users, including their records and face data.
- 07Daily attendance recap by date, exported to Excel.
Technical notes
- Times
- JAM_MASUK and JAM_PULANG set in .env (default 08:00 and 16:00)
- Refused
- Check-in after closing time, and any scan once both are recorded
- Privacy
- Face samples kept locally as .npz; the repository holds no biometric data