merge_pieces#
- rapidtools.processing.street_tracking.merge_pieces(estimates: Sequence[ObjectEstimate], project: Callable[[float, float], tuple[float, float]], bearing_sigma_deg: float = 0.75, object_length_m: float = 5.0, search_radius_m: float = 15.0, judge_range_m: float = 20.0, closest_k: int = 5, on_fraction: float = 0.6, evidence_fraction: float = 0.25, size_ratio: float = 1.3, solid_distance_m: float = 2.5, solid_parallax_deg: float = 45.0, solid_sigma_m: float = 0.25, far_fraction: float = 0.3, far_distance_m: float = 4.0) list[ObjectEstimate][source]#
Fold objects that are really pieces of a neighbour into that neighbour.
Where several vehicles line up along the camera’s line of sight (a driveway seen end-on, cars down the street) the tracker can slide from one to the next, and a detector can cut one car in two past a pole or into a front and a rear. The result is a second object a few metres from a well-located one, made of sightings that show the same vehicle. The two share frames, which the other merge stages take as proof of two objects, so they are judged here on what their sightings show instead.
A less precise object
Bjoins a more precise triangulatedAwhen:most of
B’s rays pass nearA(asmerge_by_rays()tests),B’sclosest_ksightings withinjudge_range_m, the ones that define whatBis, mostly (on_fraction) showA: the ray passes within a quarter object size ofAand the ground-contact range lands withinmax(2.5 m, 35 %)ofA’s position. This is decisive on its own, whateverB’s own triangulation says: a low-parallax track lands metres from where its sightings point,no more than
evidence_fractionof those frames contradict it, where a contradiction is a frame in whichA’s own sighting showsAwhileB’s does not (both sightings showingAare two pieces of one vehicle;A’s sighting not showingAwas the tracker astray and proves nothing). One such frame in whichAwas seen withinjudge_range_msettles it on its own: the vehicle is right there, large and unmistakable, andB’s outline is something else,Bis not larger thansize_ratiotimesA(or the class size): a motorhome behind a pickup lines up and fails only on size,and, when
Bis solid (parallax oversolid_parallax_degand uncertainty undersolid_sigma_m) so that its own position is trustworthy, it lies withinsolid_distance_mofA.
A
Bnever seen withinjudge_range_mhas no dependable position of its own whatever its parallax: ground-contact ranges read from far away are off by a third, so its triangulation lands metres along the line of sight from the vehicle. Its closest sightings, wherever they are, define it: the ray test above runs over them rather than the whole track, whose far slivers may point anywhere. When their ground points do not land onAbut their ranges fit therange_ratio_boundsband,Bstill joins if its triangulation lies withinfar_fractionof its nearest range (at leastfar_distance_m) ofA. It may only join anAthat was itself seen withinjudge_range_m: the close pass is the dependable one and keeps the position.Akeeps its position; it gains the sightings ofBthat show it.- Parameters:
estimates – Merged candidates with
membersset.project – Local metre projection.
bearing_sigma_deg – One-sigma bearing error.
object_length_m – Typical size of the class.
search_radius_m – Only pairs this close are examined.
judge_range_m – Sightings farther than this carry ranges too noisy to judge and are ignored.
closest_k – How many of
B’s closest sightings are judged.on_fraction – Share of them that must show
A.evidence_fraction – Share of contradicting frames that blocks the merge.
size_ratio – Largest size of
Brelative toA(at least the class size) still taken for one object.solid_distance_m – Farthest a solid
Bmay lie fromA.solid_parallax_deg – Parallax from which
Bcounts as solid.solid_sigma_m – Uncertainty below which
Bcounts as solid.far_fraction – How far, as a fraction of its nearest range, a
Bnever seen withinjudge_range_mmay lie fromA.far_distance_m – Least distance allowed for such a
B.
- Returns:
list[ObjectEstimate] – The remaining objects, in input order.
Example
>>> merged = merge_pieces(estimates, project)