The Camera object#

Camera models#

A set of classes that model the projective geometry of cameras.

Inheritance diagram of CentralCamera, FishEyeCamera, CatadioptricCamera, SphericalCamera

CentralCamera

Create central camera projection model

FishEyeCamera

Create fisheye camera projection model

CatadioptricCamera

Create catadioptric camera projection model

SphericalCamera

Create spherical camera projection model

Calibration#

Intrinsic calibration of camera from multiple images#

class CentralCamera(f: float | int | list[float | int] | tuple[float | int, ...] | ndarray = 1, distortion: ndarray | None = None, **kwargs)[source]

Create central camera projection model

Inheritance diagram of machinevisiontoolbox.Camera.CentralCamera
Parameters:
  • f (float, optional) – focal length, defaults to 8mm

  • distortion (array_like(5), optional) – camera distortion parameters, defaults to None

  • kwargs – arguments passed to CameraBase constructor

A camera object contains methods for projecting 3D points and lines to the image plane, as well as supporting a virtual image plane onto which 3D points and lines can be drawn.

References:
Seealso:

CameraBase FishEyeCamera SphericalCamera

Abstract camera base class

Parameters:
  • name (str, optional) – camera instance name, defaults to None

  • camtype (str, optional) – camera projection type, defaults to ‘central’

  • rho (scalar or array_like(2), optional) – pixel size, defaults to 1

  • imagesize (int or array_like(2), optional) – image dimension (width, height) in pixels, defaults to None

  • sensorsize (array_like(2), optional) – image sensor size (width, height), defaults to None

  • pp (array_like(2), optional) – principal point position, defaults to None

  • noise (float, optional) – standard deviation of image plane projection noise, defaults to None

  • pose (SE3, optional) – camera pose, defaults to None

  • limits (array_like(4), optional) – bounds of virtual image plane [umin, umax, vmin, vmax], defaults to None

  • labels (2-tuple of str, optional) – axis labels for virtual image plane, defaults to ('u', 'v')

  • seed (int, optional) – random number seed for projection noise, defaults to None

Raises:
  • TypeError – name must be a string

  • TypeError – camtype must be a string

  • ValueError – rho must be a 1- or 2-element vector

This abstract class is the base for all camera projection model classes. All baseclass constructors support these options.

classmethod images2C(images, gridshape: tuple[int, int] = (7, 6), squaresize: float = 0.025) tuple[ndarray, ndarray, list] | None[source]

Calibrate camera from checkerboard images

Parameters:
  • images (ImageSource) – an iterator that returns Image objects

  • gridshape (tuple, optional) – number of grid squares in each dimension, defaults to (7,6)

  • squaresize (float, optional) – size of the grid squares in units of length, defaults to 0.025

Returns:

camera calibration matrix, distortion parameters, image frames

Return type:

ndarray(3,4), ndarray(5), list of named tuples

The distortion coefficients are in the order \((k_1, k_2, p_1, p_2, k_3)\) where \(k_i\) are radial distortion coefficients and \(p_i\) are tangential distortion coefficients.

Image frames that were successfully processed are returned as a list of named tuples CalibrationFrame with elements:

element

type

description

image

Image

calibration image with overlaid annotation

pose

SE3 instance

pose of the camera with respect to the origin of this image

id

int

sequence number of this image in images

Note

The units used for squaresize must match the units used for defining 3D points in space.

References:
Seealso:

C points2C decomposeC SE3