# joireve/pedestriandetectionsystem architecture

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

- Interactive diagram: https://gitdiagram.com/joireve/pedestriandetectionsystem
- Repository: https://github.com/joireve/pedestriandetectionsystem

## Overview

This is a minimal C++ single-image pedestrian detector: a user supplies an ONNX model and image path, then the command-line entry loads the image, invokes the detector, annotates detections, and displays the result. The detector performs LetterBox preprocessing, OpenCV DNN blob conversion and inference, then decodes person detections, restores image coordinates, and applies NMS. Model export is a separate documented capability. The main runtime files were excerpted; the model artifact is documented but its contents were not inspected.

Main entry points: [`include/PedestrianDetector.hpp`](https://github.com/joireve/pedestriandetectionsystem/blob/main/include/PedestrianDetector.hpp) (Detector API), [`src/main.cpp`](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/main.cpp) (Image CLI), [`scripts/export_onnx.py`](https://github.com/joireve/pedestriandetectionsystem/blob/main/scripts/export_onnx.py) (ONNX exporter), [`src/PedestrianDetector.cpp`](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp) (DNN inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Image application"]
  node_cli["Image CLI<br/>[main.cpp]"]
  node_image["Input image"]
  node_annotate["Annotate and display<br/>[main.cpp]"]
end

subgraph group_inference["Detection pipeline"]
  node_detector["Detector API"]
  node_letterbox["LetterBox preprocessing"]
  node_blob["Blob conversion"]
  node_forward["DNN inference"]
  node_decode["Person decode and NMS"]
end

subgraph group_model["Model artifact"]
  node_onnx["YOLOv8n ONNX<br/>[yolov8n.onnx]"]
  node_exporter["ONNX exporter<br/>[export_onnx.py]"]
  node_weights["YOLO source weights"]
end

node_user(("Image user"))

node_user -->|"runs with paths"| node_cli
node_cli -->|"loads image"| node_image
node_cli -->|"calls detect"| node_detector
node_detector -->|"preprocesses"| node_letterbox
node_detector -->|"converts input"| node_blob
node_detector -->|"runs forward"| node_forward
node_detector -->|"postprocesses"| node_decode
node_forward -->|"loads model"| node_onnx
node_cli -->|"draws detections"| node_annotate
node_annotate -->|"displays result"| node_image
node_exporter -->|"loads weights"| node_weights
node_exporter -->|"exports model"| node_onnx

click node_cli "https://github.com/joireve/pedestriandetectionsystem/blob/main/src/main.cpp"
click node_annotate "https://github.com/joireve/pedestriandetectionsystem/blob/main/src/main.cpp"
click node_detector "https://github.com/joireve/pedestriandetectionsystem/blob/main/include/PedestrianDetector.hpp"
click node_letterbox "https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp"
click node_blob "https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp"
click node_forward "https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp"
click node_decode "https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp"
click node_onnx "https://github.com/joireve/pedestriandetectionsystem/blob/main/models/yolov8n.onnx"
click node_exporter "https://github.com/joireve/pedestriandetectionsystem/blob/main/scripts/export_onnx.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_cli,node_image,node_annotate,node_user toneBlue
class node_detector,node_letterbox,node_blob,node_forward,node_decode toneAmber
class node_onnx,node_exporter,node_weights toneMint
```

## Components

### Image application

- [Image CLI](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/main.cpp): `src/main.cpp`
- **Input image**
- [Annotate and display](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/main.cpp): `src/main.cpp`

### Detection pipeline

- [Detector API](https://github.com/joireve/pedestriandetectionsystem/blob/main/include/PedestrianDetector.hpp): `include/PedestrianDetector.hpp`
- [LetterBox preprocessing](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp): `src/PedestrianDetector.cpp`
- [Blob conversion](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp): `src/PedestrianDetector.cpp`
- [DNN inference](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp): `src/PedestrianDetector.cpp`
- [Person decode and NMS](https://github.com/joireve/pedestriandetectionsystem/blob/main/src/PedestrianDetector.cpp): `src/PedestrianDetector.cpp`

### Model artifact

- [YOLOv8n ONNX](https://github.com/joireve/pedestriandetectionsystem/blob/main/models/yolov8n.onnx): `models/yolov8n.onnx`
- [ONNX exporter](https://github.com/joireve/pedestriandetectionsystem/blob/main/scripts/export_onnx.py): `scripts/export_onnx.py`
- **YOLO source weights**

### Other components

- **Image user**

## Connections

- Image user → Image CLI: runs with paths (evidence: `README.md`)
- Image CLI → Input image: loads image (evidence: `src/main.cpp`)
- Image CLI → Detector API: calls detect (evidence: `src/main.cpp`)
- Detector API → LetterBox preprocessing: preprocesses (evidence: `src/PedestrianDetector.cpp`)
- Detector API → Blob conversion: converts input (evidence: `src/PedestrianDetector.cpp`)
- Detector API → DNN inference: runs forward (evidence: `src/PedestrianDetector.cpp`)
- Detector API → Person decode and NMS: postprocesses (evidence: `src/PedestrianDetector.cpp`)
- DNN inference → YOLOv8n ONNX: loads model (evidence: `src/PedestrianDetector.cpp`)
- Image CLI → Annotate and display: draws detections (evidence: `src/main.cpp`)
- Annotate and display → Input image: displays result (evidence: `src/main.cpp`)
- ONNX exporter → YOLO source weights: loads weights (evidence: `scripts/export_onnx.py`)
- ONNX exporter → YOLOv8n ONNX: exports model (evidence: `scripts/export_onnx.py`)
