Get extrinsics(cam2world) of an iPhone RGB camera by iPhone id. Args: iphone_id (int, optional): ID of an iPhone, starts from 0. Defaults to 0. homogeneous (bool, optional): If true, returns rotation and translation in
(self,
iphone_id=0,
homogeneous=True,
vertical=True)
| 251 | return intrinsics |
| 252 | |
| 253 | def get_iphone_extrinsics(self, |
| 254 | iphone_id=0, |
| 255 | homogeneous=True, |
| 256 | vertical=True): |
| 257 | """Get extrinsics(cam2world) of an iPhone RGB camera by iPhone id. |
| 258 | |
| 259 | Args: |
| 260 | iphone_id (int, optional): |
| 261 | ID of an iPhone, starts from 0. |
| 262 | Defaults to 0. |
| 263 | homogeneous (bool, optional): |
| 264 | If true, returns rotation and translation in |
| 265 | one 4x4 matrix. Defaults to True. |
| 266 | vertical (bool, optional): |
| 267 | iPhone assumes landscape orientation |
| 268 | if True, convert data to vertical orientation |
| 269 | Defaults to True. |
| 270 | |
| 271 | Returns: |
| 272 | homogeneous is True |
| 273 | ndarray: A 4x4 transformation matrix(cam2world). |
| 274 | homogeneous is False |
| 275 | dict: A dict of rotation and translation, |
| 276 | keys are R and T, |
| 277 | each value is an ndarray. |
| 278 | """ |
| 279 | if iphone_id != 0: |
| 280 | raise KeyError('Currently only one iPhone.') |
| 281 | R = np.asarray(self.calibration_dict['iPhone']['R']).reshape(3, 3) |
| 282 | T = np.asarray(self.calibration_dict['iPhone']['T']).reshape(3) |
| 283 | |
| 284 | # cam2world |
| 285 | extrinsics = np.identity(4, dtype=float) |
| 286 | extrinsics[:3, :3] = R |
| 287 | extrinsics[:3, 3] = T |
| 288 | |
| 289 | # Extrinsics have to be adjusted to achieve rotation |
| 290 | # A rotation matrix is applied on the extrinsics |
| 291 | if vertical: |
| 292 | # 90-degree clockwise rotation around z-axis |
| 293 | R = np.eye(4) |
| 294 | R[:2, :2] = np.array([[0, -1], [1, 0]]) |
| 295 | # Note the extrinsics is cam2world |
| 296 | # world2cam_adjusted = R @ world2cam |
| 297 | # => cam2world_adjusted = cam2world @ inv(R) |
| 298 | extrinsics = extrinsics @ np.linalg.inv(R) |
| 299 | R = extrinsics[:3, :3] |
| 300 | T = extrinsics[:3, 3] |
| 301 | |
| 302 | if homogeneous: |
| 303 | return extrinsics |
| 304 | else: |
| 305 | return {'R': R, 'T': T} |
| 306 | |
| 307 | def get_iphone_color_resolution(self, iphone_id=0, vertical=True): |
| 308 | """Get color image resolution of an iPhone RGB camera by iPhone id. |
no outgoing calls
no test coverage detected