Cameras
Setup and update cameras
- NpOptiX.setup_camera(name: str, eye: Optional[Any] = None, target: Optional[Any] = None, up: Optional[Any] = None, cam_type: Union[Camera, str] = Camera.Pinhole, work_distribution: Union[WorkDistribution, str] = WorkDistribution.Uniform, aperture_radius: float = -1, aperture_fract: float = 0.15, focal_scale: float = -1, chroma_l: float = 0.05, chroma_t: float = 0.01, fov: float = -1, camera_matrix: Optional[Any] = None, sensor_height: float = -1, blur: float = 1, glock: bool = False, textures: Optional[Any] = None, make_current: bool = True) None [source]
Setup new or update existing camera.
Note, parameters possible to update with this method are:
eye
,target
,up
,aperture_radius
,focal_scale
, andfov
.- 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. Ignored in camera modes with ray origins stored in a texture.
target (array_like, optional) – Target 3D position. Center of all geometries if argument not provided. Ignored in camera modes with ray targets or directions stored in a texture.
up (array_like, optional) – Up (vertical) direction. Y axis if argument not provided. Ignored in camera modes with ray origins stored in a texture.
cam_type (Camera enum or string, optional) – Type (pinhole, depth of field, …), see
plotoptix.enums.Camera
. Cannot be changed after construction.work_distribution – How rays per pixel are distributed. Default value is
plotoptix.enums.WorkDistribution.Uniform
, shooting constant number of rays per pixel (though no. of rays may differ vor various materials of the primary hit). Seeplotoptix.enums.WorkDistribution
for dynamic distribution of rays based on the estimated per pixel noise.aperture_radius (float, optional) – Aperture radius (increases focus blur for depth of field cameras). Default -1 is internally reset to 0.1.
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) – Focusing distance, relative to
eye - target
length. Default -1 is internally reset to 1.0, that is focus is set at the target point.chroma_l (float, optional) – Longitudinal chromatic aberration strength, relative variation of the focusing distance for different wavelengths. Use be a small positive value << 1.0. Default is
0.05
, use0.0
for no aberration.chroma_t (float, optional) – Transverse chromatic aberration strength, relative variation of the lens magnification for different wavelengths. Use be a small positive value << 1.0. Default is
0.01
, use0.0
for no aberration.fov (float, optional) – Field of view in degrees. Default -1 is internally reset to 35.0 (corresponding to a ~70mm lens in a typical 35mm frame camera).
camera_matrix (array_like, optional) – Camera intrinsic matrix in OpenCV convention: [[fx, 0, cx], [0, fy, cy], [0, 0, 1]]. Only fs, fy, cx, cy values are used, unit is [mm]; values at positions of constant 0`s and `1 are ignored. Note: camera matrix parameters override fov and require sensor_height argument.
sensor_height (float, optional) – Height of the sensor, [mm]. Used only if camera_matrix is provided. Default -1 is internally reset to 24.0 (35mm camera film size).
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.
glock (bool, optional) – Gimbal lock state of the new camera.
textures (array_like, optional) – List of textures used by the camera ray generation program.
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, camera_matrix: Optional[Any] = None, sensor_height: float = -1) 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.
camera_matrix (array_like, optional) – Camera intrinsic matrix in OpenCV convention: [[fx, 0, cx], [0, fy, cy], [0, 0, 1]]. Only fs, fy, cx, cy values are used, unit is [mm]; values at positions of constant 0`s and `1 are ignored. Note: camera matrix parameters override fov and require sensor_height value (if sensor_height is not provided then the previously set value is used).
sensor_height (float, optional) – Height of the sensor, [mm]. Used only if camera_matrix is provided. Value set previously is not updated if default -1 is used.
- 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[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[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_glock(name: Optional[str] = None) Optional[bool] [source]
Get camera gimbal lock state.
- Parameters
name (string, optional) – Name of the camera, use current camera if name not provided.
- Returns
out – Gimbal lock state of the camera or
None
if failed on accessing camera data.- Return type
bool, 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) Tuple[Optional[str], Optional[int]] [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)