Skip to content

Commit

Permalink
Cameras pr followup (nerfstudio-project#622)
Browse files Browse the repository at this point in the history
cameras manual indexing bug in datamanager
  • Loading branch information
jake-austin authored Oct 3, 2022
1 parent e3eb323 commit 4533c7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nerfstudio/cameras/cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def rescale_output_resolution(self, scaling_factor: Union[TensorType["num_camera
scaling_factor: Scaling factor to apply to the output resolution.
"""
if isinstance(scaling_factor, float):
scaling_factor = torch.tensor([scaling_factor]).broadcast_to((self.size))
scaling_factor = torch.tensor([scaling_factor]).to(self.device).broadcast_to((self.size))

self.fx = self.fx * scaling_factor
self.fy = self.fy * scaling_factor
Expand Down
12 changes: 7 additions & 5 deletions nerfstudio/data/utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ def get_camera(self, image_idx: int = 0) -> Cameras:
distortion_params = self.cameras.distortion_params[image_idx]

camera = Cameras(
fx=self.cameras.fx if isinstance(self.cameras.fx, float) else self.cameras.fx[image_idx : image_idx + 1],
fy=self.cameras.fy if isinstance(self.cameras.fy, float) else self.cameras.fy[image_idx : image_idx + 1],
cx=self.cameras.cx,
cy=self.cameras.cy,
fx=self.cameras.fx[image_idx : image_idx + 1],
fy=self.cameras.fy[image_idx : image_idx + 1],
cx=self.cameras.cx[image_idx : image_idx + 1],
cy=self.cameras.cy[image_idx : image_idx + 1],
height=self.cameras.image_height[image_idx : image_idx + 1],
width=self.cameras.image_width[image_idx : image_idx + 1],
camera_to_worlds=self.cameras.camera_to_worlds[image_idx : image_idx + 1],
distortion_params=distortion_params,
camera_type=self.cameras.camera_type,
camera_type=self.cameras.camera_type[image_idx : image_idx + 1],
)
return camera

Expand Down

0 comments on commit 4533c7d

Please sign in to comment.