14
14
# If not, see <https://www.gnu.org/licenses/>.
15
15
16
16
"""Camera models for projecting between 3D world and 2D pixel coordinates."""
17
+
17
18
from __future__ import annotations
18
19
19
20
import logging
20
21
import warnings
21
22
from abc import ABC , abstractmethod
23
+ from collections .abc import Sequence
22
24
from os import PathLike
23
- from typing import Sequence
24
25
25
26
import cv2
26
27
import numpy as np
33
34
34
35
from orthority import common
35
36
from orthority .enums import CameraType , Interp
36
- from orthority .errors import CameraInitError , OrthorityWarning , OrthorityError
37
+ from orthority .errors import CameraInitError , OrthorityError , OrthorityWarning
37
38
from orthority .param_io import _opk_to_rotation
38
39
39
40
logger = logging .getLogger (__name__ )
@@ -63,15 +64,15 @@ def im_size(self) -> tuple[int, int]:
63
64
def _validate_world_coords (xyz : np .ndarray ) -> None :
64
65
"""Utility function to validate world coordinate dimensions."""
65
66
if not (xyz .ndim == 2 and xyz .shape [0 ] == 3 ):
66
- raise ValueError (f "'xyz' should be a 3xN 2D array." )
67
+ raise ValueError ("'xyz' should be a 3xN 2D array." )
67
68
if xyz .dtype != np .float64 :
68
- raise ValueError (f "'xyz' should have 'float64' data type." )
69
+ raise ValueError ("'xyz' should have 'float64' data type." )
69
70
70
71
@staticmethod
71
72
def _validate_pixel_coords (ji : np .ndarray ) -> None :
72
73
"""Utility function to validate pixel coordinate dimensions."""
73
74
if not (ji .ndim == 2 and ji .shape [0 ] == 2 ):
74
- raise ValueError (f "'ji' should be a 2xN 2D array." )
75
+ raise ValueError ("'ji' should be a 2xN 2D array." )
75
76
76
77
@staticmethod
77
78
def _validate_z (z : np .ndarray , ji : np .ndarray ) -> None :
@@ -80,7 +81,7 @@ def _validate_z(z: np.ndarray, ji: np.ndarray) -> None:
80
81
z .ndim != 1 or (z .shape [0 ] != 1 and ji .shape [1 ] != 1 and z .shape [0 ] != ji .shape [1 ])
81
82
):
82
83
raise ValueError (
83
- f "'z' should be a single value or 1-by-N array where 'ji' is 2-by-N or 2-by-1."
84
+ "'z' should be a single value or 1-by-N array where 'ji' is 2-by-N or 2-by-1."
84
85
)
85
86
86
87
def _validate_image (self , im_array : np .ndarray ) -> None :
@@ -715,7 +716,7 @@ def _get_extrinsic(
715
716
def _test_init (self ) -> None :
716
717
"""Utility function to test if exterior parameters are initialised."""
717
718
if self ._R is None or self ._T is None :
718
- raise CameraInitError (f 'Exterior parameters not initialised.' )
719
+ raise CameraInitError ('Exterior parameters not initialised.' )
719
720
720
721
def _horizon_fov (self ) -> bool :
721
722
"""Whether this camera's field of view includes, or is above, the horizon."""
@@ -747,7 +748,7 @@ def _get_undistort_intrinsic(self, alpha: float) -> tuple[np.ndarray, np.ndarray
747
748
# Note that cv2.fisheye.estimateNewCameraMatrixForUndistortRectify() does not include all
748
749
# source pixels for balance=1. This method works for all subclasses including fisheye.
749
750
def _get_rectangles (
750
- im_size : tuple [int , int ]
751
+ im_size : tuple [int , int ],
751
752
) -> tuple [tuple [np .ndarray , np .ndarray ], tuple [np .ndarray , np .ndarray ]]:
752
753
"""Return inner and outer rectangles for distorted image grid points."""
753
754
w , h = np .array (im_size ) - 1
0 commit comments