# pseudoxec/detection_pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/pseudoxec/detection_pipeline
- Repository: https://github.com/pseudoxec/detection_pipeline

## Overview

This is an edge vehicle and license-plate detection pipeline for a Raspberry Pi, with RTSP and image-file inputs. The main workflow captures frames, detects and tracks vehicles, crops vehicles and plates, optionally reads plate text, records timings, then writes detection records to a SQLite hand-off buffer; an optional API hand-off and live-view branch are also present. Source excerpts show the core processing and persistence behavior; live-view modules were read in the source index but not excerpted, so their internal behavior is represented only where indexed references support it.

Main entry points: [`pipeline/pipeline.py`](https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/pipeline.py) (Frame pipeline), [`run.py`](https://github.com/pseudoxec/detection_pipeline/blob/main/run.py) (Pipeline runner), [`storage/storage.py`](https://github.com/pseudoxec/detection_pipeline/blob/main/storage/storage.py) (Buffer writer), [`live/live_server.py`](https://github.com/pseudoxec/detection_pipeline/blob/main/live/live_server.py) (Live server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and configuration"]
  node_entry["Pipeline runner<br/>[run.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_camera["Frame source<br/>[camera.py]"]
end

subgraph group_vision["Detection and recognition"]
  node_detector["YOLO inference<br/>[detector.py]"]
  node_tracker["Vehicle tracking<br/>[tracker.py]"]
  node_geometry["Box geometry<br/>[geometry.py]"]
  node_imageops["Image enhancement<br/>[image_ops.py]"]
  node_ocr["Plate OCR<br/>[plate_reader.py]"]
end

subgraph group_processing["Frame processing"]
  node_pipeline["Frame pipeline<br/>[pipeline.py]"]
  node_timing["Stage timing<br/>[timing.py]"]
  node_finalizer["Finalize workers<br/>[finalize_worker.py]"]
end

subgraph group_delivery["Persistence and hand-off"]
  node_storage["Buffer writer<br/>[storage.py]"]
  node_sqlite[("SQLite buffer")]
  node_api["API client<br/>[api_client.py]"]
end

subgraph group_live["Live view"]
  node_publisher["Box publisher<br/>[box_publisher.py]"]
  node_live_server["Live server<br/>[live_server.py]"]
  node_box_flow["Box flow<br/>[box_flow.py]"]
  node_snapshot["Snapshot view<br/>[snapshot.py]"]
end

node_operator(("Operator"))
node_dashboard(("C&#35; dashboard"))

node_operator -->|"starts"| node_entry
node_entry -->|"loads settings"| node_config
node_entry -->|"starts capture"| node_camera
node_entry -->|"processes frames"| node_pipeline
node_entry -->|"stops writer"| node_storage
node_camera -->|"supplies frames"| node_pipeline
node_pipeline -->|"runs inference"| node_detector
node_pipeline -->|"tracks vehicles"| node_tracker
node_pipeline -->|"crops boxes"| node_geometry
node_pipeline -->|"enhances crops"| node_imageops
node_pipeline -.->|"reads plates"| node_ocr
node_pipeline -->|"measures stages"| node_timing
node_pipeline -->|"submits jobs"| node_finalizer
node_finalizer -->|"enqueues records"| node_storage
node_storage -->|"writes batches"| node_sqlite
node_storage -->|"sends records"| node_api
node_api -->|"posts detections"| node_dashboard
node_entry -->|"publishes boxes"| node_publisher
node_pipeline -->|"publishes detections"| node_publisher
node_entry -->|"starts live view"| node_live_server
node_live_server -->|"uses flow"| node_box_flow
node_live_server -->|"uses snapshots"| node_snapshot
node_publisher -->|"uses snapshots"| node_snapshot

click node_entry "https://github.com/pseudoxec/detection_pipeline/blob/main/run.py"
click node_config "https://github.com/pseudoxec/detection_pipeline/blob/main/config/config.py"
click node_camera "https://github.com/pseudoxec/detection_pipeline/blob/main/camera/camera.py"
click node_pipeline "https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/pipeline.py"
click node_detector "https://github.com/pseudoxec/detection_pipeline/blob/main/detection/detector.py"
click node_tracker "https://github.com/pseudoxec/detection_pipeline/blob/main/detection/tracker.py"
click node_geometry "https://github.com/pseudoxec/detection_pipeline/blob/main/detection/geometry.py"
click node_imageops "https://github.com/pseudoxec/detection_pipeline/blob/main/detection/image_ops.py"
click node_ocr "https://github.com/pseudoxec/detection_pipeline/blob/main/ocr/plate_reader.py"
click node_timing "https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/timing.py"
click node_finalizer "https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/finalize_worker.py"
click node_storage "https://github.com/pseudoxec/detection_pipeline/blob/main/storage/storage.py"
click node_api "https://github.com/pseudoxec/detection_pipeline/blob/main/api/api_client.py"
click node_publisher "https://github.com/pseudoxec/detection_pipeline/blob/main/live/box_publisher.py"
click node_live_server "https://github.com/pseudoxec/detection_pipeline/blob/main/live/live_server.py"
click node_box_flow "https://github.com/pseudoxec/detection_pipeline/blob/main/live/box_flow.py"
click node_snapshot "https://github.com/pseudoxec/detection_pipeline/blob/main/live/snapshot.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_entry,node_config,node_camera toneBlue
class node_detector,node_tracker,node_geometry,node_imageops,node_ocr toneAmber
class node_pipeline,node_timing,node_finalizer toneMint
class node_storage,node_sqlite,node_api toneRose
class node_publisher,node_live_server,node_box_flow,node_snapshot,node_operator,node_dashboard toneIndigo
```

## Components

### Runtime and configuration

- [Pipeline runner](https://github.com/pseudoxec/detection_pipeline/blob/main/run.py): `run.py`
- [Configuration](https://github.com/pseudoxec/detection_pipeline/blob/main/config/config.py): `config/config.py`
- [Frame source](https://github.com/pseudoxec/detection_pipeline/blob/main/camera/camera.py): `camera/camera.py`

### Detection and recognition

- [YOLO inference](https://github.com/pseudoxec/detection_pipeline/blob/main/detection/detector.py): `detection/detector.py`
- [Vehicle tracking](https://github.com/pseudoxec/detection_pipeline/blob/main/detection/tracker.py): `detection/tracker.py`
- [Box geometry](https://github.com/pseudoxec/detection_pipeline/blob/main/detection/geometry.py): `detection/geometry.py`
- [Image enhancement](https://github.com/pseudoxec/detection_pipeline/blob/main/detection/image_ops.py): `detection/image_ops.py`
- [Plate OCR](https://github.com/pseudoxec/detection_pipeline/blob/main/ocr/plate_reader.py): `ocr/plate_reader.py`

### Frame processing

- [Frame pipeline](https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/pipeline.py): `pipeline/pipeline.py`
- [Stage timing](https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/timing.py): `pipeline/timing.py`
- [Finalize workers](https://github.com/pseudoxec/detection_pipeline/blob/main/pipeline/finalize_worker.py): `pipeline/finalize_worker.py`

### Persistence and hand-off

- [Buffer writer](https://github.com/pseudoxec/detection_pipeline/blob/main/storage/storage.py): `storage/storage.py`
- **SQLite buffer**
- [API client](https://github.com/pseudoxec/detection_pipeline/blob/main/api/api_client.py): `api/api_client.py`

### Live view

- [Box publisher](https://github.com/pseudoxec/detection_pipeline/blob/main/live/box_publisher.py): `live/box_publisher.py`
- [Live server](https://github.com/pseudoxec/detection_pipeline/blob/main/live/live_server.py): `live/live_server.py`
- [Box flow](https://github.com/pseudoxec/detection_pipeline/blob/main/live/box_flow.py): `live/box_flow.py`
- [Snapshot view](https://github.com/pseudoxec/detection_pipeline/blob/main/live/snapshot.py): `live/snapshot.py`

### Other components

- **Operator**
- **C# dashboard**

## Connections

- Operator → Pipeline runner: starts (evidence: `README.md`)
- Pipeline runner → Configuration: loads settings (evidence: `run.py`)
- Pipeline runner → Frame source: starts capture (evidence: `run.py`)
- Pipeline runner → Frame pipeline: processes frames (evidence: `run.py`)
- Pipeline runner → Buffer writer: stops writer (evidence: `run.py`)
- Frame source → Frame pipeline: supplies frames (evidence: `run.py`)
- Frame pipeline → YOLO inference: runs inference (evidence: `pipeline/pipeline.py`)
- Frame pipeline → Vehicle tracking: tracks vehicles (evidence: `pipeline/pipeline.py`)
- Frame pipeline → Box geometry: crops boxes (evidence: `pipeline/pipeline.py`)
- Frame pipeline → Image enhancement: enhances crops (evidence: `pipeline/pipeline.py`)
- Frame pipeline → Plate OCR: reads plates
- Frame pipeline → Stage timing: measures stages (evidence: `pipeline/pipeline.py`)
- Frame pipeline → Finalize workers: submits jobs (evidence: `pipeline/pipeline.py`)
- Finalize workers → Buffer writer: enqueues records (evidence: `pipeline/finalize_worker.py`)
- Buffer writer → SQLite buffer: writes batches (evidence: `README.md`)
- Buffer writer → API client: sends records (evidence: `storage/storage.py`)
- API client → C# dashboard: posts detections (evidence: `api/api_client.py`)
- Pipeline runner → Box publisher: publishes boxes (evidence: `run.py`)
- Frame pipeline → Box publisher: publishes detections (evidence: `pipeline/pipeline.py`)
- Pipeline runner → Live server: starts live view (evidence: `run.py`)
- Live server → Box flow: uses flow (evidence: `live/live_server.py`)
- Live server → Snapshot view: uses snapshots (evidence: `live/live_server.py`)
- Box publisher → Snapshot view: uses snapshots (evidence: `live/box_publisher.py`)
