def test_as_matrix(self): np.testing.assert_equal(SimpleCameraIntrinsics().as_matrix(), np.eye(3)) np.testing.assert_equal( SimpleCameraIntrinsics(10, (2, 3), 2, 5).as_matrix(), [[10, 5, 2], [0, 5, 3], [0, 0, 1]], )
def test_max_distort_radius(self): s = SimpleCameraIntrinsics( self.focal_length, self.principal_point, dist_coeffs=np.array([-0.1, 0.0, 0.0]), ) a = s.max_distort_radius() * s.max_distort_radius() b = s.get_max_distort_radius_sq() self.assertEqual(a, b)
def test_clone(self): s = SimpleCameraIntrinsics( self.focal_length, self.principal_point, dist_coeffs=np.array([-0.1, 0.0, 0.0]), ) s_clone = s.clone() assert (isinstance(s_clone, SimpleCameraIntrinsics)) self.assertEqual(s.focal_length(), s_clone.focal_length())
def test_is_map_valid(self): s = SimpleCameraIntrinsics( self.focal_length, self.principal_point, self.aspect_ratio, self.skew, self.dist_coeffs, self.image_width, self.image_height, ) assert (s.is_map_valid(np.array([1.0, -1.0])))
def test_distort_undistort(self): s = SimpleCameraIntrinsics( self.focal_length, self.principal_point, self.aspect_ratio, self.skew, self.dist_coeffs, self.image_width, self.image_height, ) np.testing.assert_array_almost_equal(np.array([2814.9, 1876.6]), s.distort(np.array([3, 2]))) np.testing.assert_array_almost_equal( np.array([0.92024957, 0.61349972]), s.undistort(np.array([3, 2])))
def test_map_unmap(self): s = SimpleCameraIntrinsics( self.focal_length, self.principal_point, self.aspect_ratio, self.skew, self.dist_coeffs, self.image_width, self.image_height, ) np.testing.assert_array_almost_equal(np.array([35377.05, 16426.53]), s.map(np.array([3, 2]))) np.testing.assert_array_almost_equal(np.array([0.084889, -0.316774]), s.unmap(np.array([3, 2])))
def test_init_from_string(self): ret_str = "0.09 1 1 0.83 2 3 4 2 9" ret_intr = SimpleCameraIntrinsics.from_string(ret_str) assert (isinstance(ret_intr, SimpleCameraIntrinsics)) self.assertEqual(ret_intr.focal_length(), 0.09) np.testing.assert_array_almost_equal(ret_intr.principal_point(), np.array([1, 3]))
def test_full_init_defaults(self): s = SimpleCameraIntrinsics(self.focal_length, self.principal_point) self.check_cam_intrins_properties_equal( s, aspect_ratio=1.0, skew=0.0, dist_coeffs=np.array([]), image_width=0, image_height=0, )
def test_full_init_kwargs(self): s = SimpleCameraIntrinsics( focal_length=self.focal_length, principal_point=self.principal_point, aspect_ratio=self.aspect_ratio, skew=self.skew, dist_coeffs=self.dist_coeffs, image_width=self.image_width, image_height=self.image_height, ) self.check_cam_intrins_properties_equal(s)
def test_get_set_skew(self): s = SimpleCameraIntrinsics() s.set_skew(self.skew) self.assertAlmostEqual(s.skew(), self.skew)
def test_str(self): s = SimpleCameraIntrinsics(self.focal_length, self.principal_point) s = str(s) assert (isinstance(s, str))
def check_finite_max_radius(self, a, b, c): mr = SimpleCameraIntrinsics().max_distort_radius_sq(a, b, c) self.assertGreater(mr, 0.0) assert (np.isfinite(mr)) self.assertAlmostEqual(self.dist_deriv(mr, a, b, c), 0.0)
def test_init_from_base(self): no_call_pure_virtual_method(SimpleCameraIntrinsics, CameraIntrinsics()) SimpleCameraIntrinsics(SimpleCameraIntrinsics())
def test_get_set_dist_coeffs(self): s = SimpleCameraIntrinsics() s.set_dist_coeffs(self.dist_coeffs) np.testing.assert_array_almost_equal(s.dist_coeffs(), self.dist_coeffs)
def test_get_set_image_height(self): s = SimpleCameraIntrinsics() s.set_image_height(self.image_height) self.assertAlmostEqual(s.image_height(), self.image_height)
def test_get_set_aspect_ratio(self): s = SimpleCameraIntrinsics() s.set_aspect_ratio(self.aspect_ratio) self.assertAlmostEqual(s.aspect_ratio(), self.aspect_ratio)
def test_get_set_principal_point(self): s = SimpleCameraIntrinsics() s.set_principal_point(self.principal_point) np.testing.assert_array_almost_equal(s.principal_point(), self.principal_point)
def test_get_set_focal_length(self): s = SimpleCameraIntrinsics() s.set_focal_length(self.focal_length) self.assertAlmostEqual(s.focal_length(), self.focal_length)
def test_init_from_calibration_mat_defaults(self): s = SimpleCameraIntrinsics(self.K) self.check_cam_intrins_properties_equal(s, dist_coeffs=np.array([]), check_width_height=False)
def test_init_from_calibration_mat(self): s = SimpleCameraIntrinsics(self.K, self.dist_coeffs) # This constructor doesn't initialize the width and height of the image, # so we wont check those self.check_cam_intrins_properties_equal(s, check_width_height=False)
def test_get_set_image_width(self): s = SimpleCameraIntrinsics() s.set_image_width(self.image_width) self.assertAlmostEqual(s.image_width(), self.image_width)
def test_default_init(self): SimpleCameraIntrinsics()