Intrinsic parameters of a pinhole camera model. Attributes: width (int): The width in pixels of the camera. height(int): The height in pixels of the camera. K: The intrinsic camera matrix.
| 120 | return cls.from_matrix(m).inverse() |
| 121 | |
| 122 | class CameraIntrinsic(object): |
| 123 | """Intrinsic parameters of a pinhole camera model. |
| 124 | |
| 125 | Attributes: |
| 126 | width (int): The width in pixels of the camera. |
| 127 | height(int): The height in pixels of the camera. |
| 128 | K: The intrinsic camera matrix. |
| 129 | """ |
| 130 | |
| 131 | def __init__(self, width, height, fx, fy, cx, cy): |
| 132 | self.width = width |
| 133 | self.height = height |
| 134 | self.K = np.array([[fx, 0.0, cx], [0.0, fy, cy], [0.0, 0.0, 1.0]]) |
| 135 | |
| 136 | @property |
| 137 | def fx(self): |
| 138 | return self.K[0, 0] |
| 139 | |
| 140 | @property |
| 141 | def fy(self): |
| 142 | return self.K[1, 1] |
| 143 | |
| 144 | @property |
| 145 | def cx(self): |
| 146 | return self.K[0, 2] |
| 147 | |
| 148 | @property |
| 149 | def cy(self): |
| 150 | return self.K[1, 2] |
| 151 | |
| 152 | def to_dict(self): |
| 153 | """Serialize intrinsic parameters to a dict object.""" |
| 154 | data = { |
| 155 | "width": self.width, |
| 156 | "height": self.height, |
| 157 | "K": self.K.flatten().tolist(), |
| 158 | } |
| 159 | return data |
| 160 | |
| 161 | @classmethod |
| 162 | def from_dict(cls, data): |
| 163 | """Deserialize intrinisic parameters from a dict object.""" |
| 164 | intrinsic = cls( |
| 165 | width=data["width"], |
| 166 | height=data["height"], |
| 167 | fx=data["K"][0], |
| 168 | fy=data["K"][4], |
| 169 | cx=data["K"][2], |
| 170 | cy=data["K"][5], |
| 171 | ) |
| 172 | return intrinsic |
| 173 | |
| 174 | class Grasp(object): |
| 175 | """Grasp parameterized as pose of a 2-finger robot hand. |
no outgoing calls