# userkhalid35/codealpha_object_detection_and_tracking architecture

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

- Interactive diagram: https://gitdiagram.com/userkhalid35/codealpha_object_detection_and_tracking
- Repository: https://github.com/userkhalid35/codealpha_object_detection_and_tracking

## Overview

This is a PySide6 desktop application for real-time object detection and multi-object tracking. The user selects a video or webcam, adjusts inference thresholds, and receives annotated frames and live telemetry; they can also record output, capture screenshots, and export detection logs. The controller coordinates the UI and worker, while the worker processes frames through YOLO/ByteTrack. The README documents theme support and automatic weight download. Some controller and worker code is excerpted only partially, so unshown details are not inferred.

Main entry points: [`controllers/main_controller.py`](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/controllers/main_controller.py) (Main controller), [`services/inference_worker.py`](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/services/inference_worker.py) (Inference worker), [`ui/main_window.py`](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/main_window.py) (Main window), [`tracker/bytetrack_impl.py`](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/tracker/bytetrack_impl.py) (YOLO and ByteTrack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application coordination"]
  node_entry["Application entry<br/>[main.py]"]
  node_controller["Main controller<br/>[main_controller.py]"]
  node_settings["Settings<br/>[settings.json]"]
end

subgraph group_interface["Desktop interface"]
  node_window["Main window<br/>[main_window.py]"]
  node_widgets["Controls and telemetry<br/>[widgets.py]"]
  node_themes["Theme styles<br/>[theme.py]"]
end

subgraph group_processing["Video processing"]
  node_worker["Inference worker"]
  node_tracker["YOLO and ByteTrack<br/>[bytetrack_impl.py]"]
  node_model["Detection data models<br/>[detection_model.py]"]
end

subgraph group_results["Results and export"]
  node_video_output["Recorded video"]
  node_helpers["Export and capture helpers<br/>[helpers.py]"]
  node_csv["Detection CSV"]
  node_screenshot["Screenshot image"]
end

node_user(("User"))
node_source(("Video or webcam"))
node_model_service["YOLO weights service"]

node_user -->|"launches"| node_entry
node_entry -->|"starts"| node_controller
node_controller -->|"loads and saves"| node_settings
node_controller -->|"creates and connects"| node_window
node_window -->|"uses controls"| node_widgets
node_window -->|"applies styles"| node_themes
node_user -->|"selects source"| node_window
node_window -->|"emits actions"| node_controller
node_controller -->|"starts and configures"| node_worker
node_source -->|"supplies frames"| node_worker
node_worker -->|"updates tracks"| node_tracker
node_tracker -->|"creates tracked objects"| node_model
node_worker -->|"creates telemetry and logs"| node_model
node_tracker -->|"runs inference"| node_model_service
node_worker -->|"emits frames and telemetry"| node_window
node_worker -->|"writes recording"| node_video_output
node_controller -->|"exports and captures"| node_helpers
node_helpers -->|"writes detection logs"| node_csv
node_helpers -->|"saves captured frame"| node_screenshot

click node_entry "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/main.py"
click node_controller "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/controllers/main_controller.py"
click node_settings "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/config/settings.json"
click node_window "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/main_window.py"
click node_widgets "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/widgets.py"
click node_themes "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/theme.py"
click node_worker "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/services/inference_worker.py"
click node_tracker "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/tracker/bytetrack_impl.py"
click node_model "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/models/detection_model.py"
click node_helpers "https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/utils/helpers.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_controller,node_settings,node_user toneBlue
class node_window,node_widgets,node_themes toneAmber
class node_worker,node_tracker,node_model toneMint
class node_video_output,node_helpers,node_csv,node_screenshot toneRose
class node_source,node_model_service toneIndigo
```

## Components

### Application coordination

- [Application entry](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/main.py): `main.py`
- [Main controller](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/controllers/main_controller.py): `controllers/main_controller.py`
- [Settings](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/config/settings.json): `config/settings.json`

### Desktop interface

- [Main window](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/main_window.py): `ui/main_window.py`
- [Controls and telemetry](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/widgets.py): `ui/widgets.py`
- [Theme styles](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/ui/theme.py): `ui/theme.py`

### Video processing

- [Inference worker](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/services/inference_worker.py): `services/inference_worker.py`
- [YOLO and ByteTrack](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/tracker/bytetrack_impl.py): `tracker/bytetrack_impl.py`
- [Detection data models](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/models/detection_model.py): `models/detection_model.py`

### Results and export

- **Recorded video**
- [Export and capture helpers](https://github.com/userkhalid35/codealpha_object_detection_and_tracking/blob/main/utils/helpers.py): `utils/helpers.py`
- **Detection CSV**
- **Screenshot image**

### Other components

- **User**
- **Video or webcam**
- **YOLO weights service**

## Connections

- User → Application entry: launches (evidence: `main.py`)
- Application entry → Main controller: starts (evidence: `main.py`)
- Main controller → Settings: loads and saves (evidence: `controllers/main_controller.py`)
- Main controller → Main window: creates and connects (evidence: `controllers/main_controller.py`)
- Main window → Controls and telemetry: uses controls (evidence: `ui/main_window.py`)
- Main window → Theme styles: applies styles (evidence: `ui/main_window.py`)
- User → Main window: selects source (evidence: `ui/main_window.py`)
- Main window → Main controller: emits actions (evidence: `controllers/main_controller.py`)
- Main controller → Inference worker: starts and configures (evidence: `controllers/main_controller.py`)
- Video or webcam → Inference worker: supplies frames (evidence: `README.md`)
- Inference worker → YOLO and ByteTrack: updates tracks (evidence: `services/inference_worker.py`)
- YOLO and ByteTrack → Detection data models: creates tracked objects (evidence: `tracker/bytetrack_impl.py`)
- Inference worker → Detection data models: creates telemetry and logs (evidence: `services/inference_worker.py`)
- YOLO and ByteTrack → YOLO weights service: runs inference (evidence: `README.md`)
- Inference worker → Main window: emits frames and telemetry (evidence: `controllers/main_controller.py`)
- Inference worker → Recorded video: writes recording (evidence: `services/inference_worker.py`)
- Main controller → Export and capture helpers: exports and captures (evidence: `controllers/main_controller.py`)
- Export and capture helpers → Detection CSV: writes detection logs (evidence: `utils/helpers.py`)
- Export and capture helpers → Screenshot image: saves captured frame (evidence: `utils/helpers.py`)
