# tiling

Python API: `depthai_nodes.node.tiling`

## Classes

| Name | Description |
| --- | --- |
| [`Tiling`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling) | Emit groups of ImageManip crop configurations at startup and on updates. |
| [`TilingCfg`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-TilingCfg) | Configuration shared by tiling geometry and ImageManip generation. |

### class `Tiling`

```python
class Tiling(BaseThreadedHostNode)
```

Emit groups of ImageManip crop configurations at startup and on updates.

`build()` stores the initial configuration. When the pipeline invokes `run()`, the node sends the first `dai.MessageGroup`. Each
call to `updateTilingConfig()` recomputes and sends another group. Keys are zero-based string indexes. There is no trigger input.

Use with `FrameCropper.fromManipConfigs(waitForConfig=False)` to reuse the latest group for subsequent frames.

Properties

| Name | Type | Description |
| --- | --- | --- |
| [`out`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-out) | `dai.Node.Output` | Return the output stream of tile configuration groups. |
| [`tileCount`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-tileCount) | `int` | Return the number of tiles in the current configuration. |
| [`tilePositions`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-tilePositions) | `list[tuple[int, int, int, int]]` | Return crop rectangles as `(xmin, ymin, xmax, ymax)` pixel bounds. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-__init__) | Initialize logging and the platform-specific output image format. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-build) | Store the initial configuration for emission when the pipeline starts. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-run) | Compute and send the initial crop-configuration group once. |
| [`updateTilingConfig`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/tiling.md#tiling-Classes-Tiling-updateTilingConfig) | Update selected settings and immediately emit a new configuration group. |

#### property `out`

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

Return the output stream of tile configuration groups.

#### property `tileCount`

```python
tileCount: int
```

Return the number of tiles in the current configuration.

#### property `tilePositions`

```python
tilePositions: list[tuple[int, int, int, int]]
```

Return crop rectangles as `(xmin, ymin, xmax, ymax)` pixel bounds.

Requires `build()` first. Includes the full canvas first when global detection is enabled, followed by the computed cell or group
rectangles.

#### method `__init__`

```python
def __init__()
```

Initialize logging and the platform-specific output image format.

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the pipeline device platform has no configured image-frame format. |

#### method `build`

```python
def build(
    overlap: float,
    gridSize: tuple[int, int],
    canvasShape: tuple[int, int],
    resizeShape: tuple[int, int],
    resizeMode: dai.ImageManipConfig.ResizeMode,
    globalDetection: bool = False,
    gridMatrix: np.ndarray | list | None = None,
) -> Tiling
```

Store the initial configuration for emission when the pipeline starts.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `overlap` | `float` | Fractional overlap between adjacent cells, in [0, 1). | required |
| `gridSize` | `tuple[int, int]` | Grid dimensions as `(columns, rows)`. | required |
| `canvasShape` | `tuple[int, int]` | Source canvas size as `(width, height)` pixels. | required |
| `resizeShape` | `tuple[int, int]` | Output crop size as `(width, height)` pixels. | required |
| `resizeMode` | `dai.ImageManipConfig.ResizeMode` | ImageManip resizing policy for each crop. | required |
| `globalDetection` | `bool` | Prepend a crop covering the entire canvas when true. | `False` |
| `gridMatrix` | `np.ndarray | list | None` | Optional row-major grid labels. Four-connected cells with equal labels are merged into their enclosing rectangle. | `None` |

Returns

| Type | Description |
| --- | --- |
| `Tiling` | This node. Crop generation and validation occur when it runs. |

#### method `run`

```python
def run()
```

Compute and send the initial crop-configuration group once.

#### method `updateTilingConfig`

```python
def updateTilingConfig(
    overlap: float | None = None,
    gridSize: tuple[int, int] | None = None,
    canvasShape: tuple[int, int] | None = None,
    resizeShape: tuple[int, int] | None = None,
    resizeMode: dai.ImageManipConfig.ResizeMode | None = None,
    globalDetection: bool | None = None,
    gridMatrix: np.ndarray | list | None | None = None,
)
```

Update selected settings and immediately emit a new configuration group.

> **Note**
> Updates mutate the stored configuration before crop validation. `None` cannot be used to clear an existing grid matrix.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `overlap` | `float | None` | Fractional overlap between adjacent cells, in [0, 1). `None` preserves the current value. | `None` |
| `gridSize` | `tuple[int, int] | None` | Grid dimensions as `(columns, rows)`. `None` preserves the current value. | `None` |
| `canvasShape` | `tuple[int, int] | None` | Source canvas size as `(width, height)` pixels. `None` preserves the current value. | `None` |
| `resizeShape` | `tuple[int, int] | None` | Output crop size as `(width, height)` pixels. `None` preserves the current value. | `None` |
| `resizeMode` | `dai.ImageManipConfig.ResizeMode | None` | ImageManip resizing policy for each crop. `None` preserves the current value. | `None` |
| `globalDetection` | `bool | None` | Prepend a crop covering the entire canvas when true. `None` preserves the current value. | `None` |
| `gridMatrix` | `np.ndarray | list | None | None` | Optional row-major grid labels. Four-connected cells with equal labels are merged into their enclosing rectangle. `None` preserves the current value. | `None` |

Raises

| Type | Description |
| --- | --- |
| `RuntimeError` | If `build()` has not been called. |
| `ValueError` | If overlap is outside [0, 1) or the grid matrix dimensions disagree with `gridSize`. |

### class `TilingCfg`

```python
class TilingCfg
```

Configuration shared by tiling geometry and ImageManip generation.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `canvasShape` | `tuple[int, int]` | Source canvas size as `(width, height)` pixels. |
| `globalDetection` | `bool` | Prepend a crop covering the entire canvas when true. |
| `gridMatrix` | `np.ndarray | list | None` | Optional row-major grid labels. Four-connected cells with equal labels are merged into their enclosing rectangle. |
| `gridSize` | `tuple[int, int]` | Grid dimensions as `(columns, rows)`. |
| `overlap` | `float` | Fractional overlap between adjacent cells, in [0, 1). |
| `resizeMode` | `dai.ImageManipConfig.ResizeMode` | ImageManip resizing policy for each crop. |
| `resizeShape` | `tuple[int, int]` | Output crop size as `(width, height)` pixels. |
