refactor: Update AffinityResult class to include detection handling

- Added a new `detections` attribute to the `AffinityResult` class to store detection objects used in affinity matrix calculations.
- Introduced a `tracking_detections` method to yield pairs of trackings and their corresponding detections, enhancing the functionality of the class.
- Updated type hints for improved clarity and consistency in the class definition.
This commit is contained in:
2025-04-28 19:13:23 +08:00
parent da4c51d04f
commit 6194f083cb

View File

@ -1,6 +1,7 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Sequence from typing import Sequence, Callable, Generator
from app.camera import Detection
from playground import Tracking from playground import Tracking
from beartype.typing import Sequence, Mapping from beartype.typing import Sequence, Mapping
from jaxtyping import jaxtyped, Float, Int from jaxtyping import jaxtyped, Float, Int
@ -23,12 +24,14 @@ class AffinityResult:
Trackings used to compute the affinity matrix. Trackings used to compute the affinity matrix.
""" """
indices_T: Sequence[int] detections: Sequence[Detection]
""" """
Indices of the trackings that were used to compute the affinity matrix. Detections used to compute the affinity matrix.
""" """
indices_T: Sequence[int]
indices_D: Sequence[int] indices_D: Sequence[int]
"""
Indices of the detections that were used to compute the affinity matrix. def tracking_detections(self) -> Generator[tuple[Tracking, Detection]]:
""" for t, d in zip(self.indices_T, self.indices_D):
yield (self.trackings[t], self.detections[d])