> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# foundationstereo

> Estimate depth from stereo pair using FoundationStereo

Estimate depth from stereo pair using FoundationStereo.

> [!NOTE]
>
> Input images up to **1280 x 720** (width x height). Larger images are rejected with HTTP 413, not downscaled — resize first.

## Parameters

**left\_image** `Union[str, Image.Image, np.ndarray]`

Left stereo image.

**right\_image** `Union[str, Image.Image, np.ndarray]`

Right stereo image.

**stereo\_image** `ImageInput | None`

Rectified \[left | right] frame, with equal-width views and at most 720x1280 pixels per eye. Supply this instead of left\_image and right\_image.

**return\_left\_image** `bool` (default: False)

If true, return a dictionary containing "depth" (float32 HxW) and "left\_image" (uint8 RGB HxWx3). The left image can be passed to any segmentation model.

**aux\_args** `Dict[str, Any]`

Camera parameters: - "K": 3x3 intrinsics for the rectified left view at input resolution - "baseline": Stereo baseline in meters - "hiera": Hierarchy level (0-2) - "valid\_iters": Number of valid iterations

**timeout** `float | None`

Optional HTTP timeout.

## Returns

np.ndarray | dict\[str, np.ndarray]: Depends on return\_left\_image:

* False (default): The depth array.
* True: A dictionary with "depth" and "left\_image" arrays.

Depth is float32 with shape (H, W), in meters. The optional left
image is uint8 RGB with shape (H, W, 3), aligned with depth.
Both use the input per-eye resolution; the server performs no
resizing or rectification.

## Example

```python theme={null}
from grid_cortex_client import CortexClient, ModelType
import numpy as np
from PIL import Image
client = CortexClient()
K = np.array([[525, 0, 320], [0, 525, 240], [0, 0, 1]], dtype=np.float32)
aux = {"K": K, "baseline": 0.1, "hiera": 0, "valid_iters": 32}
left_image = np.array(Image.open("left.jpg"))
right_image = np.array(Image.open("right.jpg"))
depth = client.run(ModelType.FOUNDATIONSTEREO, left_image=left_image, right_image=right_image, aux_args=aux)
print(depth.shape)  # (480, 640)
```


## Related topics

- [fast-foundationstereo](https://docs.generalrobotics.dev/models/cortex/fast-foundationstereo.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.