Skip to content

Commit a48cff3

Browse files
committed
docs: document perception ownership split and align TASK_STATUS with grounded implementation
1 parent adc581a commit a48cff3

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Perception Ownership Split (Python vs. Rust)
2+
3+
This document defines the architectural boundary between Python-based prototyping and Rust-based performance/determinism for the HoopSense perception layer.
4+
5+
## Current State (Stage 1: Python-Heavy)
6+
- **Ingestion:** Python (OpenCV)
7+
- **Detection & Tracking:** Python (Ultralytics BoT-SORT)
8+
- **Pose Estimation:** Python (Ultralytics YOLOv8-pose)
9+
- **Spatial Resolution:** Rust (SpatialResolver via Bridge)
10+
- **Behavior Engine:** Python (PossessionEngine + DSL Evaluator)
11+
- **Ledger:** Rust (GameStateLedger)
12+
13+
## Proposed Target State (Stage 2: Deterministic Core)
14+
15+
### 1. The Python Frontier (The "Eye")
16+
**Responsibility:** Rapid experimentation with SOTA ML models.
17+
- **ML Inference:** Detection, Pose, and OCR models should remain in Python to leverage optimized PyTorch/TensorRT ecosystems.
18+
- **Audio Analysis:** Python (AudioHead) for referee whistle detection.
19+
- **Initial JSONL Production:** Emitting raw "Shush-P" streams.
20+
21+
### 2. The Rust Interior (The "Brain")
22+
**Responsibility:** Performance-critical processing, temporal consistency, and geometric grounding.
23+
- **Track Management (Move from Python):** Implementation of the `TrackManager` and Kalman Filters should migrate to Rust. This ensures that track-state is consistent between real-time inference and offline re-processing.
24+
- **Kinematic Lifting (Move from Python):** The `lift_keypoints_to_3d` logic should be entirely in Rust to ensure bone-length constraints are enforced at the type-system level.
25+
- **Possession Logic (Move from Python):** The `PossessionEngine` should migrate to Rust. Global ball-player proximity is a geometric query that belongs in the `GeometricReferee`.
26+
27+
## Migration Rationale
28+
29+
| Component | Target | Rationale |
30+
| :--- | :--- | :--- |
31+
| **TrackManager** | Rust | High-frequency update loop; memory safety for large track sets. |
32+
| **Kalman Filter** | Rust | Deterministic floating-point math; reusable by multiple agents. |
33+
| **PossessionEngine**| Rust | Transitions system from perception to rules; must be bug-free. |
34+
| **Model Inference** | Python | Fragility of ML library bindings in Rust; Python ecosystem is superior. |
35+
36+
## First Migration Target: TrackManager
37+
The `TrackManager` is the ideal first candidate for migration (L3.37). By moving tracking state to Rust, we can:
38+
1. Remove the `deque` history management in Python.
39+
2. Perform multi-track spatial reasoning without crossing the bridge for every player.
40+
3. Ensure that track persistence logic is identical across ARM64 and x86 targets.

pipelines/geometry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import json
22
from dataclasses import asdict
33
from dataclasses import dataclass
4+
from typing import Dict
45
from typing import Iterable
6+
from typing import Union
57

68
import numpy as np
79

@@ -43,7 +45,7 @@ def lift_keypoints_to_3d(kpts_2d: np.ndarray, h_matrix: np.ndarray, *, z_scale:
4345
return np.asarray(lifted, dtype=float)
4446

4547

46-
def homography_sanity(h_matrix: np.ndarray) -> dict[str, float | bool]:
48+
def homography_sanity(h_matrix: np.ndarray) -> Dict[str, Union[float, bool]]:
4749
h_matrix = np.asarray(h_matrix, dtype=float)
4850
if h_matrix.shape != (3, 3):
4951
raise ValueError(f"Expected (3, 3) homography matrix, got {h_matrix.shape}")

0 commit comments

Comments
 (0)