Camera Interface¶
Camera interfaces allow for images to be obtained by either real or simulated cameras (rendering).
CameraInterface¶
-
class
perls2.sensors.camera_interface.
CameraInterface
(image_height, image_width, intrinsics, extrinsics=None, distortion=array([0., 0., 0., 0., 0.]), name='camera')¶ Abstract interface to be implemented for a sensor
-
property
distortion
¶ Camera distortion coefficients
-
property
intrinsics
¶ Camera intrinsics
-
property
name
¶ Name of the camera
-
reset
()¶ Restarts the sensor stream.
-
start
()¶ Starts the sensor stream.
-
stop
()¶ Stops the sensor stream.
- Returns
True if succeed, False if fail.
-
property
BulletCameraInterface¶
-
class
perls2.sensors.bullet_camera_interface.
BulletCameraInterface
(physics_id=None, image_height=500, image_width=500, near=0.02, far=100, distance=1.0, fov=60, cameraEyePosition=[0.6, 0.0, 1.0], cameraTargetPosition=[0.6, 0.0, 0], cameraUpVector=[1.0, 0.0, 1.0], name='bullet_camera') ” Interface for rendering camera images from PyBullet.
-
image_height
¶ Height of the image in pixels.
- Type
int
-
image_width
¶ Width of the image in pixels.
- Type
int
-
near
¶ The distance to the near plane.
- Type
float
-
far
¶ The distance to the far plane.
- Type
float
-
distance
¶ The distance from the camera to the object.
- Type
float
-
cameraEyePosition
¶ 3f xyz position of camera in world frame.
- Type
list
-
cameraTargetPosition
¶ 3f xyz position of camera target in world frame.
- Type
list
-
cameraUpVectory
¶ 3f vector describing camera up direction.
- Type
list
-
view_matrix
¶ View matrix
- Type
np.npdarray
-
projection_matrix
¶ projection matrix.
- Type
np.ndarray
-
name
¶ string identifying name of camera.
- Type
str
-
deproject
(pixel, depth, is_world_frame=True) Deprojects a single pixel with a given depth into a 3D point. :param pixel: 2D point representing the pixel location in camera image. :param depth: Depth value at the given pixel location. :param is_world_frame: True if the 3D point is defined in the world frame, (Default value = True)
- Returns
The deprojected 3D point.
- Return type
point
-
frames
() Render the world at the current time step. Args: None :returns: dict with rgb, depth and segmask image.
-
frames_rgb
() Render the world at the current time step. Args: None :returns: dict with rgb, depth and segmask image.
-
get_intrinsics
() Calculate camera intrinsic matrix.
-
property
image_height
Height of rendered image.
-
property
image_width
Width of rendered image.
-
place
(new_camera_pos) Places camera in new position
Modifies cameraEyePosition property and adjusts view and projection matrices
- Parameters
new_camera_pos (3f) – x y z coordinates of new camera position.
Returns: None
-
property
projection_matrix
Projection matrix.
-
set_physics_id
(physics_id) Set unique physics client id :param physics_id: new physics id to set. :type physics_id: int
-
set_projection_matrix
(projection_matrix) Set projection matrix for the camera. :param projection_matrix: list of 16 floats for pybullet projection matrix. :type projection_matrix: list
-
set_view_matrix
(view_matrix) Set View matrix for the camera :param view_matrix: list of 16 floats for pybullet view_matrix :type view_matrix: list
-
start
() Starts the camera stream.
-
stop
() Stops the sensor stream.
- Returns
True if succeed, False if fail.
-
property
view_matrix
View matrix.
-