Skip to content

Commit

Permalink
Make time slider effective in viewer (Fixes #2928) (#2931)
Browse files Browse the repository at this point in the history
  • Loading branch information
iSach authored Feb 19, 2024
1 parent 45db2bc commit 6c2bfad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion nerfstudio/viewer/render_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def _render_img(self, camera_state: CameraState):

image_height, image_width = self._calculate_image_res(camera_state.aspect)

camera = get_camera(camera_state, image_height, image_width)
if self.viewer.include_time:
camera = get_camera(camera_state, image_height, image_width, self.viewer.control_panel.time)
else:
camera = get_camera(camera_state, image_height, image_width)
camera = camera.to(self.viewer.get_model().device)
assert isinstance(camera, Cameras)
assert camera is not None, "render called before viewer connected"
Expand Down
4 changes: 2 additions & 2 deletions nerfstudio/viewer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CameraState:


def get_camera(
camera_state: CameraState, image_height: int, image_width: Optional[Union[int, float]] = None
camera_state: CameraState, image_height: int, image_width: Optional[Union[int, float]] = None, time: float = 0.0
) -> Cameras:
"""Returns the camera intrinsics matrix and the camera to world homogeneous matrix.
Expand Down Expand Up @@ -74,7 +74,7 @@ def get_camera(
cy=pp_h,
camera_type=camera_state.camera_type,
camera_to_worlds=camera_state.c2w.to(torch.float32)[None, ...],
times=torch.tensor([0.0], dtype=torch.float32),
times=torch.tensor([time], dtype=torch.float32),
)
return camera

Expand Down

0 comments on commit 6c2bfad

Please sign in to comment.