# map_output

Python API: `depthai_nodes.node.parsers.map_output`

## Classes

| Name | Description |
| --- | --- |
| [`MapOutputParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser) | A parser class for models that produce map outputs, such as depth maps (e.g. DepthAnything), density maps (e.g. DM-Count), heat maps, and similar. |

### class `MapOutputParser`

```python
class MapOutputParser(BaseParser)
```

A parser class for models that produce map outputs, such as depth maps (e.g. DepthAnything), density maps (e.g. DM-Count), heat
maps, and similar.

> **Note**
> Emits `dai.beta.Map2D` messages. Map2D message containing the parsed map as a native dai.beta.Map2D object.

Attributes

| Name | Description |
| --- | --- |
| `min_max_scaling` | If True, the map is scaled to the range [0, 1]. |
| `output_layer_name` | Name of the output layer relevant to the parser. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-__init__) | Initializes the parser node. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-build) | Configures the parser. |
| [`compute`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-compute) | Compute parser results from extracted tensors without sending messages. |
| [`emit`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-emit) | Create a `dai.beta.Map2D` message and send it on `out`. |
| [`extract`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-extract) | Select and dequantize the model tensors needed for parsing. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-run) | Read queued network outputs, parse them, and emit results while running. |
| [`setMinMaxScaling`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-setMinMaxScaling) | Sets the min_max_scaling flag. |
| [`setOutputLayerName`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/map_output.md#map_output-Classes-MapOutputParser-setOutputLayerName) | Sets the name of the output layer. |

#### method `__init__`

```python
def __init__(output_layer_name: str = '', min_max_scaling: bool = False)
```

Initializes the parser node.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_layer_name` | `str` | Name of the output layer relevant to the parser. | `''` |
| `min_max_scaling` | `bool` | If True, the map is scaled to the range [0, 1]. | `False` |

#### method `build`

```python
def build(head_config: dict[str, Any]) -> MapOutputParser
```

Configures the parser.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `head_config` | `dict[str, Any]` | The head configuration for the parser. | required |

Returns

| Type | Description |
| --- | --- |
| `MapOutputParser` | The parser object with the head configuration set. |

#### static method `compute`

```python
def compute(map_tensor)
```

Compute parser results from extracted tensors without sending messages.

> **Note**
> Uses [depthai_nodes.node.parsers.utils.map_output.compute_map_output](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/map_output.md#map_output-Functions-compute_map_output); see that helper for tensor layout and validation details.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `map_tensor` |  | HW map, a map with leading singleton axes, or an HW1 map. | required |

Returns

| Type | Description |
| --- | --- |
|  | A two-dimensional array. Values and dtype are preserved; the result may share input storage. |

#### method `emit`

```python
def emit(output: dai.NNData, map_output)
```

Create a `dai.beta.Map2D` message and send it on `out`.

Copies source timestamps and sequence number, and carries the source image transformation when present.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |
| `map_output` |  | Two-dimensional map returned by `compute()`. | required |

#### method `extract`

```python
def extract(output: dai.NNData)
```

Select and dequantize the model tensors needed for parsing.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |

Returns

| Type | Description |
| --- | --- |
|  | Dequantized numeric map tensor. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If no output name is configured and the message does not contain exactly one layer, or configured class requirements are not met. |

#### method `run`

```python
def run()
```

Read queued network outputs, parse them, and emit results while running.

The pipeline invokes this processing loop. It exits when the input queue closes or the node stops.

#### method `setMinMaxScaling`

```python
def setMinMaxScaling(min_max_scaling: bool)
```

Sets the min_max_scaling flag.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `min_max_scaling` | `bool` | If True, the map is scaled to the range [0, 1]. | required |

#### method `setOutputLayerName`

```python
def setOutputLayerName(output_layer_name: str)
```

Sets the name of the output layer.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_layer_name` | `str` | The name of the output layer. | required |
