Skip to content

get_screen_to_ndc_transform multiple values for cameras when in_ndc=False #796

@jasonyzhang

Description

@jasonyzhang

If you do not know the root cause of the problem / bug, and wish someone to help you, please
post according to this template:

🐛 Bugs / Unexpected behaviors

Using a perspective camera with in_ndc=False causes cameras to be passed in twice to get_screen_to_ndc_transform. The reason is that cameras is both an ordered argument and usually in the kwargs dict.

def get_screen_to_ndc_transform(
cameras, with_xyflip: bool = False, **kwargs
) -> Transform3d:

NOTE: Please look at the existing list of Issues tagged with the label 'bug`. Only open a new issue if this bug has not already been reported. If an issue already exists, please comment there instead..

Instructions To Reproduce the Issue:

cameras = pytorch3d.renderer.PerspectiveCameras(in_ndc=False)
rend = renderer_textured(meshes, cameras=cameras)

raises a TypeError:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_1472741/3117266896.py in <module>
      1 cameras = pytorch3d.renderer.PerspectiveCameras(in_ndc=False, device=device)
----> 2 rend = renderer_textured(meshes, cameras=cameras)

~/miniconda3/envs/p3d/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    725             result = self._slow_forward(*input, **kwargs)
    726         else:
--> 727             result = self.forward(*input, **kwargs)
    728         for hook in itertools.chain(
    729                 _global_forward_hooks.values(),

~/miniconda3/envs/p3d/lib/python3.8/site-packages/pytorch3d-0.5.0-py3.8-linux-x86_64.egg/pytorch3d/renderer/mesh/renderer.py in forward(self, meshes_world, **kwargs)
     57         For this set rasterizer.raster_settings.clip_barycentric_coords=True
     58         """
---> 59         fragments = self.rasterizer(meshes_world, **kwargs)
     60         images = self.shader(fragments, meshes_world, **kwargs)
     61 

~/miniconda3/envs/p3d/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    725             result = self._slow_forward(*input, **kwargs)
    726         else:
--> 727             result = self.forward(*input, **kwargs)
    728         for hook in itertools.chain(
    729                 _global_forward_hooks.values(),

~/miniconda3/envs/p3d/lib/python3.8/site-packages/pytorch3d-0.5.0-py3.8-linux-x86_64.egg/pytorch3d/renderer/mesh/rasterizer.py in forward(self, meshes_world, **kwargs)
    145             Fragments: Rasterization outputs as a named tuple.
    146         """
--> 147         meshes_proj = self.transform(meshes_world, **kwargs)
    148         raster_settings = kwargs.get("raster_settings", self.raster_settings)
    149 

~/miniconda3/envs/p3d/lib/python3.8/site-packages/pytorch3d-0.5.0-py3.8-linux-x86_64.egg/pytorch3d/renderer/mesh/rasterizer.py in transform(self, meshes_world, **kwargs)
    127         )
    128         # view to NDC transform
--> 129         to_ndc_transform = cameras.get_ndc_camera_transform(**kwargs)
    130         projection_transform = cameras.get_projection_transform(**kwargs).compose(
    131             to_ndc_transform

~/miniconda3/envs/p3d/lib/python3.8/site-packages/pytorch3d-0.5.0-py3.8-linux-x86_64.egg/pytorch3d/renderer/cameras.py in get_ndc_camera_transform(self, **kwargs)
   1045                 matrix=pr_point_fix.transpose(1, 2).contiguous(), device=self.device
   1046             )
-> 1047             screen_to_ndc_transform = get_screen_to_ndc_transform(
   1048                 self, with_xyflip=False, **kwargs
   1049             )

TypeError: get_screen_to_ndc_transform() got multiple values for argument 'cameras'

Metadata

Metadata

Assignees

Labels

potential-bugPotential bug to flag an issue that needs to be looked into

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions