MCPcopy Create free account
hub / github.com/dcharatan/flowmap / compute_backward_flow

Function compute_backward_flow

flowmap/model/projection.py:165–184  ·  view source on GitHub ↗

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"],
)

Source from the content-addressed store, hash-verified

163
164
165def 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
187def get_extrinsics(

Callers 3

visualizeMethod · 0.85
forwardMethod · 0.85

Calls 1

reproject_pointsFunction · 0.85

Tested by

no test coverage detected