discover_instances

discover_instances#

rapidtools.processing.street_instances.discover_instances(observations: Sequence[Observation], clusters: Mapping[str, tuple[str, str]], *, cache_dir: str | Path | None = None, camera_height_m: float = 2.4, max_range_m: float = 40.0, min_vote_fraction: float = 0.7, min_votes: int = 3, min_overlap: float = 0.5, min_height_m: float = 2.0, cell_m: float = 0.5, min_cell_points: int = 2, min_gap_m: float = 1.0, min_points: int = 40, min_frontage_m: float = 4.0, assumed_depth_m: float = 10.0, footprint: str = 'stepped', max_views: int = 12, max_workers: int = 8, project: Callable[[float, float], tuple[float, float]] | None = None, unproject: Callable[[float, float], tuple[float, float]] | None = None, loader: Callable[[str, str], PointCloud | None] | None = None, whole_object: Callable[[str, ndarray], Sequence[Sequence[ndarray]]] | None = None) → tuple[list[Structure], dict[str, int], Callable[[float, float], tuple[float, float]]][source]#

Find buildings from one outline per building and frame.

See the module docstring for the method.

Parameters:
  • observations – Per-building outlines (panoramas with a computed_rotation in extra). Outlines of one image that carry the same extra['instance'] are parts of one mask; an outline without it is an instance of its own.

  • clusters – For every image ID, the (cluster_id, url) of its sfm_cluster. Images without an entry are not used.

  • cache_dir – Folder where downloaded point clouds are cached.

  • camera_height_m – Camera height above the road; sets the ground level where a point cloud has no ground points of its own.

  • max_range_m – Farthest an outline collects points, and farthest frame a building gets a sighting from.

  • min_vote_fraction – Share of the frames that see a point that must place it inside an outline.

  • min_votes – Frames that must place a point inside an outline.

  • min_overlap – Share of each other’s points two outlines must hold to be taken for the same building.

  • min_height_m – Points lower than this above the ground are ignored.

  • cell_m – Ground cell used to tell wall from scattered points.

  • min_cell_points – Fewest points a wall cell holds.

  • min_gap_m – Tracks more than three times this apart along the street are never joined into one building.

  • min_points – Fewest points a building may have.

  • min_frontage_m – Shortest facade reported.

  • assumed_depth_m – Footprint depth where the rear was not seen.

  • footprint – 'stepped', 'rectangle' or 'observed', as in discover_structures().

  • max_views – Sightings kept per building; 0 keeps one per frame.

  • max_workers – Threads for point-cloud downloads.

  • project – Projection to local meters; made from the sightings when omitted.

  • unproject – Inverse of project.

  • loader – loader(cluster_id, url) returning a PointCloud, instead of downloading (for tests and offline use).

  • whole_object – whole_object(image_id, points) returning the candidate outlines of the object under a few normalized image points, each a list of rings (a promptable segmentation model). When given, it decides whether two tracks are wings of one building; otherwise touching outlines do.

Returns:

tuple[list[Structure], dict[str, int], Unproject] – The buildings, counters describing the run and the inverse projection.

Example

>>> structures, counts, unproject = discover_instances(
...     outlines, clusters, cache_dir='point_clouds'
... )
>>> structures[0].frontage_m, len(structures[0].members)
(21.4, 12)