Return the positions of all surface points with backward optical flow applied.
(
surfaces: Float[Tensor, "batch frame *grid xyz=3"],
extrinsics: Float[Tensor, "batch frame 4 4"],
intrinsics: Float[Tensor, "batch frame 3 3"],
)
| 163 | |
| 164 | |
| 165 | def compute_backward_flow( |
| 166 | surfaces: Float[Tensor, "batch frame *grid xyz=3"], |
| 167 | extrinsics: Float[Tensor, "batch frame 4 4"], |
| 168 | intrinsics: Float[Tensor, "batch frame 3 3"], |
| 169 | ) -> Float[Tensor, "batch frame-1 *grid xy=2"]: |
| 170 | """Return the positions of all surface points with backward optical flow applied.""" |
| 171 | |
| 172 | # Since the poses are camera-to-world and transformations are applied right to |
| 173 | # left, this can be understood as follows: First, transform from the later |
| 174 | # frame's camera space to world space. Then, transform from world space into the |
| 175 | # earlier frame's camera space. |
| 176 | backward_transformation = earlier(extrinsics).inverse() @ later(extrinsics) |
| 177 | |
| 178 | singletons = " ".join(["()"] * (surfaces.ndim - 3)) |
| 179 | pattern = f"b f i j -> b f {singletons} i j" |
| 180 | return reproject_points( |
| 181 | later(surfaces), |
| 182 | rearrange(backward_transformation, pattern), |
| 183 | rearrange(earlier(intrinsics), pattern), |
| 184 | ) |
| 185 | |
| 186 | |
| 187 | def get_extrinsics( |
no test coverage detected