# map_output

Python API: `depthai_nodes.node.parsers.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.

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

#### Methods

##### init

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

Initializes the parser node.

Parameters

 * `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].

##### build

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

Configures the parser.

Parameters

 * `head_config` (`dict[str, Any]`): The head configuration for the parser.

Returns

 * `MapOutputParser`: The parser object with the head configuration set.

##### 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); see that helper for tensor layout and validation details.

Parameters

 * `map_tensor`: HW map, a map with leading singleton axes, or an HW1 map.

Returns

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

##### 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.

Parameters

 * `output` (`dai.NNData`): Neural network output carrying tensors and source timestamps, sequence number, and optional image
   transformation.
 * `map_output`: Two-dimensional map returned by `compute()`.

##### extract

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

Select and dequantize the model tensors needed for parsing.

Parameters

 * `output` (`dai.NNData`): Neural network output carrying tensors and source timestamps, sequence number, and optional image
   transformation.

Returns

 * Dequantized numeric map tensor.

Raises

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

##### run

```python
def run(self):
```

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.

##### setMinMaxScaling

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

Sets the min_max_scaling flag.

Parameters

 * `min_max_scaling` (`bool`): If True, the map is scaled to the range [0, 1].

##### setOutputLayerName

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

Sets the name of the output layer.

Parameters

 * `output_layer_name` (`str`): The name of the output layer.

#### Attributes

##### 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.
