Pinhole Camera¶
Pinhole Metadata¶
- class py123d.datatypes.PinholeCameraMetadata[source]¶
Static metadata for a pinhole camera, stored in a log.
Public Data Attributes:
camera_modelThe projection model of this camera.
camera_nameThe name of the pinhole camera, according to the dataset naming convention.
camera_idThe
CameraIDof the pinhole camera.intrinsicsThe
PinholeIntrinsicsof the pinhole camera.distortionThe
PinholeDistortionof the pinhole camera.widthThe image width in pixels.
heightThe image height in pixels.
camera_to_imu_se3The camera-to-IMU extrinsic
PoseSE3of the pinhole camera.is_undistortedWhether the camera images are already undistorted.
is_distortedWhether the camera images are distorted.
fov_xThe horizontal field of view (FOV) of the pinhole camera in radians, if available.
fov_yThe vertical field of view (FOV) of the pinhole camera in radians, if available.
Inherited from
BaseCameraMetadatacamera_modelThe projection model of the camera.
camera_idThe camera ID, unique within a sensor rig.
camera_nameThe camera name, according to the dataset naming convention.
camera_to_imu_se3The static extrinsic pose of the camera relative to the IMU frame.
widthThe width of the camera image in pixels.
heightThe height of the camera image in pixels.
channel_typeThe channel type of the camera image.
modality_typeReturns the type of the modality that this metadata describes.
modality_idReturns the camera ID as the modality ID.
aspect_ratioThe aspect ratio (width / height) of the camera.
Inherited from
BaseModalityMetadatamodality_typeReturns the type of the modality that this metadata describes.
modality_idOptional identifier for the modality, e.g. sensor ID for sensor modalities.
modality_keyReturns a unique key for this modality, combining type and id if applicable.
Public Methods:
from_dict(data_dict)Create a
PinholeCameraMetadatafrom a dictionary.to_dict()Converts the
PinholeCameraMetadatato a dictionary.project_to_image(points_cam)Project 3D points in camera frame to image pixel coordinates using the pinhole model.
Inherited from
BaseCameraMetadataproject_to_image(points_cam)Project 3D points in camera frame to image pixel coordinates.
Inherited from
BaseMetadatato_dict()Serialize the metadata instance to a plain Python dictionary.
from_dict(data_dict)Construct a metadata instance from a plain Python dictionary.
Private Methods:
Inherited from
BaseCameraMetadata_compute_in_fov_mask(pixel_coords, depth[, eps])Compute a boolean mask for points in front of the camera and within image bounds.
- classmethod from_dict(data_dict)[source]¶
Create a
PinholeCameraMetadatafrom a dictionary.
- to_dict()[source]¶
Converts the
PinholeCameraMetadatato a dictionary.
- property camera_model: CameraModel¶
The projection model of this camera.
- property camera_name: str¶
The name of the pinhole camera, according to the dataset naming convention.
- property channel_type: CameraChannelType¶
The channel type of the camera image. Defaults to RGB.
- property intrinsics: PinholeIntrinsics | None¶
The
PinholeIntrinsicsof the pinhole camera.
- property modality_key: str¶
Returns a unique key for this modality, combining type and id if applicable.
- property modality_type: ModalityType¶
Returns the type of the modality that this metadata describes.
- property distortion: PinholeDistortion | None¶
The
PinholeDistortionof the pinhole camera.
- project_to_image(points_cam)[source]¶
Project 3D points in camera frame to image pixel coordinates using the pinhole model.
If the camera has distortion parameters and images are not pre-undistorted, the OpenCV radial-tangential distortion model is applied so that projected pixels match the raw (distorted) image.
- Parameters:
points_cam (
ndarray[tuple[Any,...],dtype[float64]]) – (N, 3) array of 3D points in the camera coordinate frame.- Return type:
Tuple[ndarray[tuple[Any,...],dtype[float64]],ndarray[tuple[Any,...],dtype[bool]],ndarray[tuple[Any,...],dtype[float64]]]- Returns:
A tuple of (pixel_coords (N,2), in_fov_mask (N,), depth (N,)).
- Raises:
ValueError – If intrinsics are not set.
Pinhole Intrinsics¶
- class py123d.datatypes.PinholeIntrinsics[source]¶
Pinhole camera intrinsics representation.
Public Data Attributes:
arrayA numpy array representation of the pinhole intrinsics, indexed by
PinholeIntrinsicsIndex.fxFocal length in x direction.
fyFocal length in y direction.
cxOptical center x coordinate.
cyOptical center y coordinate.
skewSkew coefficient.
camera_matrixThe 3x3 camera intrinsic matrix K.
Inherited from
ArrayMixinarrayThe array representation of the geometric entity.
shapeReturn the shape of the array.
Public Methods:
from_array(array[, copy])Creates a PinholeIntrinsics from a numpy array, indexed by
PinholeIntrinsicsIndex.from_camera_matrix(intrinsic)Create a PinholeIntrinsics from a 3x3 intrinsic matrix.
Inherited from
ArrayMixinfrom_array(array[, copy])Create an instance from a NumPy array.
from_list(values)Create an instance from a list of values.
tolist()Convert the array to a Python list.
to_list()Convert the array to a Python list.
copy()Return a copy of the object with a copied array.
- classmethod from_array(array, copy=True)[source]¶
Creates a PinholeIntrinsics from a numpy array, indexed by
PinholeIntrinsicsIndex.- Parameters:
- Return type:
- Returns:
A
PinholeIntrinsicsinstance.
- classmethod from_camera_matrix(intrinsic)[source]¶
Create a PinholeIntrinsics from a 3x3 intrinsic matrix.
Pinhole Distortion¶
- class py123d.datatypes.PinholeDistortion[source]¶
Pinhole camera distortion representation.
Public Data Attributes:
arrayA numpy array representation of the pinhole distortion, indexed by
PinholeDistortionIndex.k1Radial distortion coefficient k1.
k2Radial distortion coefficient k2.
p1Tangential distortion coefficient p1.
p2Tangential distortion coefficient p2.
k3Radial distortion coefficient k3.
Inherited from
ArrayMixinarrayThe array representation of the geometric entity.
shapeReturn the shape of the array.
Public Methods:
from_array(array[, copy])Creates a PinholeDistortion from a numpy array, indexed by
PinholeDistortionIndex.Inherited from
ArrayMixinfrom_array(array[, copy])Create an instance from a NumPy array.
from_list(values)Create an instance from a list of values.
tolist()Convert the array to a Python list.
to_list()Convert the array to a Python list.
copy()Return a copy of the object with a copied array.
- classmethod from_array(array, copy=True)[source]¶
Creates a PinholeDistortion from a numpy array, indexed by
PinholeDistortionIndex.- Parameters:
- Return type:
- Returns:
A
PinholeDistortioninstance.