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 orthographic projection #849

Open
SherlockCorleone opened this issue Dec 26, 2024 · 0 comments
Open

about orthographic projection #849

SherlockCorleone opened this issue Dec 26, 2024 · 0 comments

Comments

@SherlockCorleone
Copy link

SherlockCorleone commented Dec 26, 2024

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

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

1 participant