1from __future__
import annotations
4from typing
import TypeAlias, Any, cast
7import numpy.typing
as npt
10from ids_peak_icv
import lib_loader
12 peak_icv_extrinsic_parameters, peak_icv_coordinate_system)
21ReprojectionErrorArray: TypeAlias = npt.NDArray[np.object_]
27 Class for holding the extrinsic result for one image of a camera calibration and also the reprojection
28 errors of every detected marker.
30 @ingroup ids_peak_icv_python_calibration
31 @since ids_peak_icv 1.1
37 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_Create,
38 ctypes.pointer(handle))
42 def __init__(self, *args: Any, **kwargs: Any) ->
None:
45 Please do not use this function. Refer to CalibrationResult.views to get views from a calibration result.
47 @since ids_peak_icv 1.1
56 if hasattr(self,
'_handle'):
57 lib_loader.dll().peak_icv_Calibration_View_Destroy(self.
_handle)
63 Provides the mean reprojection error from a calibration view.
65 The reprojection error is the distance between the marker points extracted from the calibration
66 images and the projected world points from CalibrationPlateInfo.
68 @return Returns the mean reprojection error.
70 @since ids_peak_icv 1.1
72 mean_reprojection_error = ctypes.c_double()
73 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetMeanReprojectionError,
75 ctypes.pointer(mean_reprojection_error))
76 return mean_reprojection_error.value
82 Provides the maximum reprojection error from a calibration view.
84 The reprojection error is the distance between the marker points extracted from the calibration
85 images and the projected world points from CalibrationPlateInfo.
87 @return Returns the maximum reprojection error.
89 @since ids_peak_icv 1.1
91 maximum_reprojection_error = ctypes.c_double()
92 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetMaximumReprojectionError,
94 ctypes.pointer(maximum_reprojection_error))
95 return maximum_reprojection_error.value
101 Provides the reprojection errors for every marker in the view.
103 The reprojection error is the distance between the marker points extracted from the calibration images and
104 the projected world points from CalibrationPlateInfo.
106 @return Returns all reprojection errors.
108 @since ids_peak_icv 1.1
113 num_reprojection_errors = ctypes.c_size_t()
114 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetReprojectionErrors_GetCount,
116 ctypes.pointer(num_reprojection_errors))
118 if num_reprojection_errors.value == 0:
120 return cast(ReprojectionErrorArray, self.
_errors)
122 errors = create_array(peak_icv_reprojection_error, num_reprojection_errors.value)
123 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetReprojectionErrors, self.
_handle,
124 ctypes.pointer(errors), num_reprojection_errors)
127 self.
_errors = np.empty(len(errors), dtype=ReprojectionError)
128 for i, it
in enumerate(errors):
130 Vector(it.direction.x, it.direction.y), it.length)
132 return cast(ReprojectionErrorArray, self.
_errors)
135 def extrinsic_parameters(self) -> ExtrinsicParameters:
138 Provides the extrinsic parameters for the view.
140 A view always contains extrinsic parameters that describe the transformation from the calibration plate coordinate
141 system into the camera coordinate system.
143 @return Returns the extrinsic parameters from a calibration view.
145 @since ids_peak_icv 1.1
149 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetExtrinsicParameters,
151 ctypes.pointer(extrinsic_parameters), ctypes.sizeof(extrinsic_parameters))
159 Provides the convex hull of the found calibration pattern in the view.
161 @return Returns the convex hull as polygon from a calibration view.
163 @since ids_peak_icv 1.1
166 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetConvexHull,
168 ctypes.pointer(polygon._handle))
176 Provides the coordinate system of the calibration view that was projected into the image plane.
177 The coordinate system is represented by its origin and three vectors, each corresponding to one of the three coordinate axes (X, Y and
178 Z). These vectors describe the directions of the respective axes projected from 3D into 2D space. Their lengths are determined by twice
179 the distance between neighboring markers on the calibration plate.
181 @return Returns the coordinate system from a calibration view.
183 @since ids_peak_icv 1.1
186 execute_and_map_return_codes(lib_loader.dll().peak_icv_Calibration_View_GetCoordinateSystem,
188 ctypes.pointer(coordinate_system))
191 Point(coordinate_system.x_axis.x, coordinate_system.x_axis.y),
192 Point(coordinate_system.y_axis.x, coordinate_system.y_axis.y),
193 Point(coordinate_system.z_axis.x, coordinate_system.z_axis.y))
Represents a point in 2D space with x and y coordinates.
Class for holding the extrinsic result for one image of a camera calibration and also the reprojectio...
CalibrationView _create_empty(cls)
float maximum_reprojection_error(self)
Provides the maximum reprojection error from a calibration view.
Polygon convex_hull(self)
Provides the convex hull of the found calibration pattern in the view.
None __init__(self, *Any args, **Any kwargs)
Please do not use this function.
ReprojectionErrorArray reprojection_errors(self)
Provides the reprojection errors for every marker in the view.
CoordinateSystem coordinate_system(self)
Provides the coordinate system of the calibration view that was projected into the image plane.
float mean_reprojection_error(self)
Provides the mean reprojection error from a calibration view.
Class for handling extrinsic parameters related to camera calibration.
Represents the reprojection error in a calibration view.
Represents the coordinate system of a calibration view that was projected into the 2D plane.
A polygon is a two-dimensional geometric shape that is made up of a finite number of straight line se...
Thrown when an operation cannot be performed due to logical constraints.