Spaces:
Sleeping
Sleeping
| from typing import NamedTuple, Sequence, List | |
| import numpy as np | |
| class DepthResult(NamedTuple): | |
| """Result from depth estimation inference.""" | |
| depth_map: np.ndarray # HxW float32 depth in meters | |
| focal_length: float # Estimated focal length in pixels | |
| class DepthEstimator: | |
| """Base interface for depth estimation models.""" | |
| name: str | |
| supports_batch: bool = False | |
| max_batch_size: int = 1 | |
| def predict(self, frame: np.ndarray) -> DepthResult: | |
| """ | |
| Run depth estimation on a single frame. | |
| Args: | |
| frame: Input image as numpy array (HxWxC, BGR format from OpenCV) | |
| Returns: | |
| DepthResult with depth_map and focal_length | |
| """ | |
| raise NotImplementedError | |
| def predict_batch(self, frames: Sequence[np.ndarray]) -> Sequence[DepthResult]: | |
| return [self.predict(f) for f in frames] | |