# pisethsr168/python_face architecture

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

- Interactive diagram: https://gitdiagram.com/pisethsr168/python_face
- Repository: https://github.com/pisethsr168/python_face

## Overview

This is a single-script live webcam face and emotion analysis application. Its runtime loop captures frames, periodically asks DeepFace for emotion, age, and gender analysis, saves snapshots for selected emotions, annotates and displays the video, and exits on user input. The README also claims recognition of known faces and training-data support, but the shown implementation performs attribute analysis rather than identity recognition; no such subsystem is evidenced. Components and links below reflect the excerpted script, not uninspected code.

Main entry points: [`live_face_recogn.py`](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py) (Capture and Analysis Loop), [`emotion_snapshots`](https://github.com/pisethsr168/python_face/tree/main/emotion_snapshots) (Emotion Snapshots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Live Runtime"]
  node_main_loop["Capture and Analysis Loop"]
  node_emotion_state["Emotion History and FPS"]
end

subgraph group_analysis["Face Analysis"]
  node_analysis_fn["Face Attribute Analysis"]
  node_deepface["DeepFace"]
end

subgraph group_presentation["Display and Snapshots"]
  node_effects["Emotion Effects"]
  node_overlay["Face and Stats Overlays"]
  node_snapshot_writer["Snapshot Writer"]
  node_snapshot_store[("Emotion Snapshots")]
end

node_user(("User"))
node_webcam(("Webcam"))
node_display["OpenCV Window"]

node_webcam -->|"provides frames"| node_main_loop
node_main_loop -->|"analyzes frames"| node_analysis_fn
node_analysis_fn -->|"requests attributes"| node_deepface
node_main_loop -->|"updates history"| node_emotion_state
node_main_loop -->|"saves selected emotions"| node_snapshot_writer
node_snapshot_writer -->|"writes images"| node_snapshot_store
node_main_loop -->|"applies emotion effect"| node_effects
node_main_loop -->|"draws annotations"| node_overlay
node_main_loop -->|"shows video"| node_display
node_user -->|"quits with key"| node_display

click node_main_loop "https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py"
click node_analysis_fn "https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py"
click node_emotion_state "https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py"
click node_effects "https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py"
click node_overlay "https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py"
click node_snapshot_writer "https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py"
click node_snapshot_store "https://github.com/pisethsr168/python_face/tree/main/emotion_snapshots"

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_main_loop,node_emotion_state,node_user toneBlue
class node_analysis_fn,node_deepface toneAmber
class node_effects,node_overlay,node_snapshot_writer,node_snapshot_store toneMint
class node_webcam,node_display toneIndigo
```

## Components

### Live Runtime

- [Capture and Analysis Loop](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py): `live_face_recogn.py`
- [Emotion History and FPS](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py): `live_face_recogn.py`

### Face Analysis

- [Face Attribute Analysis](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py): `live_face_recogn.py`
- **DeepFace**

### Display and Snapshots

- [Emotion Effects](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py): `live_face_recogn.py`
- [Face and Stats Overlays](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py): `live_face_recogn.py`
- [Snapshot Writer](https://github.com/pisethsr168/python_face/blob/main/live_face_recogn.py): `live_face_recogn.py`
- [Emotion Snapshots](https://github.com/pisethsr168/python_face/tree/main/emotion_snapshots): `emotion_snapshots`

### Other components

- **User**
- **Webcam**
- **OpenCV Window**

## Connections

- Webcam → Capture and Analysis Loop: provides frames (evidence: `live_face_recogn.py`)
- Capture and Analysis Loop → Face Attribute Analysis: analyzes frames (evidence: `live_face_recogn.py`)
- Face Attribute Analysis → DeepFace: requests attributes (evidence: `live_face_recogn.py`)
- Capture and Analysis Loop → Emotion History and FPS: updates history (evidence: `live_face_recogn.py`)
- Capture and Analysis Loop → Snapshot Writer: saves selected emotions (evidence: `live_face_recogn.py`)
- Snapshot Writer → Emotion Snapshots: writes images (evidence: `live_face_recogn.py`)
- Capture and Analysis Loop → Emotion Effects: applies emotion effect (evidence: `live_face_recogn.py`)
- Capture and Analysis Loop → Face and Stats Overlays: draws annotations (evidence: `live_face_recogn.py`)
- Capture and Analysis Loop → OpenCV Window: shows video (evidence: `live_face_recogn.py`)
- User → OpenCV Window: quits with key
