MCPcopy Create free account
hub / github.com/LeapLabTHU/ActiveNeRF / get_rays_np

Function get_rays_np

run_nerf_helpers.py:174–181  ·  view source on GitHub ↗
(H, W, focal, c2w)

Source from the content-addressed store, hash-verified

172
173
174def get_rays_np(H, W, focal, c2w):
175 i, j = np.meshgrid(np.arange(W, dtype=np.float32), np.arange(H, dtype=np.float32), indexing='xy')
176 dirs = np.stack([(i-W*.5)/focal, -(j-H*.5)/focal, -np.ones_like(i)], -1)
177 # Rotate ray directions from camera frame to the world frame
178 rays_d = np.sum(dirs[..., np.newaxis, :] * c2w[:3,:3], -1) # dot product, equals to: [c2w.dot(dir) for dir in dirs]
179 # Translate camera frame's origin to the world frame. It is the origin of all rays.
180 rays_o = np.broadcast_to(c2w[:3,-1], np.shape(rays_d))
181 return rays_o, rays_d
182
183
184def ndc_rays(H, W, focal, near, rays_o, rays_d):

Callers 1

trainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected