# leo4bits/fire_smoke_person_detection architecture

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

- Interactive diagram: https://gitdiagram.com/leo4bits/fire_smoke_person_detection
- Repository: https://github.com/leo4bits/fire_smoke_person_detection

## Overview

This is a real-time fire/smoke and air-quality monitoring application. Its main workflow captures webcam frames, enhances them, detects objects, and overlays detections alongside sensor risk predictions. In parallel, a serial-reader thread parses ESP32 readings and obtains predictions from a Random Forest model. The README was empty, so capabilities and relationships here are based on the sampled runtime source; model artifact wiring is not shown clearly enough to connect the repository files.

Main entry points: [`mainTest.py`](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/mainTest.py) (Live monitor), [`threadGetData/thread.py`](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/threadGetData/thread.py) (Serial reader), [`PreProcessing/imgPreProcessing.py`](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/imgPreProcessing.py) (CLAHE enhancement), [`MODEL_USING.py`](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/MODEL_USING.py) (YOLO inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision detection"]
  node_main["Live monitor<br/>[mainTest.py]"]
  node_image["CLAHE enhancement"]
  node_yolo["YOLO inference<br/>[MODEL_USING.py]"]
  node_yolo_model["YOLO weights<br/>[best.pt]"]
end

subgraph group_sensors["Sensor monitoring"]
  node_serial["Serial reader<br/>[thread.py]"]
  node_rf["Sensor prediction"]
  node_rf_model["Random Forest weights"]
end

subgraph group_presentation["Live display"]
  node_format["Label formatting<br/>[outputGUI.py]"]
  node_display["Annotated frame<br/>[mainTest.py]"]
end

node_webcam(("Webcam"))
node_esp32(("ESP32 sensors"))

node_webcam -->|"provides frames"| node_main
node_main -->|"enhances frames"| node_image
node_main -->|"requests boxes"| node_yolo
node_main -->|"starts thread"| node_serial
node_esp32 -->|"sends readings"| node_serial
node_serial -->|"processes readings"| node_rf
node_serial -->|"shares predictions"| node_main
node_main -->|"formats labels"| node_format
node_main -->|"draws overlays"| node_display

click node_main "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/mainTest.py"
click node_image "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/imgPreProcessing.py"
click node_yolo "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/MODEL_USING.py"
click node_yolo_model "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/best.pt"
click node_serial "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/threadGetData/thread.py"
click node_rf "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/numPreProcessing.py"
click node_rf_model "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/random_forest_air_quality.pkl"
click node_format "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/outputGUI.py"
click node_display "https://github.com/leo4bits/fire_smoke_person_detection/blob/main/mainTest.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_main,node_image,node_yolo,node_yolo_model toneBlue
class node_serial,node_rf,node_rf_model toneAmber
class node_format,node_display toneMint
class node_webcam,node_esp32 toneIndigo
```

## Components

### Vision detection

- [Live monitor](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/mainTest.py): `mainTest.py`
- [CLAHE enhancement](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/imgPreProcessing.py): `PreProcessing/imgPreProcessing.py`
- [YOLO inference](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/MODEL_USING.py): `MODEL_USING.py`
- [YOLO weights](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/best.pt): `best.pt`

### Sensor monitoring

- [Serial reader](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/threadGetData/thread.py): `threadGetData/thread.py`
- [Sensor prediction](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/numPreProcessing.py): `PreProcessing/numPreProcessing.py`
- [Random Forest weights](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/random_forest_air_quality.pkl): `random_forest_air_quality.pkl`

### Live display

- [Label formatting](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/PreProcessing/outputGUI.py): `PreProcessing/outputGUI.py`
- [Annotated frame](https://github.com/leo4bits/fire_smoke_person_detection/blob/main/mainTest.py): `mainTest.py`

### Other components

- **Webcam**
- **ESP32 sensors**

## Connections

- Webcam → Live monitor: provides frames (evidence: `mainTest.py`)
- Live monitor → CLAHE enhancement: enhances frames (evidence: `mainTest.py`)
- Live monitor → YOLO inference: requests boxes (evidence: `mainTest.py`)
- Live monitor → Serial reader: starts thread (evidence: `mainTest.py`)
- ESP32 sensors → Serial reader: sends readings (evidence: `threadGetData/thread.py`)
- Serial reader → Sensor prediction: processes readings (evidence: `threadGetData/thread.py`)
- Serial reader → Live monitor: shares predictions (evidence: `mainTest.py`)
- Live monitor → Label formatting: formats labels (evidence: `mainTest.py`)
- Live monitor → Annotated frame: draws overlays (evidence: `mainTest.py`)
