# mnalsaleh/ppe-safety-monitor architecture

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

- Interactive diagram: https://gitdiagram.com/mnalsaleh/ppe-safety-monitor
- Repository: https://github.com/mnalsaleh/ppe-safety-monitor

## Overview

PPE Safety Monitor is a local, anonymous camera/video monitor for helmets, reflective vests, goggles, and a pilot glove check. The main workflow selects an ROI, detects equipment, associates detections with people, and previews per-frame status; optional visibility confirmation enables timed alerts and SQLite history. The glove pilot has a separate hand-detection and glove-classification path, alongside data capture and training utilities. Relationships are limited to README statements and indexed references or excerpts shown here; unsampled implementation details are not inferred.

Main entry points: [`scripts/stage4_webcam_wear_status.py`](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py) (Live Monitor), [`scripts/kamera_eldiven_el_bolgesi.py`](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_el_bolgesi.py) (Hand-Localized Preview), [`scripts/stage4_glove_gate.py`](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_glove_gate.py) (Hand-Glove Association), [`scripts/kamera_eldiven_nokta.py`](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_nokta.py) (Glove Model Comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitor["PPE Monitoring"]
  node_monitor_app["Live Monitor"]
  node_ppe_detector["PPE Detection"]
end

subgraph group_decisions["Decision And Alerts"]
  node_candidate_gate["Person Candidate Gate"]
  node_frame_decision["Frame Decisions<br/>[stage4_decision.py]"]
  node_timed_alerts["Timed Alerts<br/>[stage4_alerts.py]"]
  node_history_db[("Event History<br/>[stage4_alerts.py]")]
end

subgraph group_gloves["Glove Pilot"]
  node_glove_monitor["Glove Preview"]
  node_glove_region["Hand-Localized Preview"]
  node_glove_comparison["Glove Model Comparison"]
  node_hand_worker["MediaPipe Worker<br/>[el_nokta_isci.py]"]
  node_hand_detector["Hand Landmark Detector<br/>[el_noktalari.py]"]
  node_glove_gate["Hand-Glove Association"]
  node_glove_test["Controlled Glove Test"]
end

subgraph group_glove_data["Glove Data"]
  node_data_capture["Glove Data Capture"]
  node_classifier_training["Classifier Training<br/>[egit.py]"]
end

node_operator(("Operator"))
node_video_source(("Camera Or Video"))

node_operator -->|"starts"| node_monitor_app
node_video_source -->|"provides frames"| node_monitor_app
node_monitor_app -.->|"runs detection"| node_ppe_detector
node_monitor_app -->|"filters candidates"| node_candidate_gate
node_monitor_app -->|"evaluates detections"| node_frame_decision
node_monitor_app -->|"updates alerts"| node_timed_alerts
node_timed_alerts -->|"stores events"| node_history_db
node_operator -->|"confirms visibility"| node_monitor_app
node_monitor_app -->|"evaluates hands"| node_glove_gate
node_monitor_app -.->|"opens pilot"| node_glove_region
node_glove_region -->|"associates detections"| node_glove_gate
node_glove_comparison -->|"evaluates hands"| node_glove_gate
node_glove_comparison -.->|"requests hand inference"| node_hand_worker
node_hand_worker -->|"runs landmarks"| node_hand_detector
node_glove_region -->|"uses frame helpers"| node_glove_test
node_data_capture -->|"uses camera helpers"| node_glove_test
node_classifier_training -.->|"trains from captured data"| node_data_capture

click node_monitor_app "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py"
click node_ppe_detector "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py"
click node_candidate_gate "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_candidate_gate.py"
click node_frame_decision "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_decision.py"
click node_timed_alerts "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_alerts.py"
click node_history_db "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_alerts.py"
click node_glove_monitor "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py"
click node_glove_region "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_el_bolgesi.py"
click node_glove_comparison "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_nokta.py"
click node_hand_worker "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/el_nokta_isci.py"
click node_hand_detector "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/outputs/eldiven_v3_veri/pilot_el_noktalari_20261130_01/el_noktalari.py"
click node_glove_gate "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_glove_gate.py"
click node_glove_test "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_v2.py"
click node_data_capture "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/eldiven_v3_veri_topla.py"
click node_classifier_training "https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/outputs/eldiven_v3_veri/pilot_el_siniflandirma_20261130_01/egit.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_monitor_app,node_ppe_detector toneBlue
class node_candidate_gate,node_frame_decision,node_timed_alerts,node_history_db toneAmber
class node_glove_monitor,node_glove_region,node_glove_comparison,node_hand_worker,node_hand_detector,node_glove_gate,node_glove_test toneMint
class node_data_capture,node_classifier_training toneRose
class node_operator,node_video_source toneIndigo
```

## Components

### PPE Monitoring

- [Live Monitor](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py): `scripts/stage4_webcam_wear_status.py`
- [PPE Detection](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py): `scripts/stage4_webcam_wear_status.py`

### Decision And Alerts

- [Person Candidate Gate](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_candidate_gate.py): `scripts/stage4_candidate_gate.py`
- [Frame Decisions](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_decision.py): `scripts/stage4_decision.py`
- [Timed Alerts](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_alerts.py): `scripts/stage4_alerts.py`
- [Event History](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_alerts.py): `scripts/stage4_alerts.py`

### Glove Pilot

- [Glove Preview](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_webcam_wear_status.py): `scripts/stage4_webcam_wear_status.py`
- [Hand-Localized Preview](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_el_bolgesi.py): `scripts/kamera_eldiven_el_bolgesi.py`
- [Glove Model Comparison](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_nokta.py): `scripts/kamera_eldiven_nokta.py`
- [MediaPipe Worker](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/el_nokta_isci.py): `scripts/el_nokta_isci.py`
- [Hand Landmark Detector](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/outputs/eldiven_v3_veri/pilot_el_noktalari_20261130_01/el_noktalari.py): `outputs/eldiven_v3_veri/pilot_el_noktalari_20261130_01/el_noktalari.py`
- [Hand-Glove Association](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/stage4_glove_gate.py): `scripts/stage4_glove_gate.py`
- [Controlled Glove Test](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/kamera_eldiven_v2.py): `scripts/kamera_eldiven_v2.py`

### Glove Data

- [Glove Data Capture](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/scripts/eldiven_v3_veri_topla.py): `scripts/eldiven_v3_veri_topla.py`
- [Classifier Training](https://github.com/mnalsaleh/ppe-safety-monitor/blob/main/outputs/eldiven_v3_veri/pilot_el_siniflandirma_20261130_01/egit.py): `outputs/eldiven_v3_veri/pilot_el_siniflandirma_20261130_01/egit.py`

### Other components

- **Operator**
- **Camera Or Video**

## Connections

- Operator → Live Monitor: starts (evidence: `README.md`)
- Camera Or Video → Live Monitor: provides frames (evidence: `README.md`)
- Live Monitor → PPE Detection: runs detection (evidence: `scripts/stage4_webcam_wear_status.py`)
- Live Monitor → Person Candidate Gate: filters candidates (evidence: `scripts/stage4_webcam_wear_status.py`)
- Live Monitor → Frame Decisions: evaluates detections (evidence: `scripts/stage4_webcam_wear_status.py`)
- Live Monitor → Timed Alerts: updates alerts (evidence: `scripts/stage4_webcam_wear_status.py`)
- Timed Alerts → Event History: stores events (evidence: `scripts/stage4_alerts.py`)
- Operator → Live Monitor: confirms visibility (evidence: `README.md`)
- Live Monitor → Hand-Glove Association: evaluates hands (evidence: `scripts/stage4_webcam_wear_status.py`)
- Live Monitor → Hand-Localized Preview: opens pilot
- Hand-Localized Preview → Hand-Glove Association: associates detections (evidence: `scripts/kamera_eldiven_el_bolgesi.py`)
- Glove Model Comparison → Hand-Glove Association: evaluates hands (evidence: `scripts/kamera_eldiven_nokta.py`)
- Glove Model Comparison → MediaPipe Worker: requests hand inference (evidence: `scripts/el_nokta_isci.py`)
- MediaPipe Worker → Hand Landmark Detector: runs landmarks (evidence: `scripts/el_nokta_isci.py`)
- Hand-Localized Preview → Controlled Glove Test: uses frame helpers (evidence: `scripts/kamera_eldiven_el_bolgesi.py`)
- Glove Data Capture → Controlled Glove Test: uses camera helpers (evidence: `scripts/eldiven_v3_veri_topla.py`)
- Classifier Training → Glove Data Capture: trains from captured data
