# yikhow/footfallcam-staff-detection architecture

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

- Interactive diagram: https://gitdiagram.com/yikhow/footfallcam-staff-detection
- Repository: https://github.com/yikhow/footfallcam-staff-detection

## Overview

This repository is a notebook-driven staff-tag detection workflow for overhead fisheye video. Users extract and annotate sampled frames, prepare a time-ordered training set, fine-tune YOLOv8n, then upload video to a Gradio inference interface. Inference combines tag detections with hysteresis-based temporal filtering to produce annotated video, frame-level detections, and XY trajectories. The README documents these stages and outputs, but the notebooks were not sampled here, so the graph reflects documented relationships rather than inspected implementation details.

Main entry points: [`step4_inference_gui.ipynb`](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb) (Inference GUI), [`step2_data_preparation.ipynb`](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step2_data_preparation.ipynb) (Prepare dataset), [`step3_finetune.ipynb`](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step3_finetune.ipynb) (Fine-tune and evaluate), [`sample.mp4`](https://github.com/yikhow/footfallcam-staff-detection/blob/main/sample.mp4) (Sample video)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_source_video["Sample video<br/>[sample.mp4]"]
  node_extract_annotate["Extract and annotate"]
  node_labeled_frames["Labeled frames"]
  node_prepare_data["Prepare dataset"]
  node_dataset_config["Dataset config<br/>[data.yaml]"]
end

subgraph group_training["Model training"]
  node_training["Fine-tune and evaluate"]
  node_trained_model["YOLOv8n weights"]
end

subgraph group_inference["Video inference"]
  node_inference_ui["Inference GUI"]
  node_tag_detector["Staff-tag detector"]
  node_temporal_filter["Hysteresis filter"]
  node_trajectory["XY trajectory"]
end

subgraph group_results["Results"]
  node_annotated_video["Annotated video"]
  node_detection_log["Detection log"]
  node_trajectory_plot["Trajectory plot"]
end

node_operator(("User"))

node_operator -->|"provides video"| node_source_video
node_source_video -->|"samples frames"| node_extract_annotate
node_extract_annotate -->|"annotates frames"| node_labeled_frames
node_labeled_frames -->|"prepares data"| node_prepare_data
node_prepare_data -->|"configures dataset"| node_dataset_config
node_prepare_data -->|"supplies split data"| node_training
node_dataset_config -->|"configures training"| node_training
node_training -->|"saves weights"| node_trained_model
node_operator -->|"uploads video"| node_inference_ui
node_inference_ui -->|"loads model"| node_trained_model
node_inference_ui -->|"runs detection"| node_tag_detector
node_inference_ui -->|"filters detections"| node_temporal_filter
node_temporal_filter -->|"tracks coordinates"| node_trajectory
node_inference_ui -->|"outputs video"| node_annotated_video
node_inference_ui -->|"logs detections"| node_detection_log
node_inference_ui -->|"produces coordinates"| node_trajectory
node_trajectory -->|"plots trajectory"| node_trajectory_plot

click node_source_video "https://github.com/yikhow/footfallcam-staff-detection/blob/main/sample.mp4"
click node_extract_annotate "https://github.com/yikhow/footfallcam-staff-detection/blob/main/step1_extract_and_annotate.ipynb"
click node_prepare_data "https://github.com/yikhow/footfallcam-staff-detection/blob/main/step2_data_preparation.ipynb"
click node_dataset_config "https://github.com/yikhow/footfallcam-staff-detection/blob/main/dataset/data.yaml"
click node_training "https://github.com/yikhow/footfallcam-staff-detection/blob/main/step3_finetune.ipynb"
click node_inference_ui "https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb"
click node_temporal_filter "https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb"
click node_trajectory "https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb"

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_source_video,node_extract_annotate,node_labeled_frames,node_prepare_data,node_dataset_config,node_operator toneBlue
class node_training,node_trained_model toneAmber
class node_inference_ui,node_tag_detector,node_temporal_filter,node_trajectory toneMint
class node_annotated_video,node_detection_log,node_trajectory_plot toneRose
```

## Components

### Data preparation

- [Sample video](https://github.com/yikhow/footfallcam-staff-detection/blob/main/sample.mp4): `sample.mp4`
- [Extract and annotate](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step1_extract_and_annotate.ipynb): `step1_extract_and_annotate.ipynb`
- **Labeled frames**
- [Prepare dataset](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step2_data_preparation.ipynb): `step2_data_preparation.ipynb`
- [Dataset config](https://github.com/yikhow/footfallcam-staff-detection/blob/main/dataset/data.yaml): `dataset/data.yaml`

### Model training

- [Fine-tune and evaluate](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step3_finetune.ipynb): `step3_finetune.ipynb`
- **YOLOv8n weights**

### Video inference

- [Inference GUI](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb): `step4_inference_gui.ipynb`
- **Staff-tag detector**
- [Hysteresis filter](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb): `step4_inference_gui.ipynb`
- [XY trajectory](https://github.com/yikhow/footfallcam-staff-detection/blob/main/step4_inference_gui.ipynb): `step4_inference_gui.ipynb`

### Results

- **Annotated video**
- **Detection log**
- **Trajectory plot**

### Other components

- **User**

## Connections

- User → Sample video: provides video (evidence: `README.md`)
- Sample video → Extract and annotate: samples frames (evidence: `README.md`)
- Extract and annotate → Labeled frames: annotates frames (evidence: `README.md`)
- Labeled frames → Prepare dataset: prepares data (evidence: `README.md`)
- Prepare dataset → Dataset config: configures dataset (evidence: `README.md`)
- Prepare dataset → Fine-tune and evaluate: supplies split data (evidence: `README.md`)
- Dataset config → Fine-tune and evaluate: configures training (evidence: `README.md`)
- Fine-tune and evaluate → YOLOv8n weights: saves weights (evidence: `README.md`)
- User → Inference GUI: uploads video (evidence: `README.md`)
- Inference GUI → YOLOv8n weights: loads model (evidence: `README.md`)
- Inference GUI → Staff-tag detector: runs detection (evidence: `README.md`)
- Inference GUI → Hysteresis filter: filters detections (evidence: `README.md`)
- Hysteresis filter → XY trajectory: tracks coordinates (evidence: `README.md`)
- Inference GUI → Annotated video: outputs video (evidence: `README.md`)
- Inference GUI → Detection log: logs detections (evidence: `README.md`)
- Inference GUI → XY trajectory: produces coordinates (evidence: `README.md`)
- XY trajectory → Trajectory plot: plots trajectory (evidence: `README.md`)
