Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

about function get_ray_bundle #34

Open
UestcJay opened this issue Mar 21, 2022 · 2 comments
Open

about function get_ray_bundle #34

UestcJay opened this issue Mar 21, 2022 · 2 comments

Comments

@UestcJay
Copy link

UestcJay commented Mar 21, 2022

thanks for your great work! I have question about getting ray_directions. can you give me some sepcific introduction?
` ii, jj = meshgrid_xy(
torch.arange(
width, dtype=tform_cam2world.dtype, device=tform_cam2world.device
).to(tform_cam2world),
torch.arange(
height, dtype=tform_cam2world.dtype, device=tform_cam2world.device
),
)

directions = torch.stack(
    [
        (ii - width * 0.5) / focal_length,
        -(jj - height * 0.5) / focal_length,
        -torch.ones_like(ii),
    ],
    dim=-1,
)
ray_directions = torch.sum(
    directions[..., None, :] * tform_cam2world[:3, :3], dim=-1
)`
@cnnAndBn
Copy link

@krrish94 me too, what this line for ?
ray_directions = torch.sum(
directions[..., None, :] * tform_cam2world[:3, :3], dim=-1
)`

@daixiangzi
Copy link

daixiangzi commented Sep 22, 2022

+1
what's different?

`def get_rays(H, W, K, R, T):

    rays_o = -np.dot(R.T, T).ravel()   
    i, j = np.meshgrid(np.arange(W, dtype=np.float32),np.arange(H, dtype=np.float32), indexing='xy')
    xy1 = np.stack([i, j, np.ones_like(i)], axis=2)
    pixel_camera = np.dot(xy1, np.linalg.inv(K).T)
    pixel_world = np.dot(pixel_camera - T.ravel(), R)
    rays_d = pixel_world - rays_o[None, None]
    rays_o = np.broadcast_to(rays_o, rays_d.shape)
    return rays_o, rays_d`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants