MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / get_rays

Method get_rays

scene/cameras.py:75–82  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 self.timestamp = timestamp
74
75 def get_rays(self):
76 grid = create_meshgrid(self.image_height, self.image_width, normalized_coordinates=False)[0] + 0.5
77 i, j = grid.unbind(-1)
78 pts_view = torch.stack([(i-self.cx)/self.fl_x, (j-self.cy)/self.fl_y, torch.ones_like(i), torch.ones_like(i)], -1).to(self.data_device)
79 c2w = torch.linalg.inv(self.world_view_transform.transpose(0, 1))
80 pts_world = pts_view @ c2w.T
81 directions = pts_world[...,:3] - self.camera_center[None,None,:]
82 return self.camera_center[None,None], directions / torch.norm(directions, dim=-1, keepdim=True)
83
84 def cuda(self):
85 cuda_copy = deepcopy(self)

Callers 1

renderFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected