# geometry

Python API: `depthai_nodes.algorithms.measure_anything.implementation.geometry`

Foreground segmentation and support-plane cuboid fitting in millimeters.

## Functions

| Name | Description |
| --- | --- |
| [`detect`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/geometry.md#geometry-Functions-detect) | Propose connected foreground segments in source point order. |
| [`measure`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/geometry.md#geometry-Functions-measure) | Fit supported footprint bounds and height for one eligible object's points. |

### function `detect`

```python
def detect(
    scene: Scene,
    *,
    heights: NDArray | None = None,
    foreground_min_height_mm: float,
    foreground_max_height_mm: float,
    voxel_size_mm: float,
    cluster_radius_mm: float,
    cluster_min_voxels: int,
    cluster_min_points: int,
) -> list[Segment]
```

Propose connected foreground segments in source point order.

Height filtering selects points above the support plane. Voxel centroids define connected components, and both voxel-count and
point-count limits determine which components survive. Visibility is checked by the enclosing candidate callback after this
proposal stage.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `scene` | `Scene` | Source XYZ and upward support plane in a common metric frame. | required |
| `heights` | `NDArray | None` | Optional precomputed signed heights aligned with the cloud rows. | `None` |
| `foreground_min_height_mm` | `float` | Inclusive lower foreground height in millimeters. | required |
| `foreground_max_height_mm` | `float` | Inclusive upper foreground height in millimeters. | required |
| `voxel_size_mm` | `float` | Voxel side length for connectivity centroids. | required |
| `cluster_radius_mm` | `float` | Maximum centroid separation for a connectivity edge. | required |
| `cluster_min_voxels` | `int` | Minimum number of voxels in an accepted component. | required |
| `cluster_min_points` | `int` | Minimum number of source points in an accepted component. | required |

Returns

| Type | Description |
| --- | --- |
| `list[Segment]` | Segments in connected-component order. Each segment contains int32 cloud indices in source-row order. No accepted components produces an empty list. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the cloud is too large for int32 segment indices. |

### function `measure`

```python
def measure(
    parcel: PointCloud,
    plane: SupportPlane,
    *,
    outlier_voxel_size_mm: float,
    outlier_radius_mm: float,
    outlier_min_neighbor_voxels: int,
    footprint_edge_band_mm: float,
    min_footprint_edge_cells: int,
    min_footprint_side_mm: float,
    min_height_mm: float,
    height_support_band_mm: float,
    min_height_support_voxels: int,
    footprint_edge_quantile: float | None = None,
    height_cell_quantile: float | None = None,
    orientation_tail_fraction: float = 0.0,
    extent_quantile_window_mm: float | None = None,
    preserve_separated_extents: bool = False,
) -> Cuboid | None
```

Fit supported footprint bounds and height for one eligible object's points.

Local voxel support removes isolated returns before fitting a rectangle in the plane's tangent coordinates. Supported edge extrema
refine the footprint. Independent per-cell maxima determine the height. Points and plane must share a coordinate frame, with a
unit upward plane normal and millimeter units.

These arguments are bound internally from the selected frozen configuration.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `parcel` | `PointCloud` | Finite XYZ samples belonging to one eligible object. | required |
| `plane` | `SupportPlane` | Support plane for footprint placement and signed heights. | required |
| `outlier_voxel_size_mm` | `float` | Voxel side length, also used for edge and height cells. | required |
| `outlier_radius_mm` | `float` | Search radius for neighboring support voxels. | required |
| `outlier_min_neighbor_voxels` | `int` | Required neighboring voxels, excluding the voxel itself. | required |
| `footprint_edge_band_mm` | `float` | Band width for mutually supported edge extrema. | required |
| `min_footprint_edge_cells` | `int` | Required cross-strip extrema supporting an edge. | required |
| `min_footprint_side_mm` | `float` | Minimum accepted extent for either footprint side. | required |
| `min_height_mm` | `float` | Minimum height included in roof-support cells. | required |
| `height_support_band_mm` | `float` | Band width for mutually supported cell maxima. | required |
| `min_height_support_voxels` | `int` | Required cell maxima supporting a height. | required |
| `footprint_edge_quantile` | `float | None` | Optional quantile for supported footprint extrema. | `None` |
| `height_cell_quantile` | `float | None` | Optional quantile for supported height maxima. | `None` |
| `orientation_tail_fraction` | `float` | Fraction of voxel-centroid tails ignored when refining orientation. Zero retains the initial rectangle orientation. | `0.0` |
| `extent_quantile_window_mm` | `float | None` | Optional window below the highest supported extreme within which quantiles are evaluated. | `None` |
| `preserve_separated_extents` | `bool` | Preserve a separated group containing the highest supported extreme during quantile selection. | `False` |

Returns

| Type | Description |
| --- | --- |
| `Cuboid | None` | A cuboid with its base center on the plane and length at least width. `height_mm=None` denotes a usable footprint without supported height. Returns `None` when too few supported points remain or the footprint is smaller than the configured minimum side length. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the orientation tail fraction or extent window is invalid. |
