# message_collector

Python API: `depthai_nodes.node.message_collector`

## Classes

### MessageCollector

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.

#### Methods

##### init

```python
def __init__(self):
```

Create the collection input and output ports.

##### build

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

Connect the data stream and set its timestamp tolerance.

Parameters

 * `cameraFps` (`int`): Positive frame rate. Matching tolerance is half its frame interval.
 * `inputData` (`dai.Node.Output`): Input stream of messages to batch.

Returns

 * `MessageCollector[TCollected]`: This collector node.

Raises

 * `ValueError`: If the frame rate is not positive.

##### run

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

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

Raises

 * `ValueError`: If the camera frame rate has not been configured.

##### setCameraFps

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

Set the frame rate used to compute timestamp matching tolerance.

Parameters

 * `fps` (`int`): Positive frame rate; the matching window is `1 / (2 * fps)` seconds.

Raises

 * `ValueError`: If the frame rate is not positive.

#### Attributes

##### out

Return the gathered output stream.

## Attributes

### TCollected
