added caching for dataloader

This commit is contained in:
Ethan Weber committed 2022-04-23 17:36:57 +00:00
1 parent 5f1baa5a7b
commit 4c7d07116e
5 files changed
+134 -56

No files matched your search

+2 -2
View File
@@ -181,10 +181,10 @@ class PinholeCamera(Camera):
fy = intrinsics[:, cls.fy_index() : cls.fy_index() + 1]
y = coords[:, 0:1] # (num_rays, 1)
x = coords[:, 1:2] # (num_rays, 1)
directions = torch.cat([(x - cx) / fx, -(y - cy) / fy, -torch.ones_like(x)], -1) # (num_rays, 3)
original_directions = torch.cat([(x - cx) / fx, -(y - cy) / fy, -torch.ones_like(x)], -1) # (num_rays, 3)
rotation = camera_to_world[:, :3, :3] # (num_rays, 3, 3)
directions = torch.sum(
directions[:, None, :] * rotation, dim=-1
original_directions[:, None, :] * rotation, dim=-1
) # (num_rays, 1, 3) * (num_rays, 3, 3) -> (num_rays, 3)
directions = normalize(directions, dim=-1)
origins = camera_to_world[:, :3, 3] # (num_rays, 3)