# nico31415/drowning-detector architecture

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

- Interactive diagram: https://gitdiagram.com/nico31415/drowning-detector
- Repository: https://github.com/nico31415/drowning-detector

## Overview

Drowning-Detector is a webcam-based drowning-alert prototype. Its implemented workflow captures frames, detects objects, tracks the first detected box’s centre over time, flags prolonged stillness, and annotates and displays the frame. The README also describes above-water clearing and posture-ratio analysis, but these are not evident in the sampled implementation, so they are shown as documented concepts rather than implemented stages. The detection library downloads model files on demand. Edges reflect calls visible in the excerpts; no other source was inspected.

Main entry points: [`DrownDetect.py`](https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py) (Drowning detector), [`cvlib/__init__.py`](https://github.com/nico31415/drowning-detector/blob/master/cvlib/__init__.py) (cvlib API), [`cvlib/object_detection.py`](https://github.com/nico31415/drowning-detector/blob/master/cvlib/object_detection.py) (YOLO detection), [`cvlib/utils.py`](https://github.com/nico31415/drowning-detector/blob/master/cvlib/utils.py) (File downloader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Alert workflow"]
  node_app["Drowning detector<br/>[DrownDetect.py]"]
  node_capture["Frame capture<br/>[DrownDetect.py]"]
  node_tracking["Stillness tracker<br/>[DrownDetect.py]"]
  node_overlay["Alert overlay"]
  node_display["Live display<br/>[DrownDetect.py]"]
  node_waterline["Waterline handling<br/>[README.md]"]
  node_posture["Posture analysis<br/>[README.md]"]
end

subgraph group_vision["Object detection"]
  node_api["cvlib API<br/>[__init__.py]"]
  node_detector["YOLO detection"]
end

subgraph group_support["Model support"]
  node_downloader["File downloader<br/>[utils.py]"]
end

node_operator(("Pool operator"))
node_camera(("Webcam"))
node_modelhost["Model file hosts"]

node_operator -->|"starts"| node_app
node_app -->|"opens camera"| node_capture
node_camera -->|"provides frames"| node_capture
node_app -->|"calls detection"| node_api
node_api -->|"exports"| node_detector
node_app -->|"tracks centre"| node_tracking
node_app -->|"draws boxes"| node_overlay
node_app -->|"shows frame"| node_display
node_detector -->|"downloads files"| node_downloader
node_downloader -->|"fetches files"| node_modelhost
node_app -.->|"documents concept"| node_waterline
node_app -.->|"documents concept"| node_posture

click node_app "https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py"
click node_capture "https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py"
click node_tracking "https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py"
click node_overlay "https://github.com/nico31415/drowning-detector/blob/master/cvlib/object_detection.py"
click node_display "https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py"
click node_waterline "https://github.com/nico31415/drowning-detector/blob/master/README.md"
click node_posture "https://github.com/nico31415/drowning-detector/blob/master/README.md"
click node_api "https://github.com/nico31415/drowning-detector/blob/master/cvlib/__init__.py"
click node_detector "https://github.com/nico31415/drowning-detector/blob/master/cvlib/object_detection.py"
click node_downloader "https://github.com/nico31415/drowning-detector/blob/master/cvlib/utils.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_app,node_capture,node_tracking,node_overlay,node_display,node_waterline,node_posture toneBlue
class node_api,node_detector toneAmber
class node_downloader toneMint
class node_operator,node_camera,node_modelhost toneIndigo
```

## Components

### Alert workflow

- [Drowning detector](https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py): `DrownDetect.py`
- [Frame capture](https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py): `DrownDetect.py`
- [Stillness tracker](https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py): `DrownDetect.py`
- [Alert overlay](https://github.com/nico31415/drowning-detector/blob/master/cvlib/object_detection.py): `cvlib/object_detection.py`
- [Live display](https://github.com/nico31415/drowning-detector/blob/master/DrownDetect.py): `DrownDetect.py`
- [Waterline handling](https://github.com/nico31415/drowning-detector/blob/master/README.md): `README.md`
- [Posture analysis](https://github.com/nico31415/drowning-detector/blob/master/README.md): `README.md`

### Object detection

- [cvlib API](https://github.com/nico31415/drowning-detector/blob/master/cvlib/__init__.py): `cvlib/__init__.py`
- [YOLO detection](https://github.com/nico31415/drowning-detector/blob/master/cvlib/object_detection.py): `cvlib/object_detection.py`

### Model support

- [File downloader](https://github.com/nico31415/drowning-detector/blob/master/cvlib/utils.py): `cvlib/utils.py`

### Other components

- **Pool operator**
- **Webcam**
- **Model file hosts**

## Connections

- Pool operator → Drowning detector: starts (evidence: `README.md`)
- Drowning detector → Frame capture: opens camera (evidence: `DrownDetect.py`)
- Webcam → Frame capture: provides frames (evidence: `DrownDetect.py`)
- Drowning detector → cvlib API: calls detection (evidence: `DrownDetect.py`)
- cvlib API → YOLO detection: exports (evidence: `cvlib/__init__.py`)
- Drowning detector → Stillness tracker: tracks centre (evidence: `DrownDetect.py`)
- Drowning detector → Alert overlay: draws boxes (evidence: `DrownDetect.py`)
- Drowning detector → Live display: shows frame (evidence: `DrownDetect.py`)
- YOLO detection → File downloader: downloads files (evidence: `cvlib/object_detection.py`)
- File downloader → Model file hosts: fetches files (evidence: `cvlib/utils.py`)
- Drowning detector → Waterline handling: documents concept (evidence: `README.md`)
- Drowning detector → Posture analysis: documents concept (evidence: `README.md`)
