# rohangforwork/opencv_attendence architecture

> Architecture diagram of the GitHub repository rohangforwork/opencv_attendence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohangforwork/opencv_attendence
- Repository: https://github.com/rohangforwork/opencv_attendence

## Overview

##### Project Type and Purpose
- The project is an automated attendance registry that uses computer vision technologies.
- It primarily uses OpenCV for frontal face detection/recognition but has been updated to incorporate YOLO v8 (and related YOLO v9 scripts) for object detection enhancements.
- The system appears designed as a full-stack application with a web interface (templates and static assets), a backend server (server.py, server1.py, serverThread.py), and a vision component (contained in the "front_face" and "yolo_v9" directories).

##### Key File Structure Components
- Frontend/UI Layer:
- The "templates" directory (with index.html) represents the web pages.
- The "static" directory contains CSS and JS resources.
- Backend/Server Layer:
- server.py, server1.py, and serverThread.py indicate a server component that likely handles API calls, user interactions, and coordination between UI and vision modules.
- Computer Vision Modules:
- "front_face": Contains scripts (e.g., face_detect.py, face_recognition.py, record_faces.py) and model files (e.g., haar_face.xml, face_trained.yml) for OpenCV-based face recognition.
- "yolo_v9": Contains training (train.py), prediction (predict.py), and utilities (rename.py, txt_gen.py, video_yolo_trans.py) for the YOLO-based detection system.
- Model weights include YOLO files (yolo11n.pt, yolov8n.pt, yolov8n-cls.pt) and additional data files like shape_predictor_68_face_landmarks.dat.
- Data and Resources:
- Attendance.xlsx and class_timetable.xlsx likely store attendance records and scheduling information.
- The "persons" directory organizes face data per individual (hrudhay, rajat, rohan etc.) used for training or recognition.
- Numpy files (features.npy, labels.npy) are used to store extracted features/labels for face recognition.

##### How
- Next, illustrate the “Backend/Server” component:
- “Computer Vision” layer as two main subcomponents:
a. OpenCV Face Recognition Module:
- Components such as face_detect.py, face_recognition.py, record_faces.py.
- Supporting elements like the Haar cascade file (haar_face.xml), face_trained.yml, and numpy data (features.npy, labels.npy).
b. YOLO Detection Module:
- Components from the "yolo_v9" directory (train.py, predict.py, etc.) alongside the YOLO model weights files (yolo11n.pt, yolov8n.pt, and yolov8n-cls.pt).
- A “Data Storage / Resources” block:
- Excel files (ATTENDANCE.xlsx, class_timetable.xlsx) and the "persons" directory.
- How these serve as persistent data for attendance records and training data.
- External dependency nodes if necessary:

##### Relationships and Data Flow
- Optionally, illustrate a training/feedback loop for periodic model retraining (data from the "persons" directory feeding into the YOLO training pipeline).

##### Final Checklist
- Clear and descriptive labels for each component.
- Annotations if necessary to denote the use of specific technologies/frameworks (e.g., “OpenCV + Dlib”, “YOLO v8/v9”, “Flask/Django” if applicable from server code hints, and “Excel” for record keeping).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        HTMLTemplate["HTML Template"]:::frontend
        StaticAssets["Static Assets"]:::frontend
    end

    %% Backend/Server Layer
    subgraph "Backend/Server Layer"
        ServerAPI["Server/API"]:::backend
    end

    %% Computer Vision Layer
    subgraph "Computer Vision Layer"
        FaceRecog["OpenCV Face Recognition Module"]:::vision
        YOLO["YOLO Detection Module"]:::vision
    end

    %% Data Storage / Resources
    DataStorage["Data Storage / Resources"]:::database

    %% Connections
    HTMLTemplate -->|"sends request"| ServerAPI
    StaticAssets -->|"sends assets"| ServerAPI
    ServerAPI -->|"triggers detection"| FaceRecog
    ServerAPI -->|"triggers detection"| YOLO
    FaceRecog -->|"updates records"| DataStorage
    YOLO -->|"updates records"| DataStorage
    DataStorage -->|"feeds updated data"| ServerAPI

    %% Click Events
    click HTMLTemplate "https://github.com/rohangforwork/opencv_attendence/blob/main/templates/index.html"
    click StaticAssets "https://github.com/rohangforwork/opencv_attendence/tree/main/static/"
    click ServerAPI "https://github.com/rohangforwork/opencv_attendence/blob/main/server.py"
    click FaceRecog "https://github.com/rohangforwork/opencv_attendence/tree/main/front_face/"
    click YOLO "https://github.com/rohangforwork/opencv_attendence/tree/main/yolo_v9/"
    click DataStorage "https://github.com/rohangforwork/opencv_attendence/tree/main/persons/"

    %% Styles
    classDef frontend fill:#a2d2ff,stroke:#1b263b,stroke-width:2px;
    classDef backend fill:#ffafcc,stroke:#d90429,stroke-width:2px;
    classDef vision fill:#ffd6a5,stroke:#ee9b00,stroke-width:2px;
    classDef database fill:#fdffb6,stroke:#ff9f1c,stroke-width:2px;
```
