mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 22:00:35 +08:00
Updates to cameras and rasterizer to infer camera type correctly
Summary: Small update to the cameras and rasterizer to correctly infer the type of camera (perspective vs orthographic). Reviewed By: jcjohnson Differential Revision: D26267225 fbshipit-source-id: a58ed3bc2ab25553d2a4307c734204c1d41b5176
This commit is contained in:
committed by
Facebook GitHub Bot
parent
39f49c22cd
commit
838b73d3b6
@@ -794,6 +794,11 @@ class TestFoVPerspectiveProjection(TestCaseMixin, unittest.TestCase):
|
||||
new_points = cam.transform_points(points)
|
||||
self.assertClose(new_points, projected_points)
|
||||
|
||||
def test_perspective_type(self):
|
||||
cam = FoVPerspectiveCameras(znear=1.0, zfar=10.0, fov=60.0)
|
||||
self.assertTrue(cam.is_perspective())
|
||||
self.assertEquals(cam.get_znear(), 1.0)
|
||||
|
||||
|
||||
############################################################
|
||||
# FoVOrthographic Camera #
|
||||
@@ -885,6 +890,11 @@ class TestFoVOrthographicProjection(TestCaseMixin, unittest.TestCase):
|
||||
)
|
||||
self.assertClose(scale_grad, grad_scale)
|
||||
|
||||
def test_perspective_type(self):
|
||||
cam = FoVOrthographicCameras(znear=1.0, zfar=10.0)
|
||||
self.assertFalse(cam.is_perspective())
|
||||
self.assertEquals(cam.get_znear(), 1.0)
|
||||
|
||||
|
||||
############################################################
|
||||
# Orthographic Camera #
|
||||
@@ -937,6 +947,11 @@ class TestOrthographicProjection(TestCaseMixin, unittest.TestCase):
|
||||
v1 = P.transform_points(vertices)
|
||||
self.assertClose(v1, projected_verts)
|
||||
|
||||
def test_perspective_type(self):
|
||||
cam = OrthographicCameras(focal_length=5.0, principal_point=((2.5, 2.5),))
|
||||
self.assertFalse(cam.is_perspective())
|
||||
self.assertEquals(cam.get_znear(), None)
|
||||
|
||||
|
||||
############################################################
|
||||
# Perspective Camera #
|
||||
@@ -983,3 +998,8 @@ class TestPerspectiveProjection(TestCaseMixin, unittest.TestCase):
|
||||
v1 = P.transform_points(vertices)
|
||||
v2 = sfm_perspective_project_naive(vertices, fx=2.0, fy=2.0, p0x=2.5, p0y=3.5)
|
||||
self.assertClose(v1, v2, atol=1e-6)
|
||||
|
||||
def test_perspective_type(self):
|
||||
cam = PerspectiveCameras(focal_length=5.0, principal_point=((2.5, 2.5),))
|
||||
self.assertTrue(cam.is_perspective())
|
||||
self.assertEquals(cam.get_znear(), None)
|
||||
|
||||
@@ -242,7 +242,10 @@ class TestRenderImplicit(TestCaseMixin, unittest.TestCase):
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras_randomized,
|
||||
raster_settings=RasterizationSettings(
|
||||
image_size=image_size, blur_radius=1e-3, faces_per_pixel=10
|
||||
image_size=image_size,
|
||||
blur_radius=1e-3,
|
||||
faces_per_pixel=10,
|
||||
perspective_correct=False,
|
||||
),
|
||||
),
|
||||
shader=SoftPhongShader(
|
||||
|
||||
@@ -500,6 +500,7 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
blur_radius=np.log(1.0 / 1e-4 - 1.0) * blend_params.sigma,
|
||||
faces_per_pixel=100,
|
||||
clip_barycentric_coords=True,
|
||||
perspective_correct=False,
|
||||
)
|
||||
|
||||
# Load reference image
|
||||
@@ -844,7 +845,10 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
cameras = FoVPerspectiveCameras(device=device, R=R, T=T)
|
||||
|
||||
raster_settings = RasterizationSettings(
|
||||
image_size=512, blur_radius=0.0, faces_per_pixel=1
|
||||
image_size=512,
|
||||
blur_radius=0.0,
|
||||
faces_per_pixel=1,
|
||||
perspective_correct=False,
|
||||
)
|
||||
|
||||
lights = PointLights(
|
||||
@@ -919,7 +923,10 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
R, T = look_at_view_transform(2.7, 0.0, 0.0)
|
||||
cameras = FoVPerspectiveCameras(device=device, R=R, T=T)
|
||||
raster_settings = RasterizationSettings(
|
||||
image_size=512, blur_radius=0.0, faces_per_pixel=1
|
||||
image_size=512,
|
||||
blur_radius=0.0,
|
||||
faces_per_pixel=1,
|
||||
perspective_correct=False,
|
||||
)
|
||||
|
||||
# Init shader settings
|
||||
|
||||
Reference in New Issue
Block a user