Extending ns-render to support loop rendering using interpolated cameras (#1508)

* Extending ns-render to support loop rendering using interpolated cameras.

* Adding docstring for render.py. Applying formating.

* Expanding docstrings for class. Renaming trajectory type.

* Removing mentions of loop from render.py.
This commit is contained in:
Georgy Ponimatkin authored and GitHub committed 2023-02-26 09:30:19 -08:00
1 parent 3e005815cc
commit 7da588c5d2
3 files changed
+31 -11

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ def get_interpolated_camera_path(cameras: Cameras, steps: int) -> Cameras:
A new set of cameras along a path.
"""
Ks = cameras.get_intrinsics_matrices().cpu().numpy()
poses = cameras.camera_to_worlds().cpu().numpy()
poses = cameras.camera_to_worlds.cpu().numpy()
poses, Ks = get_interpolated_poses_many(poses, Ks, steps_per_transition=steps)
cameras = Cameras(fx=Ks[:, 0, 0], fy=Ks[:, 1, 1], cx=Ks[0, 0, 2], cy=Ks[0, 1, 2], camera_to_worlds=poses)
+8 -4
View File
@@ -178,7 +178,7 @@ def get_interpolated_poses(pose_a, pose_b, steps: int = 10) -> List[float]:
pose = np.identity(4)
pose[:3, :3] = quaternion_matrix(quat)[:3, :3]
pose[:3, 3] = tran
poses_ab.append(pose)
poses_ab.append(pose[:3])
return poses_ab
@@ -215,14 +215,18 @@ def get_interpolated_poses_many(
tuple of new poses and intrinsics
"""
traj = []
Ks = []
k_interp = []
for idx in range(poses.shape[0] - 1):
pose_a = poses[idx]
pose_b = poses[idx + 1]
poses_ab = get_interpolated_poses(pose_a, pose_b, steps=steps_per_transition)
traj += poses_ab
Ks += get_interpolated_k(Ks[idx], Ks[idx + 1], steps_per_transition)
return torch.stack(traj, dim=0), torch.stack(Ks, dim=0)
k_interp += get_interpolated_k(Ks[idx], Ks[idx + 1], steps=steps_per_transition)
traj = np.stack(traj, axis=0)
k_interp = np.stack(k_interp, axis=0)
return torch.tensor(traj), torch.tensor(k_interp)
def normalize(x) -> TensorType[...]: