Camera#
- class deltacamera.Camera(optical_center=None, rot_world_to_cam=None, intrinsic_matrix=None, distortion_coeffs=None, world_up=(0, 0, 1), extrinsic_matrix=None, trans_after_rot=None, image_shape=None, image_size=None, distortion_model=None)[source]#
Pinhole camera with extrinsic and intrinsic calibration with optional distortions.
- The camera coordinate system has the following axes:
x points to the right y points down z points forwards
- The world z direction is assumed to point up by default, but world_up can also be
specified differently.
- Parameters:
optical_center – position of the camera in world coordinates (eye point)
rot_world_to_cam – 3x3 rotation matrix for transforming column vectors from being expressed in world reference frame to being expressed in camera reference frame as follows: column_point_cam = rot_matrix_world_to_cam @ (column_point_world - optical_center)
intrinsic_matrix – 3x3 matrix that maps 3D points in camera space to homogeneous coordinates in image (pixel) space. Its last row must be (0,0,1).
distortion_coeffs – parameters describing radial and tangential lens distortions, following OpenCV’s model and order: k1, k2, p1, p2, k3 or None, if the camera has no distortion.
world_up – a world vector that is designated as “pointing up”.
extrinsic_matrix – 4x4 extrinsic transformation matrix as an alternative to providing optical_center and rot_world_to_cam.
trans_after_rot – translation vector to apply after the rotation (alternative to optical_center, which is a negative translation before the rotation)
distortion_model (Optional[LensDistortionModel])
Properties#
The lens distortion model, or None if undistorted. |
|
Get the raw distortion coefficients (deprecated). |
|
Image shape as (height, width) tuple, or None if not set. |
|
The optical center (position) of the camera. |
Instance Methods#
|
Transform points from 3D camera coordinate space to image space. |
|
Transform points from world coordinate space to camera coordinate space. |
|
Transform points from camera coordinate space to world coordinate space. |
|
Transform points from world coordinate space to image space. |
|
Transform points from image space to camera space. |
|
Transform points from image space to world space. |
|
Check if points in world coordinates are visible in the image. |
|
Adjust intrinsics so that the projected image is shifted by offset. |
|
Shift the principal point to move a specific point to a desired location in the image. |
Roll the camera upright by turning along the optical axis to align the vertical image |
|
|
Rotate the camera around a vertical or horizontal axis passing through world point by |
|
Rotate this camera by yaw, pitch, roll Euler angles in radians, |
|
Transform the camera such that the produces image will be rotated around its center |
Check if the camera has fisheye (Kannala-Brandt) distortion. |
|
Check if the camera has non-fisheye (Brown-Conrady) distortion. |
|
|
Zooms the camera (factor > 1 makes objects look larger), |
|
Adjusts the camera such that the images become scaled by factor. It's a scaling with |
|
Undistort the camera by removing lens distortion and optionally adjusting the intrinsic |
Adjusts the intrinsic matrix such that the pixels correspond to squares on the |
|
Flip the camera horizontally by negating the first row of the rotation matrix. |
|
|
Flip the camera horizontally by negating the first row of the rotation matrix, |
|
Adjusts the intrinsic matrix so that the principal point becomes located at the center |
|
Shifts the principal point such that what's currently at desired_center_image_point |
|
Turns the camera so that its optical axis goes through a desired target point. |
Get the 3x4 projection matrix that maps 3D points in camera space to homogeneous |
|
Get the 4x4 extrinsic transformation matrix that maps 3D points in world space to |
|
Get the 4x4 extrinsic transformation matrix that maps 3D points in camera space to |
|
|
Get the field of view of the camera in degrees. |
|
Get the distortion coefficients of the camera, padded or truncated as needed. |
Check if the camera has nonzero lens distortion. |
|
|
Check if all parameters of this camera are close to corresponding parameters |
|
Check if all parameters are exactly equal to another camera. |
|
Hash based on all camera parameters for use as dict key. |
|
Compare cameras for equality based on all parameters. |
|
Wrap arrays as DeprecatingArray after unpickling and handle legacy pickles. |
|
Create a copy of this camera, optionally with modified parameters. |
|
Return a new camera with focal length scaled by factor. |
|
Return a new camera rotated by yaw, pitch, roll Euler angles in radians. |
|
Return a new camera with optical axis pointing at a target point. |
|
Return a new camera orbited around a world point. |
Return a new camera rolled upright to align with world up vector. |
|
|
Return a new camera with horizontal flip (negated first row of rotation). |
|
Return a new camera with principal point shifted by offset. |
|
Return a new camera with principal point adjusted to move a point. |
|
Return a new camera with principal point adjusted so that |
|
Return a camera adjusted for a cropped image. |
|
Return a camera adjusted for a padded image. |
|
Return a camera adjusted for a resized image. |
|
Return a camera adjusted for a uniformly scaled image. |
Return a camera adjusted for a horizontally flipped image. |
|
|
Return a camera adjusted for a rotated image. |
|
Return a camera adjusted for a 90-degree rotated image. |
|
Return a new camera with distortion removed. |
Return a new camera with principal point at image center. |