MCPcopy Create free account
hub / github.com/Robotics-STAR-Lab/H2-Mapping / get_rays

Method get_rays

mapping/src/frame.py:58–73  ·  view source on GitHub ↗
(self, w=None, h=None, K=None)

Source from the content-addressed store, hash-verified

56
57 @torch.no_grad()
58 def get_rays(self, w=None, h=None, K=None):
59 w = self.w if w == None else w
60 h = self.h if h == None else h
61 if K is None:
62 K = np.eye(3)
63 K[0, 0] = self.K[0, 0] * w / self.w
64 K[1, 1] = self.K[1, 1] * h / self.h
65 K[0, 2] = self.K[0, 2] * w / self.w
66 K[1, 2] = self.K[1, 2] * h / self.h
67 ix, iy = torch.meshgrid(
68 torch.arange(w), torch.arange(h), indexing='xy')
69 rays_d = torch.stack(
70 [(ix - K[0, 2]) / K[0, 0],
71 (iy - K[1, 2]) / K[1, 1],
72 torch.ones_like(ix)], -1).float() # camera coordinate
73 return rays_d
74
75 @torch.no_grad()
76 def precompute(self):

Callers 3

precomputeMethod · 0.95
runMethod · 0.45
render_debug_imagesMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected