Derive camera intrinsic matrix. Args: width_px: width (pixel) height_px: height (pixel) fov: field-of-view (degree) Returns: 3x3 intrinsic matrix
(
width_px: int,
height_px: int,
fov: float,
dtype: np.dtype = np.float32,
)
| 437 | |
| 438 | |
| 439 | def derive_camera_intrinsics( |
| 440 | width_px: int, |
| 441 | height_px: int, |
| 442 | fov: float, |
| 443 | dtype: np.dtype = np.float32, |
| 444 | ) -> np.ndarray: |
| 445 | """ |
| 446 | Derive camera intrinsic matrix. |
| 447 | |
| 448 | Args: |
| 449 | width_px: width (pixel) |
| 450 | height_px: height (pixel) |
| 451 | fov: field-of-view (degree) |
| 452 | |
| 453 | Returns: |
| 454 | 3x3 intrinsic matrix |
| 455 | """ |
| 456 | camera_f = 0.5 * float(width_px) / np.tan(0.5 * fov / 180. * np.pi) |
| 457 | camera_intrinsics = np.array( |
| 458 | [ |
| 459 | [camera_f, 0., width_px * 0.5], |
| 460 | [0., camera_f, height_px * 0.5], |
| 461 | [0., 0., 1.], |
| 462 | ], dtype=sample_utils.get_np_dtype(dtype)) |
| 463 | |
| 464 | return camera_intrinsics |
| 465 | |
| 466 | |
| 467 | def create_gif( |
nothing calls this directly
no outgoing calls
no test coverage detected