Skip to main content
Estimate depth from a stereo image pair using FoundationStereo.

Parameters

left_image
str | PIL.Image | np.ndarray
required
Left stereo image.
right_image
str | PIL.Image | np.ndarray
required
Right stereo image.
aux_args
Dict[str, Any]
Camera parameters:
  • K — 3x3 camera intrinsics matrix
  • 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 — Depth map of shape (H, W) with dtype float32. Values in meters.

Example

from grid_cortex_client import CortexClient
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.open("left.jpg")
right = Image.open("right.jpg")

depth = client.run(
    model_id="foundationstereo",
    left_image=left,
    right_image=right,
    aux_args=aux,
)
print(depth.shape)  # (480, 640)