Loading repository data…
Loading repository data…
kyledelfin2006 / repository
An offline desktop application using OpenCV DNN/LBPH and SQLite to automate attendance logging, registration, exporting.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A Offline-based desktop application for offline attendance tracking using facial recognition. The system detects faces via a pre-trained DNN and recognizes individuals using LBPH histograms. All data is stored locally in SQLite, attendance is exportable to CSV, and the app provides real-time feedback through a clean GUI.
Prototype Deployment — This system was piloted by two small businesses in Kalibo, Aklan as a proof-of-concept attendance tracking solution.
The application follows a modular, layered design with clear separation of concerns:
GUI Layer (Tkinter, ttk)
|
Business Logic (AttendanceApp, Registration, Session Management)
|
Face Manager (DNN detection + LBPH recognition)
|
Data Layer (SQLite, CSV export)
|
Image Storage / Model File
database.py.images/<person_id>/; the LBPH model is persisted as face_model.yml; attendance sessions are exported as CSV files.project_root/
├── app/
│ ├── __init__.py
│ ├── attendance_app.py # Main application class (GUI + logic)
│ └── about_app.py # About tab content
│
├── face/
│ ├── __init__.py
│ └── face_manager.py # DNN detection + LBPH recognition + training
│
├── data/
│ ├── __init__.py
│ └── database.py # SQLite CRUD operations
│
├── models/ # Pre-trained DNN files (must be downloaded)
│ └── dnn/
│ ├── deploy.prototxt
│ └── res10_300x300_ssd_iter_140000_fp16.caffemodel
│
├── images/ # Stored face crops (auto-created)
├── exports/ # CSV exports (auto-created)
├── main.py # Application entry point
├── wipe_db_script.py # Utility to reset all data
└── requirements.txt
FaceManager centralises all face-related operations: loading the DNN network, detecting faces in a frame, extracting and resizing face ROIs, performing LBPH recognition, and training the model on newly registered persons. It manages the persistence of the LBPH model and loads it automatically at startup.
class FaceManager:
def __init__(self):
self.face_net = cv2.dnn.readNetFromCaffe(...)
self.recognizer = cv2.face.LBPHFaceRecognizer_create()
self.load_model()
All SQLite operations are wrapped in simple functions in database.py (e.g., add_person, log_attendance, get_all_sessions). The module handles connection management using context managers, ensuring transactions are properly committed or rolled back.
Registration involves capturing multiple face crops (~4 seconds) and then training the LBPH model. Training runs in a background thread while a timer updates the UI with elapsed time.
thread = threading.Thread(target=self._do_registration, daemon=True)
thread.start()
self._update_processing_timer() # updates status label every 500ms
A single display_frame() method handles video feeds across both tabs, with configurable target dimensions.
The DNN expects a 300×300 blob; detections are filtered by a confidence threshold and bounding boxes are scaled back to the original frame dimensions.
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)), 1.0, (300, 300), (104.0, 177.0, 123.0))
self.face_net.setInput(blob)
detections = self.face_net.forward()
LBPH returns a label and confidence score (lower = better). If confidence is below the threshold (default 70), the person is considered recognised.
label, confidence = self.recognizer.predict(face_roi)
if confidence < CONFIDENCE_THRESHOLD:
name = get_person_name_by_id(label)
A semi-transparent overlay displays the app name, status message, countdown, captured face count, and a progress bar.
overlay = frame.copy()
cv2.rectangle(overlay, (10, 10), (w - 10, 190), (0, 0, 0), -1)
frame = cv2.addWeighted(overlay, 0.45, frame, 0.55, 0)
Each export writes session metadata followed by a header row and all attendance records.
writer.writerow(["Session ID", session_id])
writer.writerow(["Session Name", session_name])
writer.writerow(["Start Time", start_time])
writer.writerow(["End Time", end_time])
writer.writerow([])
writer.writerow(["Name", "Timestamp"])
writer.writerows(records)
UI updates from the registration background thread are scheduled via root.after() to keep Tkinter responsive.
def _update_processing_timer(self):
if not self._reg_timer_running:
return
elapsed = time.time() - self._reg_start_time
self.set_reg_status(f"Processing registration... {elapsed:.1f}s", fg="blue")
self.root.after(500, self._update_processing_timer)
git clone <repository-url>
cd facial-recognition-attendance
pip install -r requirements.txt
requirements.txt:
opencv-python>=4.5
opencv-contrib-python>=4.5 # required for LBPH
Pillow>=9.0
The application uses the res10_300x300_ssd_iter_140000_fp16 model. Download the following two files and place them in models/dnn/:
python main.py
| Issue | Solution |
|---|---|
| Camera not opening | Check that your webcam is connected and not in use by another application. |
| "No face crops captured" during registration | Ensure good lighting and that your face is clearly visible. Move your head slowly side-to-side. |
| Recognition is poor | Re-register the person under the same lighting conditions used during attendance. You can also adjust CONFIDENCE_THRESHOLD in face_manager.py. |
| Model files missing | The app will crash if the DNN .prototxt or .caffemodel are not in the correct location. Download them as described above. |
| Performance issues | DNN detection runs on CPU. Consider reducing video resolution (default is 800×600) in attendance_app.py if frame rate is too low. |
| Resource | Location |
|---|---|
| Database | database.db — persons, sessions, attendance |
| Face images | images/<person_id>/ — used for retraining the model |
| Trained model | models/face_model.yml — LBPH recognizer state |
| CSV exports | exports/ — one CSV file per session |
To reset everything completely and start fresh:
python wipe_db_script.py
This deletes the database, the images/ and exports/ folders, and the model file.
I plan to replace the current face detection model with a more robust, modern architecture (e.g., YOLO‑face or RetinaFace) to improve accuracy in challenging lighting and pose conditions. This upgrade will also bring:
Better handling of partial occlusions and side profiles.
Faster inference with optional GPU support.
Improved confidence scoring for more reliable attendance logging.
Estimated timeline: Next major release within 2‑3 months.
This project is provided for educational and non-commercial use.