# sampath123123/fire-smoke-detection architecture

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

- Interactive diagram: https://gitdiagram.com/sampath123123/fire-smoke-detection
- Repository: https://github.com/sampath123123/fire-smoke-detection

## Overview

A compact command-line fire and smoke detector: a user selects a camera, RTSP stream, or video file; the loop runs YOLO inference, groups persistent detections into events, and writes qualifying events to CSV. Annotated video and on-screen display are optional outputs. Runtime responsibilities are implemented together in detect.py, so the graph separates domain stages without implying separate modules. The model file is the supplied detector; source evidence for its internal behavior is not available.

Main entry points: [`detect.py`](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py) (Frame loop), [`models/fire.pt`](https://github.com/sampath123123/fire-smoke-detection/blob/main/models/fire.pt) (Fire/smoke weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Video capture"]
  node_sources["Camera, RTSP, or file"]
  node_source_open["Source selection<br/>[detect.py]"]
  node_frame_loop["Frame loop<br/>[detect.py]"]
end

subgraph group_detection["Detection"]
  node_model_file["Fire/smoke weights<br/>[fire.pt]"]
  node_yolo["YOLO inference<br/>[detect.py]"]
  node_filter["Confidence filtering<br/>[detect.py]"]
end

subgraph group_events["Event processing"]
  node_event_state["Open event state<br/>[detect.py]"]
  node_event_rules["Persistence and gap rules<br/>[detect.py]"]
  node_event_record["Event record formatting<br/>[detect.py]"]
end

subgraph group_outputs["Outputs"]
  node_csv_file[("Event CSV")]
  node_annotate["Frame annotation<br/>[detect.py]"]
  node_display["Live display<br/>[detect.py]"]
  node_video_file["Annotated video"]
end

node_user(("Operator"))

node_user -->|"selects source"| node_source_open
node_sources -->|"provides stream"| node_source_open
node_source_open -->|"opens capture"| node_frame_loop
node_frame_loop -->|"submits frames"| node_yolo
node_model_file -->|"provides weights"| node_yolo
node_yolo -->|"returns detections"| node_filter
node_filter -->|"updates sightings"| node_event_state
node_frame_loop -->|"checks elapsed gaps"| node_event_rules
node_event_rules -->|"closes qualifying events"| node_event_state
node_event_state -->|"supplies event data"| node_event_record
node_event_record -->|"appends rows"| node_csv_file
node_filter -->|"draws detections"| node_annotate
node_frame_loop -->|"shows frames"| node_display
node_annotate -->|"renders overlay"| node_display
node_annotate -->|"writes frames"| node_video_file

click node_source_open "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_frame_loop "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_model_file "https://github.com/sampath123123/fire-smoke-detection/blob/main/models/fire.pt"
click node_yolo "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_filter "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_event_state "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_event_rules "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_event_record "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_annotate "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py"
click node_display "https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.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_sources,node_source_open,node_frame_loop toneBlue
class node_model_file,node_yolo,node_filter toneAmber
class node_event_state,node_event_rules,node_event_record toneMint
class node_csv_file,node_annotate,node_display,node_video_file toneRose
class node_user toneIndigo
```

## Components

### Video capture

- **Camera, RTSP, or file**
- [Source selection](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`
- [Frame loop](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`

### Detection

- [Fire/smoke weights](https://github.com/sampath123123/fire-smoke-detection/blob/main/models/fire.pt): `models/fire.pt`
- [YOLO inference](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`
- [Confidence filtering](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`

### Event processing

- [Open event state](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`
- [Persistence and gap rules](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`
- [Event record formatting](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`

### Outputs

- **Event CSV**
- [Frame annotation](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`
- [Live display](https://github.com/sampath123123/fire-smoke-detection/blob/main/detect.py): `detect.py`
- **Annotated video**

### Other components

- **Operator**

## Connections

- Operator → Source selection: selects source (evidence: `README.md`)
- Camera, RTSP, or file → Source selection: provides stream (evidence: `detect.py`)
- Source selection → Frame loop: opens capture (evidence: `detect.py`)
- Frame loop → YOLO inference: submits frames (evidence: `detect.py`)
- Fire/smoke weights → YOLO inference: provides weights (evidence: `detect.py`)
- YOLO inference → Confidence filtering: returns detections (evidence: `detect.py`)
- Confidence filtering → Open event state: updates sightings (evidence: `detect.py`)
- Frame loop → Persistence and gap rules: checks elapsed gaps (evidence: `detect.py`)
- Persistence and gap rules → Open event state: closes qualifying events (evidence: `detect.py`)
- Open event state → Event record formatting: supplies event data (evidence: `detect.py`)
- Event record formatting → Event CSV: appends rows (evidence: `detect.py`)
- Confidence filtering → Frame annotation: draws detections (evidence: `detect.py`)
- Frame loop → Live display: shows frames (evidence: `detect.py`)
- Frame annotation → Live display: renders overlay (evidence: `detect.py`)
- Frame annotation → Annotated video: writes frames (evidence: `detect.py`)
