MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / get_rays_np

Function get_rays_np

script/models/ray_utils.py:18–25  ·  view source on GitHub ↗
(H, W, focal, c2w)

Source from the content-addressed store, hash-verified

16
17
18def get_rays_np(H, W, focal, c2w):
19 i, j = np.meshgrid(np.arange(W, dtype=np.float32), np.arange(H, dtype=np.float32), indexing='xy')
20 dirs = np.stack([(i-W*.5)/focal, -(j-H*.5)/focal, -np.ones_like(i)], -1)
21 # Rotate ray directions from camera frame to the world frame
22 rays_d = np.sum(dirs[..., np.newaxis, :] * c2w[:3,:3], -1) # dot product, equals to: [c2w.dot(dir) for dir in dirs]
23 # Translate camera frame's origin to the world frame. It is the origin of all rays.
24 rays_o = np.broadcast_to(c2w[:3,-1], np.shape(rays_d))
25 return rays_o, rays_d
26
27def ndc_rays(H, W, focal, near, rays_o, rays_d):
28 # Shift ray origins to near plane

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected