blenderproc.python.modules.camera.CameraInterface module¶
-
class
blenderproc.python.modules.camera.CameraInterface.
CameraInterface
(config)[source]¶ Bases:
blenderproc.python.modules.main.Module.Module
A super class for camera related modules. Holding key information like camera intrinsics and extrinsics, in addition to setting stereo parameters.
Example 1: Setting a custom source frame while specifying the format of the rotation. Note that to set config parameters here, it has to be in a child class of CameraInterface.
{ "module": "camera.CameraLoader", "config": { "path": "<args:0>", "file_format": "location rotation/value _ _ _ _ _ _", "world_frame_change": ["X", "-Z", "Y"], "default_cam_param": { "rotation": { "format": "forward_vec" } } } }
Configuration:
Parameter Description Type world_frame_change Can be used if the given camera poses are specified in frames different from the blender frame. This parameter changes the world coordinate frame of points and matrices. Has to be a list of three strings. Example: [‘X’, ‘-Z’, ‘Y’]: Point (1,2,3) will be transformed to (1, -3, 2). Default: [“X”, “Y”, “Z”]. ” Available: [‘X’, ‘Y’, ‘Z’, ‘-X’, ‘-Y’, ‘-Z’]. list local_frame_change Can be used if the given camera poses are specified in frames different from the blender frame. This parameter changes the local coordinate frame of matrices. It is currently only available when setting camera poses via the cam2world_matrix parameter. Has to be a list of three strings. Default: [“X”, “Y”, “Z”]. ” Available: [‘X’, ‘Y’, ‘Z’, ‘-X’, ‘-Y’, ‘-Z’]. list cam_poses A list of dicts, where each dict specifies one cam pose. See the next table for details about specific properties. list default_cam_param Properties across all cam poses. dict intrinsics A dictionary containing camera intrinsic parameters. See the last table for details. Default: {}. dict Properties per cam pose:
Parameter Description Type location The position of the camera, specified as a list of three values (xyz). mathutils.Vector rotation/value Specifies the rotation of the camera. Per default rotations are specified as three euler angles. mathutils.Vector rotation/format Describes the form in which the rotation is specified. Available: ‘euler’ (three Euler angles), ‘forward_vec’(specified with a forward vector: the Y-Axis is assumed as Up-Vector), ‘look_at’ (camera will be turned such as it looks at ‘value’ location, which can be defined as a fixed or sampled XYZ location). string rotation/inplane_rot A rotation angle in radians around the Z axis. Default: 0.0 float cam2world_matrix 4x4 camera extrinsic matrix. Default: []. list of floats frame The frame to set the camera pose to. int Intrinsic camera parameters:
Parameter Description Type cam_K Camera Matrix K. Cx, cy are defined in a coordinate system with (0,0) being the CENTER of the top-left pixel - this is the convention e.g. used in OpenCV. list shift Principal Point deviation from center. The unit is proportion of the larger image dimension. float fov The FOV (normally the angle between both sides of the frustum, if fov_is_half is True than its assumed to be the angle between forward vector and one side of the frustum). float resolution_x Width resolution of the camera. int resolution_y Height resolution of the camera. int pixel_aspect_x Pixel aspect ratio x. float pixel_aspect_y Pixel aspect ratio y. float clip_start Near clipping. float clip_end Far clipping. float stereo_convergence_mode How the two cameras converge (e.g. Off-Axis where both cameras are shifted inwards to converge in the convergence plane, or parallel where they do not converge and are parallel). string. convergence_distance The convergence point for the stereo cameras (i.e. distance from the projector to the projection screen). float interocular_distance Distance between the camera pair. float lens_distortion/k1 k1 is the first radial distortion parameter (of 3rd degree in radial distance) as defined by the undistorted-to-distorted Brown-Conrady lens distortion model, which is conform to the current DLR CalLab/OpenCV/Bouguet/Kalibr implementations. Note that undistorted-to-distorted means that the distortion parameters are multiplied by undistorted, normalized camera projections to yield distorted projections, that are in turn digitized by the intrinsic camera matrix. float lens_distortion/k2 k2 is the second radial distortion parameter (of 5th degree in radial distance) as defined by the undistorted-to-distorted Brown-Conrady lens distortion model, which is conform to the current DLR CalLab/OpenCV/Bouguet/Kalibr implementations. float lens_distortion/k3 k3 is the third radial distortion parameter (of 7th degree in radial distance) as defined by the undistorted-to-distorted Brown-Conrady lens distortion model, which is conform to the current DLR CalLab/OpenCV/Bouguet/Kalibr implementations. The use of this parameter is discouraged unless the angular field of view is too high, rendering it necessary, and the parameter allows for a distorted projection in the whole sensor size (which isn’t always given by features-driven camera calibration). float lens_distortion/p1 p1 is the first decentering distortion parameter as defined by the undistorted-to-distorted Brown-Conrady lens distortion model in (Brown, 1965; Brown, 1971; Weng et al., 1992) and is comform to the current DLR CalLab implementation. Note that OpenCV/Bouguet/Kalibr permute them. This parameter shares one degree of freedom (j1) with p2; as a consequence, either both parameters are given or none. The use of these parameters is discouraged since either current cameras do not need them or their potential accuracy gain is negligible w.r.t. image processing. float lens_distortion/p2 p2 is the second decentering distortion parameter as defined by the undistorted-to-distorted Brown-Conrady lens distortion model in (Brown, 1965; Brown, 1971; Weng et al., 1992) and is comform to the current DLR CalLab implementation. Note that OpenCV/Bouguet/Kalibr permute them. This parameter shares one degree of freedom (j1) with p1; as a consequence, either both parameters are given or none. The use of these parameters is discouraged since either current cameras do not need them or their potential accuracy gain is negligible w.r.t. image processing. float depth_of_field/focal_object This object will be used as focal point, ideally a empty plane_axes is used here, see BasicEmptyInitializer. Using this will automatically activate the depth of field mode. Can not be combined with depth_of_field_dist. Provider depth_of_field/depth_of_field_dist Instead of a focal_object it is possible to use a distance from the camera for the focal plane. More control over the scene can be achieved by using a focal_object. float depth_of_field/fstop The desired amount of blurring, a lower value means more blur and higher value less. Default: 2.4 float depth_of_field/aperture_blades Amount of aperture polygon blades used, to change the shape of the blurred object. Minimum to see an effect is three. Default: 0 int depth_of_field/aperture_ratio Change the amount of distortion to simulate the anamorphic bokeh effect. A setting of 1.0 shows no distortion, where a number below 1.0 will cause a horizontal distortion, and a higher number will cause a vertical distortion. Default: 1.0 float depth_of_field/aperture_rotation_in_rad Rotate the polygonal blades along the facing axis, and will rotate in a clockwise, and counter-clockwise fashion in radiant. Default: 0.0 float -
_cam2world_matrix_from_cam_extrinsics
(config)[source]¶ Determines camera extrinsics by using the given config and returns them in form of a cam to world frame transformation matrix.
Parameters: config ( Config
) – The configuration object.Return type: ndarray
Returns: The 4x4 cam to world transformation matrix.
-
_set_cam_extrinsics
(config, frame=None)[source]¶ Sets camera extrinsics according to the config.
Parameters: - frame – Optional, the frame to set the camera pose to.
- config – A configuration object with cam extrinsics.
-
_set_cam_intrinsics
(cam, config)[source]¶ Sets camera intrinsics from a source with following priority
- from config function parameter if defined
- from custom properties of cam if set in Loader
- default config:
- resolution_x/y: 512 pixel_aspect_x: 1 clip_start: : 0.1 clip_end : 1000 fov : 0.691111
Parameters: - cam – The camera which contains only camera specific attributes.
- config – A configuration object with cam intrinsics.
-