Skip to content

Commit

Permalink
pulsar image_size validation
Browse files Browse the repository at this point in the history
Summary:
For a non-square image, the image_size in PointsRasterizationSettings is now (H,W) not (W,H). A part of pulsar's validation code wasn't updated for this.

The following now works.
```
H, W = 249, 125
image_size = (H, W)
camera = PerspectiveCameras(focal_length=1.0, image_size=(image_size,), in_ndc=True)
points_rasterizer = PointsRasterizer(cameras=camera, raster_settings=PointsRasterizationSettings(image_size=image_size, radius=0.0000001))
pulsar_renderer = PulsarPointsRenderer(rasterizer=points_rasterizer)
pulsar_renderer(Pointclouds(...), gamma = (0.1,), znear = (0.1,), zfar = (70,))
```

Reviewed By: nikhilaravi, classner

Differential Revision: D32316322

fbshipit-source-id: 8405a49acecb1c95d37ee368c3055868b797208a
  • Loading branch information
bottler authored and facebook-github-bot committed Nov 17, 2021
1 parent a8cb7fa commit a0247ea
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions pytorch3d/renderer/points/pulsar/unified.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,41 +143,30 @@ def _conf_check(self, point_clouds, kwargs: Dict[str, Any]) -> bool:
"The camera type can not be changed after renderer initialization! "
"Current camera orthogonal: %r. Original orthogonal: %r."
) % (orthogonal_projection, self.renderer._renderer.orthogonal)
if (
isinstance(self.rasterizer.raster_settings.image_size, tuple)
and self.rasterizer.raster_settings.image_size[0]
!= self.renderer._renderer.width
) or (
not isinstance(self.rasterizer.raster_settings.image_size, tuple)
and self.rasterizer.raster_settings.image_size
!= self.renderer._renderer.width
):
image_size = self.rasterizer.raster_settings.image_size
if isinstance(image_size, tuple):
expected_height, expected_width = image_size
else:
expected_height = expected_width = image_size
if expected_width != self.renderer._renderer.width:
raise ValueError(
(
"The rasterizer width and height can not be changed after renderer "
"initialization! Current width: %d. Original width: %d."
"The rasterizer width can not be changed after renderer "
"initialization! Current width: %s. Original width: %d."
)
% (
self.rasterizer.raster_settings.image_size,
expected_width,
self.renderer._renderer.width,
)
)
if (
isinstance(self.rasterizer.raster_settings.image_size, tuple)
and self.rasterizer.raster_settings.image_size[1]
!= self.renderer._renderer.height
) or (
not isinstance(self.rasterizer.raster_settings.image_size, tuple)
and self.rasterizer.raster_settings.image_size
!= self.renderer._renderer.height
):
if expected_height != self.renderer._renderer.height:
raise ValueError(
(
"The rasterizer width and height can not be changed after renderer "
"initialization! Current height: %d. Original height: %d."
"The rasterizer height can not be changed after renderer "
"initialization! Current height: %s. Original height: %d."
)
% (
self.rasterizer.raster_settings.image_size,
expected_height,
self.renderer._renderer.height,
)
)
Expand Down

0 comments on commit a0247ea

Please sign in to comment.