# box_measurer

Python API: `depthai_nodes.node.box_measurer`

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

## Classes

### BoxMeasurer

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)
into a
[BoxDimensioner](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/box_dimensioner/box_dimensioner.md).
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]"`.

#### Methods

##### init

```python
def __init__(self):
```

Create the detection and dimensioning subnodes.

##### 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.

Parameters

 * `color` (`dai.Node.Output`): Color stream to detect boxes in.
 * `pointCloud` (`dai.Node.Output`): Output emitting organized `dai.PointCloudData` in millimeters.
 * `pointCloudSize` (`tuple[int, int]`): Cloud `(width, height)` in points.
 * `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)
   is called.
 * `confidenceThreshold` (`float`): Minimum detection confidence, between zero and one.

Returns

 * `BoxMeasurer`: The configured node instance.

Raises

 * `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.

##### clearSupportPlane

```python
def clearSupportPlane(self):
```

Stop measuring from the next frame.

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

##### getSupportPlane

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

Return the active support plane.

Returns

 * `SupportPlane or None`: The active support plane, if set.

##### run

```python
def run(self):
```

Do nothing: the subnodes do the work.

##### setConfidenceThreshold

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

Change the minimum detection confidence while the pipeline runs.

Parameters

 * `confidenceThreshold` (`float`): Minimum detection confidence, between zero and one.

Raises

 * `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.

##### 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.

Parameters

 * `supportPlane` (`SupportPlane`): The new active support plane.

Raises

 * `TypeError`: If `supportPlane` is not a `SupportPlane`.

#### Attributes

##### boxCloudOutput

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

Returns

 * `dai.Node.Output`: The box point-cloud output.

##### out

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).
