# instance_to_semantic_mask

Python API: `depthai_nodes.node.instance_to_semantic_mask`

## Classes

### InstanceToSemanticMask

Replace instance-mask IDs with detection class labels.

The input and output are `dai.ImgDetections` messages. A copied message is emitted; its mask is replaced when both a mask and
detections are present. Class labels must be representable in uint8, with 255 reserved for background. Missing or empty masks pass
through on the copied message unchanged.

#### Methods

##### init

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

Initialize logging and the platform-specific output image format.

Raises

 * `ValueError`: If the pipeline device platform has no configured image-frame format.

##### build

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

Connect a detection stream with instance masks.

Parameters

 * `detections` (`dai.Node.Output`): Output producing `dai.ImgDetections`.

Returns

 * `InstanceToSemanticMask`: This node.

##### process

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

Copy detections and convert valid mask indexes to class labels.

Parameters

 * `msg` (`dai.Buffer`): Detections with a mask of non-negative instance indexes. Values of 255 or indexes beyond the detection
   list become background.

Raises

 * `TypeError`: If the input is not `dai.ImgDetections`.
