feat: Integrate pyrsistent for enhanced tracking state management

- Added `pyrsistent` as a dependency to manage historical detections in the `Tracking` class, improving data integrity and immutability.
- Updated the `GlobalTrackingState` to include historical detections using `PVector`, facilitating better tracking of past detections.
- Introduced a new `update_tracking` function to handle timestamp updates for tracking objects, enhancing the tracking logic.
- Refactored imports and type hints for improved organization and clarity across the codebase.
This commit is contained in:
2025-04-30 10:04:39 +08:00
parent cea21dc434
commit 072bf1c46f
4 changed files with 54 additions and 2 deletions

View File

@ -13,12 +13,12 @@ from typing import (
overload,
)
import jax
import jax.numpy as jnp
from beartype import beartype
from beartype.typing import Mapping, Sequence
from jax import Array
from jaxtyping import Array, Float, Int, jaxtyped
from pyrsistent import PVector
from app.camera import Detection
@ -33,8 +33,20 @@ class Tracking:
keypoints: Float[Array, "J 3"]
"""
The 3D keypoints of the tracking
Used for calculate affinity 3D
"""
last_active_timestamp: datetime
"""
The last active timestamp of the tracking
"""
historical_detections: PVector[Detection]
"""
Historical detections of the tracking.
Used for 3D re-triangulation
"""
velocity: Optional[Float[Array, "3"]] = None
"""