# box_measurer

Python API: `depthai_nodes.node.box_measurer`

Box measurement from color and a point cloud, composed of detection and dimensioning.

## Classes

| Name | Description |
| --- | --- |
| [`BoxMeasurer`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer) | Detect, track and measure boxes from color and a point cloud on RVC4. |

### class `BoxMeasurer`

```python
class BoxMeasurer(BaseThreadedHostNode)
```

Detect, track and measure boxes from color and a point cloud on RVC4.

Wires a
[BoxDetector](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_detector/box_detector.md#box_detector-Classes-BoxDetector)
into a
[BoxDimensioner](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_dimensioner/box_dimensioner.md#box_dimensioner-Classes-BoxDimensioner).
Color and cloud must cover the same field of view; their resolutions may differ. Boxes are measured against the active support
plane, which can come from any source. Requires open3d, installed with `pip install "depthai-nodes[box-measurement]"`.

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`boxCloudOutput`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-boxCloudOutput) | `dai.Node.Output` | Valid points under all box masks, as `dai.PointCloudData`. |
| [`out`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-out) | `dai.Node.Output` | Return the stream of [depthai_nodes.message.BoxMeasurements](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/message/box_measurements.md#box_measurements-Classes-BoxMeasurements). |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-__init__) | Create the detection and dimensioning subnodes. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-build) | Build the detector and the dimensioner. |
| [`clearSupportPlane`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-clearSupportPlane) | Stop measuring from the next frame. |
| [`getSupportPlane`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-getSupportPlane) | Return the active support plane. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-run) | Do nothing: the subnodes do the work. |
| [`setConfidenceThreshold`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-setConfidenceThreshold) | Change the minimum detection confidence while the pipeline runs. |
| [`setSupportPlane`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-setSupportPlane) | Measure against a support plane from the next frame. |

#### property `boxCloudOutput`

```python
boxCloudOutput: dai.Node.Output
```

Valid points under all box masks, as `dai.PointCloudData`.

Returns

| Type | Description |
| --- | --- |
| `dai.Node.Output` | The box point-cloud output. |

#### property `out`

```python
out: dai.Node.Output
```

Return the stream of
[depthai_nodes.message.BoxMeasurements](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/message/box_measurements.md#box_measurements-Classes-BoxMeasurements).

#### method `__init__`

```python
def __init__()
```

Create the detection and dimensioning subnodes.

#### method `build`

```python
def build(
    color: dai.Node.Output,
    pointCloud: dai.Node.Output,
    pointCloudSize: tuple[int, int],
    supportPlane: SupportPlane | None = None,
    confidenceThreshold: float = 0.5,
) -> BoxMeasurer
```

Build the detector and the dimensioner.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `color` | `dai.Node.Output` | Color stream to detect boxes in. | required |
| `pointCloud` | `dai.Node.Output` | Output emitting organized `dai.PointCloudData` in millimeters. | required |
| `pointCloudSize` | `tuple[int, int]` | Cloud `(width, height)` in points. | required |
| `supportPlane` | `SupportPlane | None` | Initial active support plane; `None` leaves boxes ineligible until [setSupportPlane](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_measurer.md#box_measurer-Classes-BoxMeasurer-setSupportPlane) is called. | `None` |
| `confidenceThreshold` | `float` | Minimum detection confidence, between zero and one. | `0.5` |

Returns

| Type | Description |
| --- | --- |
| `BoxMeasurer` | The configured node instance. |

Raises

| Type | Description |
| --- | --- |
| `ImportError` | If open3d is not installed. |
| `RuntimeError` | If the node is already built. |
| `TypeError` | If `pointCloudSize` is not a pair of integers, `supportPlane` is not a `SupportPlane` or `confidenceThreshold` is not a real number. |
| `ValueError` | If `pointCloudSize` does not have two positive values, if `confidenceThreshold` is not finite or not between zero and one, or if the device is not an RVC4. |

#### method `clearSupportPlane`

```python
def clearSupportPlane()
```

Stop measuring from the next frame.

Aggregated dimensions are reset, and boxes are ineligible until a support plane is set again.

#### method `getSupportPlane`

```python
def getSupportPlane() -> SupportPlane | None
```

Return the active support plane.

Returns

| Type | Description |
| --- | --- |
| `SupportPlane or None` | The active support plane, if set. |

#### method `run`

```python
def run()
```

Do nothing: the subnodes do the work.

#### method `setConfidenceThreshold`

```python
def setConfidenceThreshold(confidenceThreshold: float)
```

Change the minimum detection confidence while the pipeline runs.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `confidenceThreshold` | `float` | Minimum detection confidence, between zero and one. | required |

Raises

| Type | Description |
| --- | --- |
| `RuntimeError` | If the node is not built yet. |
| `TypeError` | If `confidenceThreshold` is not a real number. |
| `ValueError` | If `confidenceThreshold` is not finite or not between zero and one. |

#### method `setSupportPlane`

```python
def setSupportPlane(supportPlane: SupportPlane)
```

Measure against a support plane from the next frame.

Works before and after build, also while the pipeline runs. Aggregated dimensions are reset.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `supportPlane` | `SupportPlane` | The new active support plane. | required |

Raises

| Type | Description |
| --- | --- |
| `TypeError` | If `supportPlane` is not a `SupportPlane`. |
