# visibility

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

Calibrated image and depth evidence for measurement eligibility.

## Classes

| Name | Description |
| --- | --- |
| [`Visibility`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/visibility.md#visibility-Classes-Visibility) | Classify proposal visibility across calibrated images with a per-scene cache. |

### class `Visibility`

```python
class Visibility
```

Classify proposal visibility across calibrated images with a per-scene cache.

One clear retained view makes a candidate eligible. Candidates blocked in every view are partially visible. Insufficient or
conflicting evidence is uncertain. Pixel thresholds apply to the delivered image grids, and depth thresholds use millimeters. The
factory supplies these frozen settings.

The cache belongs to one component instance. Scenes must not be processed concurrently on that instance. Input arrays remain
unchanged until all projection and validation work for a scene has completed.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `boundary_band_px` | `int` | Maximum pixel offset for probes around a silhouette edge. |
| `boundary_contrast_intensity` | `float` | Minimum image-intensity contrast at an edge. |
| `boundary_contrast_window_px` | `int` | Image window size for local contrast evidence. |
| `boundary_depth_gap_mm` | `float` | Minimum depth difference supporting a boundary. |
| `boundary_exterior_px` | `int` | Exterior image-window width for boundary evidence. |
| `boundary_probe_stride` | `int` | Stride factor reducing the number of edge samples. |
| `depth_cell_px` | `int` | Pixel side length of a nearest-depth grid cell. |
| `frame_continuation_px` | `int` | Maximum edge-to-frame distance checked for continuation. |
| `frame_margin_px` | `int` | Required image margin around a projected silhouette. |
| `max_hull_gap_fraction` | `float` | Maximum fraction of convex-hull area missing from the observed silhouette. Zero disables recovery. |
| `min_depth_coverage_fraction` | `float` | Required observed coverage of the silhouette. |
| `min_edge_support_fraction` | `float` | Required supported fraction of each silhouette edge. |
| `min_occlusion_cells` | `int` | Minimum connected nearer-foreground area in grid cells. |
| `occlusion_depth_mm` | `float` | Nearer-foreground gap used to identify occlusion. |
| `occlusion_min_height_mm` | `float` | Foreground height for occlusion evidence. |
| `projection_stride` | `int` | Row stride for shared scene projection. |
| `silhouette_close_radius_cells` | `int` | Morphological closing radius in grid cells. |
| `silhouette_simplify_px` | `float` | Pixel tolerance for polygon approximation. |

Methods

| Name | Description |
| --- | --- |
| [`begin`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/visibility.md#visibility-Classes-Visibility-begin) | Reset scene state and schedule shared projections on the caller's pool. |
| [`prepare`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/visibility.md#visibility-Classes-Visibility-prepare) | Prepare shared depth grids for one scene's nonoverlapping proposals. |
| [`validate_candidate`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/visibility.md#visibility-Classes-Visibility-validate_candidate) | Return measurement eligibility from all retained calibrated views. |

#### method `begin`

```python
def begin(scene, foreground_min_height_mm, pool: ThreadPoolExecutor, *, heights=None)
```

Reset scene state and schedule shared projections on the caller's pool.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `scene` |  | Scene whose arrays remain stable until scheduled work completes. | required |
| `foreground_min_height_mm` |  | Detection's lower foreground height threshold. | required |
| `pool` | `ThreadPoolExecutor` | Executor retained by the caller until all submitted work finishes. | required |
| `heights` |  | Optional signed heights aligned with the scene cloud rows. | `None` |

#### method `prepare`

```python
def prepare(scene: Scene, segments: list[Segment], *, pool=None)
```

Prepare shared depth grids for one scene's nonoverlapping proposals.

Matching projections from `begin` are reused, and per-view grid work completes before cached validation starts. Overlapping
segments disable the shared cache, so validation uses independent projections instead. The caller remains responsible for
completing work scheduled by `begin`.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `scene` | `Scene` | Scene associated with the supplied segments. | required |
| `segments` | `list[Segment]` | Proposed source-cloud row sets in candidate order. | required |
| `pool` |  | Optional caller-owned executor. An omitted pool creates an executor scoped to this preparation call. | `None` |

#### method `validate_candidate`

```python
def validate_candidate(scene: Scene, candidate: Segment) -> CandidateDecision
```

Return measurement eligibility from all retained calibrated views.

Prepared grids are reused only for the same scene object and an exactly matching segment. Other candidates are projected
independently. This call checks clipping, observed depth coverage, occlusion and edge support.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `scene` | `Scene` | Scene supplying the cloud, plane and calibrated view pixels. | required |
| `candidate` | `Segment` | Source-cloud indices of one proposed object. | required |

Returns

| Type | Description |
| --- | --- |
| `CandidateDecision` | `eligible` if any view is clear, `partially_visible` if every view is blocked, or `uncertain` otherwise, including scenes with no views. |

## Module Attributes

| Name | Description |
| --- | --- |
| [`ViewDecision`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/visibility.md#visibility-Module-Attributes-ViewDecision) |  |

### type alias `ViewDecision`

```python
ViewDecision = Literal['clear', 'blocked', 'uncertain']
```
