System Architecture OverviewΒΆ
This document provides a high-level overview of the execution flow and modular design of the tracking system.
It serves as a technical reference for developers working on both the C++ and Python sides of the vision pipeline.
1. OverviewΒΆ
The system is organized into three major layers:
Entry Layer (
app/track.py)Command-line interface and runtime entry point.
Initializes configurations, logging, and pipeline settings.
Manages execution modes (UI, service, headless, record-only).
Context Layer (
app/_contextgenerators.py)Handles data input and frame acquisition.
Supports multiple sources: live network streams, local cameras, recorded datasets, or database entries.
Pipeline Layer (
app/_pipeline.pyand submodules)Performs the main image-processing pipeline.
Composed of modular stages:
Boundary detection
_pipeline_boundary_stage.pyProcess camera view
_pipeline_process_camera_view.pyTriangulation
_pipeline_triangulate_stage.pyTip detection
_pipeline_process_camera_view.pyExperimental extensions
_pipeline_experimental_stage.py
Interface Layer (
app/_gui.py/ service mode)GUI via PyQt6 (
MainWindow) connected through multiprocessing queues.Optional REST/WebSocket server for telemetry (FastAPI + Uvicorn).
2. Execution Flow SummaryΒΆ
Program start
app/track.pyis executed as the entry point.Command-line arguments are parsed (input mode, logging, config, UI/service flags, etc.).
Configuration and context initialization
Loads pipeline configuration file (
pipeline.config.jsonor.yaml).Creates
context_generatorbased on input type:CameraContextGeneratorPhysicalCameraContextGeneratorDatabaseContextGeneratorDatasetContextGenerator
Pipeline selection
If
--record-onlyβ disable pipeline (record frames only).Otherwise import the actual
pipeline()function from_pipeline.py.
Execution modes
Service mode (
--service):Starts background process for context generation and pipeline execution.
Launches FastAPI server with:
/ws/telemetryβ WebSocket streaming livectx["export"]data./queue_sizeβ Returns current queue depth.
UI mode (
--ui):Launches PyQt6 GUI, creates shared queue and event pool.
Displays real-time processing results.
Headless mode:
Runs
context_generator.run(None, pipeline)directly in the main process.
Output
Logs and results are stored in
logs/runs/<timestamp>/when enabled.Optional dataset export controlled by
--output-datasetand--manually-output-dataset.
3. File Hierarchy (Simplified)ΒΆ
project_root/
βββapp
βββ track.py # Entry point
βββ _contextgenerators.py # Context input sources
βββ _pipeline.py # Main pipeline manager
βββ _pipeline_boundary_stage.py
βββ _pipeline_process_camera_view.py
βββ _pipeline_triangulate_stage.py
βββ _pipeline_tip_detection_stage.py
βββ _pipeline_experimental_stage.py
βββ _gui.py # GUI components (PyQt6)
βββvision
βββ detectors.py # Detection utilities
4. System FlowchartΒΆ
flowchart TD
A[[Start: app/track.py]] --> B[Parse CLI arguments]
B --> C[Load config & setup environment]
C --> D{Input type?}
D -->|network| D1[CameraContextGenerator]
D -->|local| D2[PhysicalCameraContextGenerator]
D -->|db:name| D3[DatabaseContextGenerator]
D -->|dataset| D4[DatasetContextGenerator]
C --> E{Record-only?}
E -->|yes| F[Record only (no pipeline)]
E -->|no | G[Import pipeline from _pipeline.py]
C --> H{Execution mode?}
H -->|Service| I[service_mode()]
H -->|UI| J[Launch PyQt6 MainWindow]
H -->|Headless| K[Run context_generator.run() directly]
%% Service mode branch
I --> I1[Background: context_generator.run(q, cmd_queue, pipeline)]
I --> I2[FastAPI + Uvicorn server]
I2 --> I3[/ws/telemetry<br/>Stream ctx.export + queue stats/]
I2 --> I4[GET /queue_size]
%% UI branch
J --> J1[Create multiprocessing Manager/Queue/Event/Pool]
J1 --> J2[Background: context_generator.run(q, cmd_queue, pipeline)]
J --> J3[MainWindow.connect(q)<br/>display processed data]
%% Headless
K --> K1[context_generator.run(None, pipeline)]
%% Pipeline internals
G --> P[Pipeline stages]
P --> P1[Boundary Stage]
P --> P2[Process Camera View]
P --> P3[Triangulate Stage]
P --> P4[Tip Detection Stage]
P --> P5[Experimental Stage]
%% End
I4 --> Z([End])
J3 --> Z
K1 --> Z
P5 --> Z
5. Design PrinciplesΒΆ
Modularity:
Each stage and context generator is self-contained, enabling isolated development and debugging.Parallelism:
Background processes (viamultiprocessing.PoolandManager.Queue) allow concurrent frame acquisition and processing.Interoperability:
Designed for hybrid Python/C++ usage (e.g.,pybind11-linked modules).Extensibility:
New stages or detectors can be added simply by implementing corresponding_pipeline_*_stage.pymodules and registering them.