forked from HQU-gxy/CVTH3PE
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 dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from functools import partial, reduce
|
from functools import partial, reduce
|
||||||
|
from itertools import chain
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
@ -1055,10 +1056,11 @@ def calculate_camera_affinity_matrix_jax(
|
|||||||
# sub‑second detail (resolution ≈ 200 ms). Keep them in float64 until
|
# sub‑second detail (resolution ≈ 200 ms). Keep them in float64 until
|
||||||
# after subtraction so we preserve Δt‑on‑the‑order‑of‑milliseconds.
|
# after subtraction so we preserve Δt‑on‑the‑order‑of‑milliseconds.
|
||||||
# --- timestamps ----------
|
# --- timestamps ----------
|
||||||
tracking0 = next(iter(trackings))
|
|
||||||
detection0 = next(iter(camera_detections))
|
|
||||||
t0 = min(
|
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)
|
).timestamp() # common origin (float)
|
||||||
ts_trk = jnp.array(
|
ts_trk = jnp.array(
|
||||||
[trk.last_active_timestamp.timestamp() - t0 for trk in trackings],
|
[trk.last_active_timestamp.timestamp() - t0 for trk in trackings],
|
||||||
|
|||||||
Reference in New Issue
Block a user