Compute focal length based on FOV.
(img_w: int, img_h: int, fov: float = 55)
| 99 | |
| 100 | |
| 101 | def estimate_focal_length(img_w: int, img_h: int, fov: float = 55) -> float: |
| 102 | """Compute focal length based on FOV.""" |
| 103 | fov_rad = fov * np.pi / 180 |
| 104 | larger_side = max(img_w, img_h) |
| 105 | focal = larger_side / (2 * np.tan(fov_rad / 2)) |
| 106 | return float(focal) |
| 107 | |
| 108 | |
| 109 | def visualize_depth_map(depth_map: torch.Tensor) -> np.ndarray: |