polygon_width_px#
- rapidtools.processing.reid.polygon_width_px(polygon: Sequence[tuple[float, float]], image_width: int, panorama: bool = True) float[source]#
Width of a detection outline in pixels of the image it was drawn on.
- Parameters:
polygon – Detection outline in normalised image coordinates.
image_width – Width in pixels of the image the width is wanted for.
panorama – Treat a span wider than half the image as an object that straddles the seam of an equirectangular panorama.
- Returns:
float – Width in pixels; zero for an empty polygon.
Example
>>> round(polygon_width_px([(0.40, 0.5), (0.45, 0.5), (0.45, 0.6)], 2048), 1) 102.4 >>> round(polygon_width_px([(0.98, 0.5), (0.02, 0.5)], 2048), 1) # seam 81.9