Unproject 2D camera coordinates with the given Z values.
(
coordinates: Float[Tensor, "*#batch dim"],
z: Float[Tensor, "*#batch"],
intrinsics: Float[Tensor, "*#batch dim+1 dim+1"],
)
| 74 | |
| 75 | |
| 76 | def unproject( |
| 77 | coordinates: Float[Tensor, "*#batch dim"], |
| 78 | z: Float[Tensor, "*#batch"], |
| 79 | intrinsics: Float[Tensor, "*#batch dim+1 dim+1"], |
| 80 | ) -> Float[Tensor, "*batch dim+1"]: |
| 81 | """Unproject 2D camera coordinates with the given Z values.""" |
| 82 | |
| 83 | # Apply the inverse intrinsics to the coordinates. |
| 84 | coordinates = homogenize_points(coordinates) |
| 85 | ray_directions = einsum( |
| 86 | intrinsics.inverse(), coordinates, "... i j, ... j -> ... i" |
| 87 | ) |
| 88 | |
| 89 | # Apply the supplied depth values. |
| 90 | return ray_directions * z[..., None] |
| 91 | |
| 92 | |
| 93 | def sample_image_grid( |
no test coverage detected