Skip to content

Commit cf1227d

Browse files
committed
Make time slider effective in viewer (Fixes nerfstudio-project#2928)
1 parent 45db2bc commit cf1227d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

nerfstudio/viewer/render_state_machine.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def _render_img(self, camera_state: CameraState):
129129

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

132-
camera = get_camera(camera_state, image_height, image_width)
132+
if self.viewer.include_time:
133+
camera = get_camera(camera_state, image_height, image_width, self.viewer.control_panel.time)
134+
else:
135+
camera = get_camera(camera_state, image_height, image_width)
133136
camera = camera.to(self.viewer.get_model().device)
134137
assert isinstance(camera, Cameras)
135138
assert camera is not None, "render called before viewer connected"

nerfstudio/viewer/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CameraState:
4242

4343

4444
def get_camera(
45-
camera_state: CameraState, image_height: int, image_width: Optional[Union[int, float]] = None
45+
camera_state: CameraState, image_height: int, image_width: Optional[Union[int, float]] = None, time: float = 0.0
4646
) -> Cameras:
4747
"""Returns the camera intrinsics matrix and the camera to world homogeneous matrix.
4848
@@ -74,7 +74,7 @@ def get_camera(
7474
cy=pp_h,
7575
camera_type=camera_state.camera_type,
7676
camera_to_worlds=camera_state.c2w.to(torch.float32)[None, ...],
77-
times=torch.tensor([0.0], dtype=torch.float32),
77+
times=torch.tensor([time], dtype=torch.float32),
7878
)
7979
return camera
8080

0 commit comments

Comments
 (0)