# scene

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

Scene types and calibrated 3D-to-image projection for the measurement algorithm.

## Classes

| Name | Description |
| --- | --- |
| [`CameraView`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-CameraView) | One delivered image and its calibrated scene-to-camera projection. |
| [`CandidateResult`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-CandidateResult) | A proposed segment and its measurement-eligibility decision. |
| [`Cuboid`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-Cuboid) | An oriented footprint and optional height relative to a support plane. |
| [`PointCloud`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-PointCloud) | XYZ samples in one metric scene coordinate frame. |
| [`Scene`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-Scene) | Point cloud, support plane and calibrated images for one capture interval. |
| [`SceneError`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-SceneError) | A frozen artifact or its scene metadata could not be decoded. |
| [`Segment`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-Segment) | Rows of a scene cloud belonging to one proposed object. |
| [`SupportPlane`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Classes-SupportPlane) | A unit-normal plane defining zero height in the scene frame. |

### class `CameraView`

```python
class CameraView
```

One delivered image and its calibrated scene-to-camera projection.

Calibration describes the image's actual pixel grid, including any crop, scale or rectification. Transform translations use
millimeters.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `distortion_coefficients` | `tuple[float, ...]` | Coefficients for the selected distortion model. |
| `distortion_model` | `str` | Perspective, fisheye or undistorted projection model. |
| `image` | `NDArray[np.uint8]` | Read-only uint8 RGB `(H, W, 3)` or mono `(H, W)` pixels. |
| `intrinsics` | `Matrix3` | Camera intrinsic matrix for the delivered image coordinates. |
| `role` | `CameraRole` | The color, left or right view identifier. |
| `scene_to_camera_mm` | `Matrix4` | Homogeneous transform from scene XYZ to camera XYZ. |

### class `CandidateResult`

```python
class CandidateResult
```

A proposed segment and its measurement-eligibility decision.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `decision` | `CandidateDecision` | Eligibility outcome. Only eligible segments enter measurement. |
| `segment` | `Segment` | Source-cloud rows retained for this proposal. |

### class `Cuboid`

```python
class Cuboid
```

An oriented footprint and optional height relative to a support plane.

The base center lies on the plane. The length axis is unit length and tangent to the plane. The width axis is the plane normal
crossed with the length axis. Length is at least width. This container retains geometry without validating it; the message adapter
checks the emitted result.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `base_center_mm` | `Vec3` | Footprint center in the scene frame, in millimeters. |
| `height_mm` | `float | None` | Supported height above the plane, or `None` if unavailable. |
| `length_axis` | `Vec3` | Unit vector along the longer footprint side. |
| `length_mm` | `float` | Longer footprint extent in millimeters. |
| `width_mm` | `float` | Shorter footprint extent in millimeters. |

### class `PointCloud`

```python
class PointCloud
```

XYZ samples in one metric scene coordinate frame.

The container retains the supplied array without copying or validating it. Computation expects finite float32 points and treats
the array as read-only.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `frame` | `str` | Coordinate-frame identifier shared with the support plane. |
| `xyz_mm` | `NDArray[np.float32]` | An `(N, 3)` array in millimeters. Row order defines segment indices. |

### class `Scene`

```python
class Scene
```

Point cloud, support plane and calibrated images for one capture interval.

The cloud and plane share a coordinate frame. Each view maps that frame to its camera coordinates. Scene arrays remain unchanged
during detection, visibility checks and measurement.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `cloud` | `PointCloud` | Source XYZ samples whose row ordering defines all segments. |
| `plane` | `SupportPlane` | Upward support plane used for foreground heights and cuboid placement. |
| `views` | `tuple[CameraView, ...]` | Retained calibrated color and mono views for visibility checks. |

### exception `SceneError`

```python
class SceneError(ValueError)
```

A frozen artifact or its scene metadata could not be decoded.

### class `Segment`

```python
class Segment
```

Rows of a scene cloud belonging to one proposed object.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `point_indices` | `NDArray[np.int32]` | Unique int32 indices into the scene cloud. Their order is retained when object points are extracted. |

### class `SupportPlane`

```python
class SupportPlane
```

A unit-normal plane defining zero height in the scene frame.

Signed height in millimeters is `xyz_mm @ normal + offset_mm`. The normal points upward from the support surface. The message
adapter establishes this orientation before constructing the computation scene.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `frame` | `str` | Coordinate-frame identifier shared with the point cloud. |
| `normal` | `Vec3` | Unit normal expressed in the scene coordinate frame. |
| `offset_mm` | `float` | Constant term in the plane equation, in millimeters. |

## Functions

| Name | Description |
| --- | --- |
| [`project_points`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Functions-project_points) | Project scene XYZ into a calibrated image while preserving point order. |

### function `project_points`

```python
def project_points(xyz_mm: NDArray, view: CameraView) -> NDArray[np.float64]
```

Project scene XYZ into a calibrated image while preserving point order.

The view's transform and lens model produce image coordinates without clipping, resizing or rectifying the image. Points with
nonpositive camera Z or nonfinite projections produce NaN rows. Finite pixels outside the image remain available for the caller to
clip.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `xyz_mm` | `NDArray` | An `(N, 3)` array of scene coordinates in millimeters. | required |
| `view` | `CameraView` | Image-grid calibration and scene-to-camera transform. | required |

Returns

| Type | Description |
| --- | --- |
| `NDArray[np.float64]` | A float64 `(N, 3)` array containing pixel u, pixel v and camera Z in millimeters for each input row. |

Raises

| Type | Description |
| --- | --- |
| `SceneError` | If XYZ has the wrong shape or the lens model and coefficient count are unsupported. |

## Module Attributes

| Name | Type | Description |
| --- | --- | --- |
| [`CAMERA_ROLES`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-CAMERA_ROLES) | `tuple[CameraRole, ...]` |  |
| [`CameraRole`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-CameraRole) |  |  |
| [`CandidateDecision`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-CandidateDecision) |  |  |
| [`InputMode`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-InputMode) |  |  |
| [`Matrix3`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-Matrix3) |  |  |
| [`Matrix4`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-Matrix4) |  |  |
| [`PlaneEstimator`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-PlaneEstimator) |  |  |
| [`Vec3`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-Vec3) |  |  |
| [`Vec4`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/algorithms/measure_anything/implementation/scene.md#scene-Module-Attributes-Vec4) |  |  |

### constant `CAMERA_ROLES`

```python
CAMERA_ROLES: tuple[CameraRole, ...] = ('color', 'left', 'right')
```

### type alias `CameraRole`

```python
CameraRole = Literal['color', 'left', 'right']
```

### type alias `CandidateDecision`

```python
CandidateDecision = Literal['eligible', 'background', 'partially_visible', 'uncertain']
```

### type alias `InputMode`

```python
InputMode = Literal['supplied_plane', 'estimated_plane']
```

### type alias `Matrix3`

```python
Matrix3 = tuple[Vec3, Vec3, Vec3]
```

### type alias `Matrix4`

```python
Matrix4 = tuple[Vec4, Vec4, Vec4, Vec4]
```

### type alias `PlaneEstimator`

```python
PlaneEstimator = Callable[[PointCloud, tuple[CameraView, ...], Vec3], SupportPlane]
```

### type alias `Vec3`

```python
Vec3 = tuple[float, float, float]
```

### type alias `Vec4`

```python
Vec4 = tuple[float, float, float, float]
```
