1
0
forked from HQU-gxy/CVTH3PE

refactor: Update type hints and enhance affinity calculations in playground.py

- Changed function signatures to use `Sequence` instead of `list` for better type flexibility.
- Introduced a new function `calculate_tracking_detection_affinity` to streamline the calculation of affinities between tracking and detection objects.
- Refactored existing affinity calculation logic to improve clarity and performance, leveraging the new affinity function.
- Removed commented-out code to clean up the implementation and enhance readability.
This commit is contained in:
2025-04-27 17:45:31 +08:00
parent 4f48c78cfb
commit 41e0141bde
2 changed files with 77 additions and 47 deletions

View File

@ -1,7 +1,7 @@
from collections import OrderedDict, defaultdict
from dataclasses import dataclass
from datetime import datetime
from typing import Any, TypeAlias, TypedDict, Optional
from typing import Any, TypeAlias, TypedDict, Optional, Sequence
from beartype import beartype
import jax
@ -463,7 +463,7 @@ class Detection:
def classify_by_camera(
detections: list[Detection],
detections: Sequence[Detection],
) -> OrderedDict[CameraID, list[Detection]]:
"""
Classify detections by camera
@ -677,7 +677,7 @@ def compute_affinity_epipolar_constraint_with_pairs(
def calculate_affinity_matrix_by_epipolar_constraint(
detections: list[Detection] | dict[CameraID, list[Detection]],
detections: Sequence[Detection] | dict[CameraID, Sequence[Detection]],
alpha_2d: float,
) -> tuple[list[Detection], Num[Array, "N N"]]:
"""