Compute camera for eye position.
(self, eye_pos: torch.Tensor)
| 319 | ) |
| 320 | |
| 321 | def compute(self, eye_pos: torch.Tensor) -> CameraInfo: |
| 322 | """Compute camera for eye position.""" |
| 323 | extrinsics = self.screen_extrinsics.clone() |
| 324 | |
| 325 | origin = eye_pos if self.lookat_mode == "ahead" else torch.zeros(3) |
| 326 | |
| 327 | if self.lookat_point is None: |
| 328 | depth_focus = max(self.min_depth_focus, self.depth_quantiles.focus) |
| 329 | look_at_position = origin + torch.tensor([0.0, 0.0, depth_focus]) |
| 330 | else: |
| 331 | look_at_position = origin + torch.tensor([*self.lookat_point]) |
| 332 | |
| 333 | world_up = torch.tensor([0.0, -1.0, 0.0]) |
| 334 | extrinsics_modifier = create_camera_matrix( |
| 335 | eye_pos, look_at_position, world_up, inverse=True |
| 336 | ) |
| 337 | extrinsics = extrinsics_modifier @ self.screen_extrinsics |
| 338 | |
| 339 | camera_info = CameraInfo( |
| 340 | intrinsics=self.screen_intrinsics, |
| 341 | extrinsics=extrinsics, |
| 342 | width=self.screen_resolution_px[0], |
| 343 | height=self.screen_resolution_px[1], |
| 344 | ) |
| 345 | return camera_info |
| 346 | |
| 347 | def set_screen_extrinsics(self, new_value: torch.Tensor) -> None: |
| 348 | """Modify the default extrinsics.""" |
no test coverage detected