track_sequence

Contents

track_sequence#

rapidtools.processing.street_tracking.track_sequence(observations: Sequence[Observation], project: Callable[[float, float], tuple[float, float]], max_gap_frames: int = 4, base_gate_deg: float = 6.0, gate_m: float = 2.5, gate_fraction: float = 0.1, loose_gate_deg: float = 45.0, min_object_width_m: float = 1.0) → list[list[Observation]][source]#

Link the sightings of one sequence into tracks, one per object.

Frames are visited in capture order. For every live track the bearing the object should have from the new camera position is predicted (from the track’s current position estimate, or its last bearing when it has none yet) and detections are assigned to tracks by the Hungarian algorithm on the normalised bearing difference plus a mild size term. Two detections in one frame can never join the same track, and a track not seen for max_gap_frames frames is closed.

Parameters:
  • observations – Sightings of one class in one sequence with bearing set (see localize()). Those with a range_m seed the position estimate.

  • project – Local metre projection shared by the caller.

  • max_gap_frames – Frames a track may miss before it is closed.

  • base_gate_deg – Minimum angular gate for a track with a position.

  • gate_m – Ground-distance tolerance behind the angular gate.

  • gate_fraction – Extra tolerance as a fraction of the distance.

  • loose_gate_deg – Widest gate ever used, for a close object whose bearing swings quickly between frames.

  • min_object_width_m – Narrowest real object of this class. With the outline’s angular width it bounds how close the object can be, hence how far its bearing can move while the camera advances; a track without a reliable position is gated by that bound instead of loose_gate_deg.

Returns:

list[list[Observation]] – The tracks, each in capture order.

Example

>>> from rapidtools.processing.street_localization import local_projection
>>> project, _ = local_projection(-117.4, 47.7)
>>> tracks = track_sequence(sightings, project)
>>> [len(t) for t in tracks]
[7, 6, 1]