pairs_to_compare

pairs_to_compare#

rapidtools.processing.reid.pairs_to_compare(candidates: Sequence[ReidCandidate], max_distance_m: float = 6.0, require_different_sequence: bool = True) → list[tuple[str, str]][source]#

List the candidate pairs whose appearance is worth comparing.

A pair qualifies when the two positions are within max_distance_m, the candidates share no frame, and (by default) they come from different capture sequences. A grid index with cells of max_distance_m keeps this linear in the number of candidates for a city-scale survey.

Parameters:
  • candidates – Candidate records with unique keys.

  • max_distance_m – Largest great-circle separation to consider.

  • require_different_sequence – Skip pairs that share a sequence id.

Returns:

list[tuple[str, str]] – Key pairs in input order, each listed once.

Example

>>> a = ReidCandidate('a', 0.0, 0.0, frozenset({'s1'}), ('i1',))
>>> b = ReidCandidate('b', 0.00003, 0.0, frozenset({'s2'}), ('i2',))
>>> c = ReidCandidate('c', 0.001, 0.0, frozenset({'s2'}), ('i3',))
>>> pairs_to_compare([a, b, c], max_distance_m=6.0)
[('a', 'b')]