Spaces:
Paused
Paused
File size: 887 Bytes
5c36daa b8fe2b6 5c36daa b8fe2b6 5c36daa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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]
|