mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 23:00:34 +08:00
Update Rasterizer and add end2end fisheye integration test
Summary: 1) Update rasterizer/point rasterizer to accommodate fisheyecamera. Specifically, transform_points is in placement of explicit transform compositions. 2) In rasterizer unittests, update corresponding tests for rasterizer and point_rasterizer. Address comments to test fisheye against perspective camera when distortions are turned off. 3) Address comments to add end2end test for fisheyecameras. In test_render_meshes, fisheyecameras are added to camera enuerations whenever possible. 4) Test renderings with fisheyecameras of different params on cow mesh. 5) Use compositions for linear cameras whenever possible. Reviewed By: kjchalup Differential Revision: D38932736 fbshipit-source-id: 5b7074fc001f2390f4cf43c7267a8b37fd987547
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b0515e1461
commit
d19e6243d0
@@ -23,6 +23,7 @@ from pytorch3d.renderer.cameras import (
|
||||
PerspectiveCameras,
|
||||
)
|
||||
from pytorch3d.renderer.compositing import alpha_composite, norm_weighted_sum
|
||||
from pytorch3d.renderer.fisheyecameras import FishEyeCameras
|
||||
from pytorch3d.renderer.points import (
|
||||
AlphaCompositor,
|
||||
NormWeightedCompositor,
|
||||
@@ -84,6 +85,49 @@ class TestRenderPoints(TestCaseMixin, unittest.TestCase):
|
||||
)
|
||||
self.assertClose(rgb, image_ref)
|
||||
|
||||
def test_simple_sphere_fisheye(self):
|
||||
device = torch.device("cuda:0")
|
||||
sphere_mesh = ico_sphere(1, device)
|
||||
verts_padded = sphere_mesh.verts_padded()
|
||||
# Shift vertices to check coordinate frames are correct.
|
||||
verts_padded[..., 1] += 0.2
|
||||
verts_padded[..., 0] += 0.2
|
||||
pointclouds = Pointclouds(
|
||||
points=verts_padded, features=torch.ones_like(verts_padded)
|
||||
)
|
||||
R, T = look_at_view_transform(2.7, 0.0, 0.0)
|
||||
cameras = FishEyeCameras(
|
||||
device=device,
|
||||
R=R,
|
||||
T=T,
|
||||
use_radial=False,
|
||||
use_tangential=False,
|
||||
use_thin_prism=False,
|
||||
world_coordinates=True,
|
||||
)
|
||||
raster_settings = PointsRasterizationSettings(
|
||||
image_size=256, radius=5e-2, points_per_pixel=1
|
||||
)
|
||||
rasterizer = PointsRasterizer(cameras=cameras, raster_settings=raster_settings)
|
||||
compositor = NormWeightedCompositor()
|
||||
renderer = PointsRenderer(rasterizer=rasterizer, compositor=compositor)
|
||||
|
||||
# Load reference image
|
||||
filename = "render_fisheye_sphere_points.png"
|
||||
image_ref = load_rgb_image("test_%s" % filename, DATA_DIR)
|
||||
|
||||
for bin_size in [0, None]:
|
||||
# Check both naive and coarse to fine produce the same output.
|
||||
renderer.rasterizer.raster_settings.bin_size = bin_size
|
||||
images = renderer(pointclouds)
|
||||
rgb = images[0, ..., :3].squeeze().cpu()
|
||||
if DEBUG:
|
||||
filename = "DEBUG_%s" % filename
|
||||
Image.fromarray((rgb.numpy() * 255).astype(np.uint8)).save(
|
||||
DATA_DIR / filename
|
||||
)
|
||||
self.assertClose(rgb, image_ref)
|
||||
|
||||
def test_simple_sphere_pulsar(self):
|
||||
for device in [torch.device("cpu"), torch.device("cuda")]:
|
||||
sphere_mesh = ico_sphere(1, device)
|
||||
|
||||
Reference in New Issue
Block a user