3from __future__
import annotations
6from typing
import TypeAlias, Any
9import numpy.typing
as npt
11from ids_peak_icv
import lib_loader
21ImageArray: TypeAlias = npt.NDArray[np.object_]
27 Class for calibrating a camera.
29 The CameraCalibration calculates the intrinsic and extrinsic parameters,
30 as well as the mean reprojection error.
32 @ingroup ids_peak_icv_python_calibration
33 @since ids_peak_icv 1.1
40 Creates an instance of class CameraCalibration.
42 For a camera calibration a calibration plate is needed.
44 @param calibration_plate: A calibration plate.
46 @return A new instance of CameraCalibration.
48 @since ids_peak_icv 1.1
50 return cls(_calibration_plate=calibration_plate)
52 def __init__(self, *args: Any, **kwargs: Any) ->
None:
55 In order to create a CameraCalibration, please refer to the classmethods.
57 @since ids_peak_icv 1.1
63 "Cannot initialize {} with __init__. Please use a classmethod.".format(self.__class__.__name__))
65 def process(self, images: ImageArray) -> CalibrationResult:
68 Applies the camera calibration and calculates the intrinsic and extrinsic
69 camera parameters based on several views of a calibration pattern.
70 Furthermore, it computes the mean reprojection error.
72 @note This operation disregards any specified image regions. It processes the entire image.
74 @param images: A list of images containing a calibration plate in different poses.
76 @exception MismatchException: If no images are provided, or if the sizes of the images are different.
77 @exception NotSupportedException: If the pattern of the calibration plate is not supported or
78 the image has an unsupported format.
79 @exception TargetNotFoundException: If the marker points were not found on the given image.
81 @since ids_peak_icv 1.1
83 if not isinstance(images, np.ndarray):
85 "Parameter images has to be a numpy array of ids_peak_icv or ids_peak_ipl images.")
89 _images.append(_check_and_get_icv_image(image))
91 image_handles = create_array(ctypes.c_void_p, len(_images))
92 transform(_images, image_handles,
lambda image: image._handle)
95 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_Result_Create,
96 ctypes.pointer(result_handle))
97 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_Process, self.
_calibration_plate._handle,
99 ctypes.c_size_t(len(image_handles)), ctypes.pointer(result_handle))
Class for holding the results of a camera calibration.
Class for calibrating a camera.
CameraCalibration create_from_plate(cls, CalibrationPlate calibration_plate)
Creates an instance of class CameraCalibration.
CalibrationResult process(self, ImageArray images)
Applies the camera calibration and calculates the intrinsic and extrinsic camera parameters based on ...
None __init__(self, *Any args, **Any kwargs)
In order to create a CameraCalibration, please refer to the classmethods.
Occurs when an operation cannot be performed due to logical constraints (e.g., camera calibration wit...
Occurs when a requested operation is not implemented or supported (e.g., exporting to an unsupported ...