fuse_view_detections

fuse_view_detections#

rapidtools.processing.instance_fusion.fuse_view_detections(detections: Sequence[ViewDetection], windows: Mapping[Hashable, BaseGeometry], *, link_iou: float = 0.5, neck_width: float = 1.0, min_area: float = 3.0, resolution: float | None = None, resolve_conflicts: bool = True) → list[FusedObject][source]#

Fuse detections from overlapping views into one outline per object.

See the module docstring for the method.

Parameters:
  • detections – Detections from all views, in a planar CRS.

  • windows – For every view, the area it covered (its tile or crop footprint, without padding), in the same CRS.

  • link_iou – Two detections from different views are the same object when their intersection over union inside the views’ common window reaches this value.

  • neck_width – Detections are cut where they narrow below this width (CRS units); 0 disables the cut.

  • min_area – Parts and objects smaller than this are dropped.

  • resolution – Grid cell for the consensus outlines; by default about a hundredth of the object’s size, between 0.05 and 0.25.

  • resolve_conflicts – Drop group detections and remove overlaps between objects.

Returns:

list[FusedObject] – The fused objects.

Raises:

KeyError – If a detection’s view has no window.

Example

>>> objects = fuse_view_detections(detections, windows, link_iou=0.4)
>>> objects[0].geometry.area > 0
True