# base_parser

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

## Classes

| Name | Description |
| --- | --- |
| [`BaseMeta`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseMeta) |  |
| [`BaseParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser) | Base class for neural network output parsers. This class serves as a foundation for specific parser implementations used to postprocess the outputs of neural network models. Each parser is attached to a model "head" that governs the parsing process as it contains all the necessary information for the parser to function correctly. Subclasses should implement `build` method to correctly set all parameters of the parser and the `run` method to define the parsing logic. |

### class `BaseMeta`

```python
class BaseMeta(ABCMeta, type(dai.node.ThreadedHostNode))
```

### class `BaseParser`

```python
class BaseParser(dai.node.ThreadedHostNode)
```

Base class for neural network output parsers. This class serves as a foundation for specific parser implementations used to
postprocess the outputs of neural network models. Each parser is attached to a model "head" that governs the parsing process as it
contains all the necessary information for the parser to function correctly. Subclasses should implement `build` method to
correctly set all parameters of the parser and the `run` method to define the parsing logic.

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`input`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-input) | `dai.Node.Input` | Input port accepting neural-network output messages. |
| [`out`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-out) | `dai.Node.Output` | Output port carrying parsed native DepthAI messages. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-__init__) | Create NNData input and parsed-message output ports and initialize logging. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-build) | Configures the parser based on the specified head configuration. |
| [`input.setter`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-input.setter) | Replace the stored parser port. |
| [`out.setter`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-out.setter) | Replace the stored parser port. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/base_parser.md#base_parser-Classes-BaseParser-run) | Read neural network outputs and send parsed messages through `out`. |

#### property `input`

```python
input: dai.Node.Input
```

Input port accepting neural-network output messages.

#### property `out`

```python
out: dai.Node.Output
```

Output port carrying parsed native DepthAI messages.

#### method `__init__`

```python
def __init__()
```

Create NNData input and parsed-message output ports and initialize logging.

#### method `build`

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

Configures the parser based on the specified head configuration.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `head_config` | `dict[str, Any]` | A dictionary containing configuration details relevant to the parser, including parameters and settings required for output parsing. | required |

Returns

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

#### method `input.setter`

```python
def input.setter(node: dai.Node.Input)
```

Replace the stored parser port.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `node` | `dai.Node.Input` | Input port to store as the parser input. | required |

#### method `out.setter`

```python
def out.setter(node: dai.Node.Output)
```

Replace the stored parser port.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `node` | `dai.Node.Output` | Output port to store as the parsed-message output. | required |

#### method `run`

```python
def run()
```

Read neural network outputs and send parsed messages through `out`.

Subclasses implement their processing loop here. The pipeline invokes this method when the threaded host node starts.
