# instance_to_semantic_mask

Python API: `depthai_nodes.node.instance_to_semantic_mask`

## 类

### InstanceToSemanticMask

将实例掩码 ID 替换为检测类别标签。

输入和输出都是 `dai.ImgDetections` 消息。当掩码和检测都存在时，会发出一个复制的消息；其掩码会被替换。类别标签必须可以用 uint8 表示，其中 255 保留给背景。缺失或空的掩码会在复制的消息上不变地通过。

#### 方法

##### init

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

初始化日志记录和特定于平台的输出图像格式。

引发

 * `ValueError`: 如果管道设备平台没有配置图像帧格式。

##### build

```python
def build(detections: dai.Node.Output) -> InstanceToSemanticMask:
```

连接带有实例掩码的检测流。

参数

 * `detections` (`dai.Node.Output`): 生成 `dai.ImgDetections` 的输出。

返回

 * `InstanceToSemanticMask`: 此节点。

##### process

```python
def process(msg: dai.Buffer):
```

复制检测并将有效的掩码索引转换为类别标签。

参数

 * `msg` (`dai.Buffer`): 带有非负实例索引掩码的检测。值为 255 或超出检测列表的索引将成为背景。

引发

 * `TypeError`: 如果输入不是 `dai.ImgDetections`。
