# message_remapping

Python API: `depthai_nodes.node.utils.message_remapping`

## Functions

| Name | Description |
| --- | --- |
| [`remap_message`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/utils/message_remapping.md#message_remapping-Functions-remap_message) | Remap a supported DepthAI message into a target image transformation. |

### function `remap_message`

```python
def remap_message(
    message: GMessage,
    from_transformation: dai.ImgTransformation | None,
    to_transformation: dai.ImgTransformation,
) -> GMessage
```

Remap a supported DepthAI message into a target image transformation.

Native `transformTo` maps coordinate fields. Map and mask pixel arrays are warped separately with nearest-neighbor interpolation
and detached from the source buffer before writing. Pixels outside the source image are filled with 255 for `uint8` arrays and -1
for other dtypes.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `message` | `GMessage` | An `ImgDetections`, `SegmentationMask`, or beta `Keypoints`, `Clusters`, `Map2D`, `Lines`, `Predictions`, or `Classifications` message. | required |
| `from_transformation` | `dai.ImgTransformation | None` | Fallback source transformation. If the message has no transformation, this value is attached to it before remapping. An existing message transformation takes precedence. | required |
| `to_transformation` | `dai.ImgTransformation` | Target coordinate space and output pixel dimensions. | required |

Returns

| Type | Description |
| --- | --- |
| `GMessage` | Remapped message carrying the target transformation. If neither the message nor `from_transformation` provides a source transformation, returns the original message unchanged. |

Raises

| Type | Description |
| --- | --- |
| `TypeError` | If the message type is unsupported. |
