Data Types

Module: cutoop.data_types.

Data types are defined to unify the parameter types of functions. Moreover, they’re able to be stored to and retrieved from JSON file.

classCameraIntrinsicsBase​(fx: float, fy: float, cx: float, cy: float, width: float, height: float)

Bases: object

Camera intrinsics data. The unit of fx, fy, cx, cy, width, height are all pixels.

methodto_matrix​()

Transform to 3x3 K matrix. i. e.:

[[fx, 0,  cx],
 [0,  fy, cy],
 [0,  0,  1 ]]

Returns: 3x3 numpy array.

classPose​(quaternion: tuple[float, float, float, float], translation: tuple[float, float, float])

Bases: object

Object/Camera pose representation

propertyquaternion: tuple[float, float, float, float]

quaternion in scale-first format (wxyz)

propertytranslation: tuple[float, float, float]

translation from object (centered) space to camera space

methodto_affine​(scale = None)

transform to affine transformation (with no additional scaling)

Returns: 4x4 numpy array.

Here’s an example of getting Pose from rotation matrix:

>>> from cutoop.data_types import Pose
>>> from scipy.spatial.transform import Rotation
>>> x, y, z, w = Rotation.from_matrix([
...     [ 0.,  0.,  1.],
...     [ 0.,  1.,  0.],
...     [-1.,  0.,  0.]
... ]).as_quat()
>>> pose = Pose(quaternion=[w, x, y, z], translation=[1, 1, 1])
>>> pose.to_affine()
array([[ 0.,  0.,  1.,  1.],
       [ 0.,  1.,  0.,  1.],
       [-1.,  0.,  0.,  1.],
       [ 0.,  0.,  0.,  1.]], dtype=float32)