# prabin0karki/facedetection architecture

> Architecture diagram of the GitHub repository prabin0karki/facedetection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prabin0karki/facedetection
- Repository: https://github.com/prabin0karki/facedetection

## Overview

This small OpenCV face-recognition application captures labeled face samples, trains an LBPH recognizer, then uses the saved model to identify faces from a camera feed. It also includes a separate live face-detection preview. The dataset and recognizer files are shown as shared state; source excerpts establish their paths, though they do not show direct calls between the scripts.

Main entry points: [`facetrain.py`](https://github.com/prabin0karki/facedetection/blob/master/facetrain.py) (Model training), [`facedata.py`](https://github.com/prabin0karki/facedetection/blob/master/facedata.py) (Sample capture), [`facedect.py`](https://github.com/prabin0karki/facedetection/blob/master/facedect.py) (Face recognition)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_sample_capture["Sample capture<br/>[facedata.py]"]
node_dataset[("Face dataset")]
node_model_training["Model training<br/>[facetrain.py]"]
node_recognizer[("Trained recognizer")]
node_face_recognition["Face recognition<br/>[facedect.py]"]
node_live_detection["Live detection<br/>[fa.py]"]

node_sample_capture -->|"writes samples"| node_dataset
node_model_training -->|"reads samples"| node_dataset
node_model_training -->|"saves model"| node_recognizer
node_face_recognition -->|"loads model"| node_recognizer

click node_sample_capture "https://github.com/prabin0karki/facedetection/blob/master/facedata.py"
click node_model_training "https://github.com/prabin0karki/facedetection/blob/master/facetrain.py"
click node_face_recognition "https://github.com/prabin0karki/facedetection/blob/master/facedect.py"
click node_live_detection "https://github.com/prabin0karki/facedetection/blob/master/fa.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sample_capture,node_face_recognition,node_live_detection toneTeal
class node_dataset,node_recognizer toneAmber
class node_model_training toneIndigo
```

## Components

### Other components

- [Sample capture](https://github.com/prabin0karki/facedetection/blob/master/facedata.py): `facedata.py`
- **Face dataset**
- [Model training](https://github.com/prabin0karki/facedetection/blob/master/facetrain.py): `facetrain.py`
- **Trained recognizer**
- [Face recognition](https://github.com/prabin0karki/facedetection/blob/master/facedect.py): `facedect.py`
- [Live detection](https://github.com/prabin0karki/facedetection/blob/master/fa.py): `fa.py`

## Connections

- Sample capture → Face dataset: writes samples (evidence: `facedata.py`)
- Model training → Face dataset: reads samples (evidence: `facetrain.py`)
- Model training → Trained recognizer: saves model (evidence: `facetrain.py`)
- Face recognition → Trained recognizer: loads model (evidence: `facedect.py`)
