# message_collector

Python API: `depthai_nodes.node.message_collector`

## Classes

| Name | Description |
| --- | --- |
| [`MessageCollector`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Classes-MessageCollector) | Batch timestamp-matched messages from a single input stream. |

### class `MessageCollector`

```python
class MessageCollector(dai.node.ThreadedHostNode, Generic)
```

Batch timestamp-matched messages from a single input stream.

A group contains messages within half a frame interval of its first timestamp. The first newer message outside that tolerance
emits the preceding group; older out-of-window messages are discarded. Output metadata comes from the last message added to the
group. There is no explicit final flush when the stream stops, so the final group needs a newer message to be emitted.

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`out`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Classes-MessageCollector-out) | `dai.Node.Output` | Return the gathered output stream. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Classes-MessageCollector-__init__) | Create the collection input and output ports. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Classes-MessageCollector-build) | Connect the data stream and set its timestamp tolerance. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Classes-MessageCollector-run) | Read the input stream and emit groups when newer timestamps arrive. |
| [`setCameraFps`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Classes-MessageCollector-setCameraFps) | Set the frame rate used to compute timestamp matching tolerance. |

#### property `out`

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

Return the gathered output stream.

#### method `__init__`

```python
def __init__()
```

Create the collection input and output ports.

#### method `build`

```python
def build(cameraFps: int, inputData: dai.Node.Output) -> MessageCollector[TCollected]
```

Connect the data stream and set its timestamp tolerance.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `cameraFps` | `int` | Positive frame rate. Matching tolerance is half its frame interval. | required |
| `inputData` | `dai.Node.Output` | Input stream of messages to batch. | required |

Returns

| Type | Description |
| --- | --- |
| `MessageCollector[TCollected]` | This collector node. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the frame rate is not positive. |

#### method `run`

```python
def run()
```

Read the input stream and emit groups when newer timestamps arrive.

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the camera frame rate has not been configured. |

#### method `setCameraFps`

```python
def setCameraFps(fps: int)
```

Set the frame rate used to compute timestamp matching tolerance.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `fps` | `int` | Positive frame rate; the matching window is `1 / (2 * fps)` seconds. | required |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the frame rate is not positive. |

## Module Attributes

| Name | Description |
| --- | --- |
| [`TCollected`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/message_collector.md#message_collector-Module-Attributes-TCollected) |  |

### type variable `TCollected`

```python
TCollected = TypeVar('TCollected', bound=dai.Buffer)
```
