| 110 | |
| 111 | |
| 112 | def get_virtual_camera_rays( |
| 113 | camera: pycolmap.Camera, |
| 114 | ) -> npt.NDArray[np.floating]: |
| 115 | size = (camera.width, camera.height) |
| 116 | x, y = np.indices(size).astype(np.float32) |
| 117 | xy: NDArrayNx2 = np.column_stack([x.ravel(), y.ravel()]) |
| 118 | # The center of the upper left most pixel has coordinate (0.5, 0.5) |
| 119 | xy += 0.5 |
| 120 | xy_norm: NDArrayNx2 = camera.cam_from_img(image_points=xy) |
| 121 | rays = np.concatenate([xy_norm, np.ones_like(xy_norm[:, :1])], -1) |
| 122 | rays /= np.linalg.norm(rays, axis=-1, keepdims=True) |
| 123 | return rays |
| 124 | |
| 125 | |
| 126 | def spherical_img_from_cam( |