A virtual camera, including its intrinsics and its pose.
| 8 | from .constants import Z_NEAR, Z_FAR |
| 9 | |
| 10 | class VirtualCamera(object): |
| 11 | """A virtual camera, including its intrinsics and its pose. |
| 12 | """ |
| 13 | |
| 14 | def __init__(self, intrinsics, T_camera_world=RigidTransform(from_frame='camera', to_frame='world'), |
| 15 | z_near=Z_NEAR, z_far=Z_FAR): |
| 16 | """Initialize a virtual camera with the given intrinsics and initial pose in the world. |
| 17 | |
| 18 | Parameters |
| 19 | ---------- |
| 20 | intrinsics : percetion.CameraIntrinsics |
| 21 | The intrinsic properties of the camera, from the Berkeley AUTOLab's perception module. |
| 22 | T_camera_world : autolab_core.RigidTransform |
| 23 | A transform from camera to world coordinates that indicates |
| 24 | the camera's pose. The camera frame's x axis points right, |
| 25 | its y axis points down, and its z axis points towards |
| 26 | the scene (i.e. standard OpenCV coordinates). |
| 27 | z_near : float |
| 28 | The near-plane clipping distance. |
| 29 | z_far : float |
| 30 | The far-plane clipping distance. |
| 31 | """ |
| 32 | if not isinstance(intrinsics, CameraIntrinsics): |
| 33 | raise ValueError('intrinsics must be an object of type CameraIntrinsics') |
| 34 | |
| 35 | self._intrinsics = intrinsics |
| 36 | self.T_camera_world = T_camera_world |
| 37 | self._z_near = z_near |
| 38 | self._z_far = z_far |
| 39 | |
| 40 | @property |
| 41 | def intrinsics(self): |
| 42 | """perception.CameraIntrinsics: The camera's intrinsic parameters. |
| 43 | """ |
| 44 | return self._intrinsics |
| 45 | |
| 46 | @property |
| 47 | def T_camera_world(self): |
| 48 | """autolab_core.RigidTransform: The camera's pose relative to the world frame. |
| 49 | """ |
| 50 | return self._T_camera_world |
| 51 | |
| 52 | @T_camera_world.setter |
| 53 | def T_camera_world(self, T): |
| 54 | if not isinstance(T, RigidTransform): |
| 55 | raise ValueError('transform must be an object of type RigidTransform') |
| 56 | if not T.from_frame == self._intrinsics.frame or not T.to_frame == 'world': |
| 57 | raise ValueError('transform must be from {} -> world, got {} -> {}'.format(self._intrinsics.frame, T.from_frame, T.to_frame)) |
| 58 | self._T_camera_world = T |
| 59 | |
| 60 | @property |
| 61 | def z_near(self): |
| 62 | """float: The near clipping distance. |
| 63 | """ |
| 64 | return self._z_near |
| 65 | |
| 66 | @z_near.setter |
| 67 | def z_near(self, z_near): |
no outgoing calls
no test coverage detected