Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants