IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
intrinsic_parameters.py
Go to the documentation of this file.
1from __future__ import annotations
2
3from typing import Any
4
5import numpy as np
6
7from ids_peak_icv.datatypes.binning_factor import BinningFactor
10from ids_peak_icv.backend.datatypes import peak_icv_intrinsic_parameters, ctypes_objects_equal
11from ids_peak_icv.exceptions import NotPossibleException
12
13
15 """!
16 @brief
17 Class for intrinsic parameters.
18
19 The intrinsic parameters contain the necessary information to use the camera calibration.
20
21 This class contains only the intrinsic parameters. These parameters are essential for image
22 operations like point cloud generation, image undistortion, and other calibration-dependent operations.
23
24 @ingroup ids_peak_icv_python_calibration
25 @since ids_peak_icv 1.1
26 """
27
28 def __init__(self, *args: Any, **kwargs: Any) -> None:
29 """!
30 @brief
31 In order to create IntrinsicParameters, please refer to the classmethods.
32
33 @since ids_peak_icv 1.1
34 """
35 try:
36 self._parameters: peak_icv_intrinsic_parameters = kwargs["_parameters"]
37 except KeyError:
38 raise NotPossibleException("{} shall not be initialized".format(self.__class__.__name__))
39
40 @property
41 def principle_point(self) -> Point:
42 """!
43 @brief
44 Returns the principle point.
45
46 @return Point representing the principle point.
47
48 @since ids_peak_icv 1.1
49 """
50 return Point(
51 self._parameters.principle_point.x, self._parameters.principle_point.y)
52
53 @property
54 def distortion_coefficients(self) -> np.ndarray:
55 """!
56 @brief
57 Returns the distortion coefficients.
58
59 @return A numpy array of size 14 containing the distortion coefficients.
60
61 @since ids_peak_icv 1.1
62 """
63
64 coefficients = (list(self._parameters.distortion_coefficients.radial_distortion.coefficients)
65 + list(self._parameters.distortion_coefficients.tangential_distortion.coefficients)
66 + list(self._parameters.distortion_coefficients.prism_distortion.coefficients)
67 + list(self._parameters.distortion_coefficients.tilt_distortion.coefficients))
68
69 return np.array(coefficients, dtype=np.float32)
70
71 @property
73 """!
74 @brief
75 Returns the focal length pixel size ratio.
76
77 @return Point representing the focal length pixel size ratio.
78
79 @since ids_peak_icv 1.1
80 """
81 return Point(
82 self._parameters.focal_length_pixel_size_ratio.x, self._parameters.focal_length_pixel_size_ratio.y)
83
84 @property
85 def image_size(self) -> Size:
86 """!
87 @brief
88 Returns image size
89
90 @return Size representing the image size.
91
92 @since ids_peak_icv 1.1
93 """
94 return Size(
95 self._parameters.image_size.width, self._parameters.image_size.height)
96
97 @property
98 def binning_factor(self) -> BinningFactor:
99 """!
100 @brief
101 Returns binning factor
102
103 @return Binning factor of the image.
104
105 @since ids_peak_icv 1.1
106 """
107 return BinningFactor(self._parameters.binning_factor.x, self._parameters.binning_factor.y)
108
109 def __eq__(self, other: object) -> bool:
110 if not isinstance(other, IntrinsicParameters):
111 return False
112 return ctypes_objects_equal(self._parameters, other._parameters)
Represents a point in 2D space with x and y coordinates.
Definition point.py:6
A size consists of width and height where width and height have to be greater than or equal to zero.
Definition size.py:9
None __init__(self, *Any args, **Any kwargs)
In order to create IntrinsicParameters, please refer to the classmethods.
Point focal_length_pixel_size_ratio(self)
Returns the focal length pixel size ratio.
np.ndarray distortion_coefficients(self)
Returns the distortion coefficients.
The binning factor for the x and y directions must consist of positive integer values.
Thrown when an operation cannot be performed due to logical constraints.
Definition exceptions.py:85