Cameras

Setup and update cameras

NpOptiX.get_camera_names() → list[source]

Return list of cameras’ names.

NpOptiX.setup_camera(name: str, eye: Optional[Any] = None, target: Optional[Any] = None, up: Any = array([0., 1., 0.], dtype=float32), cam_type: Union[plotoptix.enums.Camera, str] = <Camera.Pinhole: 0>, aperture_radius: float = 0.1, aperture_fract: float = 0.15, focal_scale: float = 1.0, fov: float = 35.0, blur: float = 1, make_current: bool = True) → None[source]

Setup new camera with given name.

Parameters
  • name (string) – Name of the new camera.

  • eye (array_like, optional) – Eye 3D position. Best fit for the current scene is computed if argument is not provided.

  • target (array_like, optional) – Target 3D position. Center of all geometries if argument not provided.

  • up (array_like, optional) – Up (vertical) direction. Y axis if argument not provided.

  • cam_type (Camera enum or string, optional) – Type (pinhole, depth of field, …), see plotoptix.enums.Camera. Cannot be changed after construction.

  • aperture_radius (float, optional) – Aperture radius (increases focus blur for depth of field cameras).

  • aperture_fract (float, optional) – Fraction of blind central spot of the aperture (results with ring-like bokeh if > 0). Cannot be changed after construction.

  • focal_scale (float, optional) – Focus distance / (eye - target).length.

  • fov (float, optional) – Field of view in degrees.

  • blur (float, optional) – Weight of the new frame in averaging with already accumulated frames. Range is (0; 1>, lower values result with a higher motion blur, value 1.0 turns off the blur (default). Cannot be changed after construction.

  • make_current (bool, optional) – Automatically switch to this camera if set to True.

NpOptiX.update_camera(name: Optional[str] = None, eye: Optional[Any] = None, target: Optional[Any] = None, up: Optional[Any] = None, aperture_radius: float = -1.0, focal_scale: float = -1.0, fov: float = -1.0) → None[source]

Update camera parameters.

Parameters
  • name (string) – Name of the camera to update.

  • eye (array_like, optional) – Eye 3D position.

  • target (array_like, optional) – Target 3D position.

  • up (array_like, optional) – Up (vertical) direction.

  • aperture_radius (float, optional) – Aperture radius (increases focus blur for depth of field cameras).

  • focal_scale (float, optional) – Focus distance / (eye - target).length.

  • fov (float, optional) – Field of view in degrees.

NpOptiX.get_current_camera() → Optional[str][source]

Get current camera name.

Returns

out – Name of the current camera or None if camera not set.

Return type

string, optional

NpOptiX.set_current_camera(name: str) → None[source]

Switch to another camera.

Parameters

name (string) – Name of the new current camera.

NpOptiX.camera_fit(camera: Optional[str] = None, geometry: Optional[str] = None, scale: float = 2.5) → None[source]

Fit the camera eye and target to contain geometry in the field of view.

Parameters
  • camera (string, optional) – Name of the new camera to fit; current camera if name not provided.

  • geometry (string, optional) – Name of the geometry to fit in view; all geometries if not provided.

  • scale (float, optional) – Adjustment of the prefered distance (useful for wide angle cameras).

Shifts and rotations

NpOptiX.camera_move_by(shift: Tuple[float, float, float]) → None[source]

Move current camera in the world coordinates.

Parameters

shift (tuple (float, float, float)) – (X, Y, Z) shift vector.

NpOptiX.camera_move_by_local(shift: Tuple[float, float, float]) → None[source]

Move current camera in the camera coordinates.

Camera coordinates are: X to the right, Y up, Z towards camera.

Parameters

shift (tuple (float, float, float)) – (X, Y, Z) shift vector.

NpOptiX.camera_rotate_by(rot: Tuple[float, float, float], center: Tuple[float, float, float]) → None[source]

Rotate current camera in the world coordinates about the center.

Rotation is done the world coordinates about Y, X, and then Z axis, by the angles provided with rot = (rx, ry, rz) parameter.

Parameters
  • rot (tuple (float, float, float)) – Rotation around (X, Y, Z) axis.

  • center (tuple (float, float, float)) – Rotation center.

NpOptiX.camera_rotate_by_local(rot: Tuple[float, float, float], center: Tuple[float, float, float]) → None[source]

Rotate current camera in the camera coordinates about the center.

Rotation is done the camera coordinates about Y (camera up, yaw), X (camera right, pitch), and then Z (towards camera, roll) axis, by the angles provided with rot = (rx, ry, rz) parameter.

Parameters
  • rot (tuple (float, float, float)) – Rotation around (X, Y, Z) axis.

  • center (tuple (float, float, float)) – Rotation center.

NpOptiX.camera_rotate_eye(rot: Tuple[float, float, float]) → None[source]

Rotate current camera eye about the target point in the world coordinates.

Rotation is done the world coordinates about Y, X, and then Z axis, by the angles provided with rot = (rx, ry, rz) parameter.

Parameters

rot (tuple (float, float, float)) – Rotation around (X, Y, Z) axis.

NpOptiX.camera_rotate_eye_local(rot: Tuple[float, float, float]) → None[source]

Rotate current camera eye about the target point in the camera coordinates.

Rotation is done the camera coordinates about Y (camera up, yaw), X (camera right, pitch), and then Z (towards camera, roll) axis, by the angles provided with rot = (rx, ry, rz) parameter.

Parameters

rot (tuple (float, float, float)) – Rotation around (X, Y, Z) axis.

NpOptiX.camera_rotate_target(rot: Tuple[float, float, float]) → None[source]

Rotate current camera target about the eye point in the world coordinates.

Rotation is done the world coordinates about Y, X, and then Z axis, by the angles provided with rot = (rx, ry, rz) parameter.

Parameters

rot (tuple (float, float, float)) – Rotation around (X, Y, Z) axis.

NpOptiX.camera_rotate_target_local(rot: Tuple[float, float, float]) → None[source]

Rotate current camera target about the eye point in the camera coordinates.

Rotation is done the camera coordinates about Y (camera up, yaw), X (camera right, pitch), and then Z (towards camera, roll) axis, by the angles provided with rot = (rx, ry, rz) parameter.

Parameters

rot (tuple (float, float, float)) – Rotation around (X, Y, Z) axis.

Read back camera properties

NpOptiX.get_camera_eye(name: Optional[str] = None) → Optional[numpy.ndarray][source]

Get camera eye coordinates.

Parameters

name (string, optional) – Name of the camera, use current camera if name not provided.

Returns

out – 3D coordinates of the camera eye or None if failed on accessing camera data.

Return type

np.ndarray, optional

NpOptiX.get_camera_target(name: Optional[str] = None) → Optional[numpy.ndarray][source]

Get camera target coordinates.

Parameters

name (string, optional) – Name of the camera, use current camera if name not provided.

Returns

out – 3D coordinates of the camera target or None if failed on accessing camera data.

Return type

np.ndarray, optional

NpOptiX.get_camera(name: Optional[str] = None) → Optional[dict][source]

Get camera parameters.

Parameters

name (string, optional) – Name of the camera, use current camera if name not provided.

Returns

out – Dictionary of the camera parameters or None if failed on accessing camera data.

Return type

dict, optional

NpOptiX.get_camera_name_handle(name: Optional[str] = None) -> (typing.Union[str, NoneType], typing.Union[int, NoneType])[source]

Get camera name and handle.

Mostly for the internal use.

Parameters

name (string, optional) – Camera name; current camera is used if name not provided.

Returns

out – Name and handle of the camera or (None, None) if camera not found.

Return type

tuple (name, handle)