mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 05:40:34 +08:00
Add PyTorch3D->OpenCV camera parameter conversion.
Summary: This diff implements the inverse of D28992470 (8006842f2a): a function to extract OpenCV convention camera parameters from a PyTorch3D `PerspectiveCameras` object. This is the first part of the new PyTorch3d<>OpenCV<>Pulsar conversion functions.
Reviewed By: patricklabatut
Differential Revision: D29278411
fbshipit-source-id: 68d4555b508dbe8685d8239443f839d194cc2484
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e4039aa570
commit
da9974b416
@@ -15,6 +15,7 @@ from pytorch3d.ops import eyes
|
||||
from pytorch3d.transforms import so3_exponential_map, so3_log_map
|
||||
from pytorch3d.utils import (
|
||||
cameras_from_opencv_projection,
|
||||
opencv_from_cameras_projection,
|
||||
)
|
||||
|
||||
DATA_DIR = get_tests_dir() / "data"
|
||||
@@ -151,3 +152,11 @@ class TestCameraConversions(TestCaseMixin, unittest.TestCase):
|
||||
self.assertClose(
|
||||
pts_proj_opencv_in_pytorch3d_screen, pts_proj_pytorch3d, atol=1e-5
|
||||
)
|
||||
|
||||
# Check the inverse.
|
||||
rvec_i, tvec_i, camera_matrix_i = opencv_from_cameras_projection(
|
||||
cameras_opencv_to_pytorch3d, image_size
|
||||
)
|
||||
self.assertClose(rvec, rvec_i)
|
||||
self.assertClose(tvec, tvec_i)
|
||||
self.assertClose(camera_matrix, camera_matrix_i)
|
||||
|
||||
Reference in New Issue
Block a user