merge_estimates

merge_estimates#

rapidtools.processing.street_tracking.merge_estimates(estimates: Sequence[ObjectEstimate], max_distance_m: float = 6.0, chi2: float = 9.21, floor_m: float = 0.5, min_separation_m: float = 1.5, max_solid_separation_m: float = 2.5) → list[ObjectEstimate][source]#

Fuse estimates of the same object; keep different objects apart.

Candidates are visited from the most to the least certain. A candidate joins an existing object when it lies within max_distance_m of it, passes the Mahalanobis gate under the combined covariance, and shares no frame with it (two detections in one frame are two objects). Positions are fused by information weighting, so a precise triangulation is not dragged around by a vague single view. floor_m is added to both covariances for the gate only: an object’s apparent centre wanders by that much with the viewpoint, which a triangulation covariance does not know about. Two solid triangulations (see is_weak_estimate()) are never fused when more than max_solid_separation_m apart: a precise position from one pass and another from a second pass that disagree by more than a car’s width are two cars parked next to each other, one of them hidden in each pass, not one car (the halves of a long vehicle are reunited earlier by merge_by_rays()).

Example

>>> import numpy as np
>>> a = ObjectEstimate(0.0, 0.0, np.eye(2) * 0.1, [], 'triangulated')
>>> b = ObjectEstimate(0.4, 0.2, np.eye(2) * 0.5, [], 'single_view')
>>> c = ObjectEstimate(5.0, 0.0, np.eye(2) * 0.1, [], 'triangulated')
>>> [round(e.x, 2) for e in merge_estimates([a, b, c])]
[0.07, 5.0]