views_for_reid

Contents

views_for_reid#

rapidtools.processing.reid.views_for_reid(observations: Sequence[Observation], image_width: int, min_width_px: float = 100, reference_width: int = 2048) → list[Observation][source]#

The sightings of a candidate worth cropping for re-identification.

Sightings are ordered widest first, so the first one that can be cropped is the most informative, and those narrower than min_width_px (measured on a thumbnail reference_width pixels wide, then scaled to image_width) are left out. A candidate with no sighting wide enough gets no crop and is never merged by appearance.

Parameters:
  • observations – Sightings of one candidate.

  • image_width – Width in pixels of the thumbnails that will be cropped.

  • min_width_px – Narrowest acceptable detection on the reference thumbnail. 0 keeps every sighting.

  • reference_width – Thumbnail width the threshold is quoted for.

Returns:

list[Observation] – Acceptable sightings, widest first.

Example

>>> from rapidtools.core import Observation
>>> wide = Observation('i1', 'car', [(0.4, 0.5), (0.5, 0.5), (0.5, 0.6)],
...                    0.0, 0.0, 0.0)
>>> narrow = Observation('i2', 'car', [(0.4, 0.5), (0.41, 0.5), (0.41, 0.6)],
...                      0.0, 0.0, 0.0)
>>> [o.image_id for o in views_for_reid([narrow, wide], 1024)]
['i1']