mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Merge pull request #36 from ethanweber/tancik/fix_camera_index_bug
Fix camera index bug
This commit is contained in:
2 files changed
+5
-3
No files matched your search
@@ -96,6 +96,8 @@ def collate_batch(batch, num_rays_per_batch, keep_full_image: bool = False):
|
|||||||
mask = batch["mask"][c, y, x]
|
mask = batch["mask"][c, y, x]
|
||||||
assert pixels.shape == (num_rays_per_batch, 3), pixels.shape
|
assert pixels.shape == (num_rays_per_batch, 3), pixels.shape
|
||||||
|
|
||||||
|
indices[:, 0] = batch["image_idx"][c]
|
||||||
|
|
||||||
collated_batch = {
|
collated_batch = {
|
||||||
"indices": indices,
|
"indices": indices,
|
||||||
"pixels": pixels,
|
"pixels": pixels,
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ class RayGenerator(nn.Module):
|
|||||||
x (_type_): _description_
|
x (_type_): _description_
|
||||||
"""
|
"""
|
||||||
c = ray_indices[:, 0] # camera indices
|
c = ray_indices[:, 0] # camera indices
|
||||||
i = ray_indices[:, 1] # row indices
|
y = ray_indices[:, 1] # row indices
|
||||||
j = ray_indices[:, 2] # col indices
|
x = ray_indices[:, 2] # col indices
|
||||||
intrinsics = self.intrinsics[c]
|
intrinsics = self.intrinsics[c]
|
||||||
camera_to_world = self.camera_to_world[c]
|
camera_to_world = self.camera_to_world[c]
|
||||||
# NOTE(ethan): we currently assume all images have the same height and width
|
# NOTE(ethan): we currently assume all images have the same height and width
|
||||||
@@ -46,7 +46,7 @@ class RayGenerator(nn.Module):
|
|||||||
camera_class = get_camera_model(self.num_intrinsics_params)
|
camera_class = get_camera_model(self.num_intrinsics_params)
|
||||||
camera = camera_class(*self.intrinsics[camera_index].tolist())
|
camera = camera_class(*self.intrinsics[camera_index].tolist())
|
||||||
image_coords = camera.get_image_coords().to(ray_indices.device)
|
image_coords = camera.get_image_coords().to(ray_indices.device)
|
||||||
coords = image_coords[i, j]
|
coords = image_coords[y, x]
|
||||||
|
|
||||||
ray_bundle = camera_class.generate_rays(intrinsics=intrinsics, camera_to_world=camera_to_world, coords=coords)
|
ray_bundle = camera_class.generate_rays(intrinsics=intrinsics, camera_to_world=camera_to_world, coords=coords)
|
||||||
ray_bundle.camera_indices = c
|
ray_bundle.camera_indices = c
|
||||||
|
|||||||
Reference in new issue
Block a user