How tejas7k/face-attendeance-system works
Project Type and Purpose
• This project is a Python-based face recognition application. It uses a web interface (built in Flask) to allow user registration (including face capturing) and to log attendance via face recognition.
• Key technologies include Flask (web server), OpenCV (face detection with the Haar Cascade), and scikit-learn (face recognition with a KNN model), and it logs attendance data in CSV files.
Analyzing the File Structure
• Top-level files:
• app.py: The main application file which manages routes, face detection, recognition, and attendance logging.
• haarcascade_frontalface_default.xml: The pre-trained Haar Cascade used for face detection.
• README.md and background.png (additional UI resource).
• Directories:
• static: Contains the serialized face recognition model (face_recognition_model.pkl) and a folder named “faces” where each subdirectory (e.g., tejas_7) holds face images of a registered user.
• templates: Contains the HTML templates (home.html) used for the web interface.
• The attendance records (CSV files) are saved (as noted in the README) in an Attendance directory (even if not immediately present in the file tree, it is described as part of the system).
Key Components
• Web Server Component:
• Flask application (app.py) that handles different routes such as home ("/"), user registration ("/add"), and starting attendance ("/start").
• Face Detection Module:
• OpenCV integrated with the Haar Cascade (haarcascade_frontalface_default.xml) to detect faces in webcam frames.
• Face Recognition Module:
• The KNN model for face recognition is trained on captured face images. The trained model is stored as “face_recognition_model.pkl” in the static folder.
• Data Storage / Attendance Logging:
• Attendance records are stored in CSV files (named with the date) under an Attendance directory.
• User Interface:
• HTML templates (home.html) in the templates directory which render the web pages.
• Additional static assets such as the background image for the webcam interface.
• Image Capture and Storage:
• The static/faces directory contains subdirectories for each registered user’s face image dataset.
Establishing Relationships and Data Flow
• The user accesses the system via a web browser and loads the web interface (served by Flask from the templates).
• When a user registers:
• The system captures face images from a webcam.
• These images are stored in the corresponding user directory under static/faces.
• The face detection module (using OpenCV and the Haar Cascade file) processes these images.
• When registering and starting attendance:
• The images are either directly compared using the KNN model or used to trigger model training, updating the stored model (face_recognition_model.pkl).
• Attendance is logged in a CSV file within the Attendance folder with user details and timestamp.
• Data flow from the Web Browser to the Flask server.
• Flask’s communication with the face detection and face recognition services.
• Storage operations to the static directory (for models and captured face images) and the Attendance directory for logs.
Final Advice for the Principal Software Engineer
• Component is labeled clearly with its role (e.g., “Flask Server: Handles routing and processing”).
• A different one for processing modules,
• And another for data storage components.
• As many components as possible to reflect both the high-level architecture and the finer details of how voice data flows from registration to attendance logging.