# depth_merger

Python API: `depthai_nodes.node.depth_merger`

## 类

### DepthMerger

将 2D 检测与对齐深度合并以生成空间检测。

> **示例**
> 使用管道、神经网络、立体节点和设备校准：

```text
depth_merger = pipeline.create(DepthMerger).build(
    output2d=nn.out,
    outputDepth=stereo.depth,
    calibData=calibration,
)
```

#### 方法

##### init

```python
def __init__(shrinkingFactor: float = 0):
```

创建空间检测输出并设置 ROI 缩放。

参数

 * `shrinkingFactor` (`float`): 在采样深度之前从每侧修剪的比例。构建调用会提供其自己的值。

##### build

```python
def build(output2d: dai.Node.Output, outputDepth: dai.Node.Output, calibData: dai.CalibrationHandler, depthAlignmentSocket: dai.CameraBoardSocket = dai.CameraBoardSocket.CAM_A, shrinkingFactor: float = 0) -> DepthMerger:
```

连接检测和深度流并初始化空间转换。

参数

 * `output2d` (`dai.Node.Output`): 产生 2D 检测的上游输出。
 * `outputDepth` (`dai.Node.Output`): 产生对齐深度帧的上游输出。
 * `calibData` (`dai.CalibrationHandler`): 用于将图像坐标转换为空间坐标的设备校准。
 * `depthAlignmentSocket` (`dai.CameraBoardSocket`): 深度帧对齐到的相机插槽。
 * `shrinkingFactor` (`float`): 在深度平均之前修剪每个边界框边缘的百分比。

返回

 * `DepthMerger`: 配置好的节点实例。

##### process

```python
def process(message2d: dai.Buffer, depth: dai.ImgFrame):
```

将检测转换为空间检测并通过 `output` 发送它们。

参数

 * `message2d` (`dai.Buffer`): 要投影到相机空间的 `dai.ImgDetection` 或 `dai.ImgDetections`。
 * `depth` (`dai.ImgFrame`): 与配置的校准相机对齐的深度帧。

抛出

 * `ValueError`: 如果检测输入类型不受支持。

#### 属性

##### host_spatials_calc

##### output

包含空间检测的输出流。

##### shrinking_factor

在采样深度之前修剪每个边界框边缘的比例。
