kaolin
kaolin copied to clipboard
about orthographic projection
I used the way of defining the Orthographic Camera in the doc, like this
orthographic_camera = Camera.from_args(
eye=np.array([10.0, 0.0, 4.0]),
at=np.array([0.0, 0.0, 0.0]),
up=np.array([0.0, 1.0, 0.0]),
width=800, height=800,
near=-800, far=800,
fov_distance=1.0,
dtype=torch.float32,
device='cuda'
)
Then, I used this code to render
with torch.jit.optimized_execution(False):
with torch.no_grad():
render_dict =kal.render.easy_render.render_mesh(orthographic_camera,mesh)
rendered_image = render_dict['render'].clamp(0,1)
image = rendered_image[0].cpu().numpy()
image = (image * 255).astype('uint8')
image = Image.fromarray(image)
image.save(osp.join(output_dir, "1.png"))
But I got the error
Traceback (most recent call last):
File "/media/sherlock-exp/share_SSD/opensuorce/data_process/stl_to2Dview.py", line 214, in <module>
stl_to_2Dview_kaolin(data_dir, temp_out_dir, filename)
File "/media/sherlock-exp/share_SSD/opensuorce/data_process/stl_to2Dview.py", line 186, in stl_to_2Dview_kaolin
render_dict =kal.render.easy_render.render_mesh(orthographic_camera,mesh)
File "/home/sherlock-exp/.conda/envs/opensource/lib/python3.10/site-packages/kaolin/render/easy_render/mesh.py", line 112, in render_mesh
diffuse_img, specular_img, img = sg_shade(
File "/home/sherlock-exp/.conda/envs/opensource/lib/python3.10/site-packages/kaolin/render/easy_render/mesh.py", line 430, in sg_shade
_, rays_d = kal.render.camera.raygen.generate_pinhole_rays(camera, pixel_grid)
File "/home/sherlock-exp/.conda/envs/opensource/lib/python3.10/site-packages/kaolin/render/camera/raygen.py", line 151, in generate_pinhole_rays
pixel_x = pixel_x - camera.x0
File "/home/sherlock-exp/.conda/envs/opensource/lib/python3.10/site-packages/kaolin/render/camera/camera.py", line 599, in __getattr__
raise AttributeError
AttributeError
In the doc, x0 and y0 is optional. I add it like this
orthographic_camera = Camera.from_args(
eye=np.array([10.0, 0.0, 4.0]),
at=np.array([0.0, 0.0, 0.0]),
up=np.array([0.0, 1.0, 0.0]),
width=800, height=800,
near=-800, far=800,
x0= 1.0, y0=1.0,
fov_distance=1.0,
dtype=torch.float32,
device='cuda'
)
The error is still exist, how to fix it
This is a bug on our end: easy_render always assumes pinhole rays for shading:
https://github.com/NVIDIAGameWorks/kaolin/blob/master/kaolin/render/easy_render/mesh.py#L430
We'll address that, thanks for the heads up!
Stale issue message