refactor: Improve timestamp handling in camera affinity matrix calculation
- Replaced direct access to tracking and detection timestamps with a more efficient use of `itertools.chain` to gather timestamps, enhancing readability and performance in `calculate_camera_affinity_matrix_jax`. - Maintained precision in timestamp calculations to ensure accurate results in affinity computations.
This commit is contained in:
@ -20,6 +20,7 @@ from copy import deepcopy as deep_copy
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta
|
||||
from functools import partial, reduce
|
||||
from itertools import chain
|
||||
from pathlib import Path
|
||||
from typing import (
|
||||
Any,
|
||||
@ -1055,10 +1056,11 @@ def calculate_camera_affinity_matrix_jax(
|
||||
# sub‑second detail (resolution ≈ 200 ms). Keep them in float64 until
|
||||
# after subtraction so we preserve Δt‑on‑the‑order‑of‑milliseconds.
|
||||
# --- timestamps ----------
|
||||
tracking0 = next(iter(trackings))
|
||||
detection0 = next(iter(camera_detections))
|
||||
t0 = min(
|
||||
tracking0.last_active_timestamp, detection0.timestamp
|
||||
chain(
|
||||
(trk.last_active_timestamp for trk in trackings),
|
||||
(det.timestamp for det in camera_detections),
|
||||
)
|
||||
).timestamp() # common origin (float)
|
||||
ts_trk = jnp.array(
|
||||
[trk.last_active_timestamp.timestamp() - t0 for trk in trackings],
|
||||
|
||||
Reference in New Issue
Block a user