mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 22:30: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)
|
||||
|
||||
Reference in New Issue
Block a user