-
Notifications
You must be signed in to change notification settings - Fork 561
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
Update camera_ray_tracing.py: fix small bugs #726
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
import torch | ||
import numpy as np | ||
from typing import Tuple | ||
from kaolin.render.camera import Camera, CameraFOV | ||
from kaolin.render.camera import Camera | ||
from kaolin.render.camera.intrinsics import CameraFOV | ||
|
||
def generate_pixel_grid(res_x=None, res_y=None, device='cuda'): | ||
h_coords = torch.arange(res_x, device=device) | ||
|
@@ -45,20 +46,21 @@ def generate_perspective_rays(camera: Camera, pixel_grid: Tuple[torch.Tensor, to | |
|
||
return ray_orig, ray_dir, camera.near, camera.far | ||
|
||
|
||
img_width = 200 | ||
img_height =200 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Please fix the space here |
||
camera = Camera.from_args( | ||
eye=torch.tensor([4.0, 4.0, 4.0]), | ||
at=torch.tensor([0.0, 0.0, 0.0]), | ||
up=torch.tensor([0.0, 1.0, 0.0]), | ||
fov=30 * np.pi / 180, # In radians | ||
x0=0.0, y0=0.0, | ||
width=800, height=800, | ||
width=img_width, height=img_height, | ||
near=1e-2, far=1e2, | ||
dtype=torch.float64, | ||
device='cuda' | ||
) | ||
|
||
pixel_grid = generate_pixel_grid(200, 200) | ||
pixel_grid = generate_pixel_grid(img_width, img_height) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this snippet should be a simple recipe, I agree with your suggestion of having the raygen grid and image plane with the same resolution. For reference, kaolin-wisp implements exactly that for its interactive mode:
Picking an arbitrary resolution (which is not a power of 2 downscale factor) can indeed cause alignment issues, which I think it what you're worried about? |
||
ray_orig, ray_dir, near, far = generate_perspective_rays(camera, pixel_grid) | ||
|
||
print('Ray origins:') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one isn't actually needed as
__init__.py
has: