symforce.cam.camera module#

class Camera(calibration, image_size=None)[source]#

Bases: object

Camera with a given camera calibration and an optionally specified image size (width, height).

If the image size is specified, we use it to check whether pixels (either given or computed by projection of 3D points into the image frame) are in the image frame and thus valid/invalid.

Parameters:
CameraT = ~CameraT#
property focal_length: Matrix21#
property principal_point: Matrix21#
property distortion_coeffs: Matrix#
pixel_from_camera_point(point, epsilon=0.0)[source]#

Project a 3D point in the camera frame into 2D pixel coordinates.

Returns:
  • pixel – (x, y) coordinate in pixels if valid

  • is_valid – 1 if the operation is within bounds (including image_size bounds) else 0

Parameters:
Return type:

Tuple[Matrix21, float]

camera_ray_from_pixel(pixel, epsilon=0.0, normalize=False)[source]#

Backproject a 2D pixel coordinate into a 3D ray in the camera frame.

NOTE: If image_size is specified and the given pixel is out of bounds, is_valid will be set to zero.

Parameters:
  • normalize (bool) – Whether camera_ray will be normalized (False by default)

  • pixel (Matrix21) –

  • epsilon (float) –

Returns:
  • camera_ray – The ray in the camera frame

  • is_valid – 1 if the operation is within bounds else 0

Return type:

Tuple[Matrix31, float]

has_camera_ray_from_pixel()[source]#

Returns True if self has implemented the method camera_ray_from_pixel, and False otherwise.

Return type:

bool

maybe_check_in_view(pixel)[source]#
Parameters:

pixel (Matrix21) –

Return type:

int

static in_view(pixel, image_size)[source]#

Returns 1.0 if the pixel coords are in bounds of the image, 0.0 otherwise.

Parameters:
Return type:

int

subs(*args, **kwargs)[source]#

Substitute given values of each scalar element into a new instance.

Parameters:
  • self (CameraT) –

  • args (Any) –

  • kwargs (Any) –

Return type:

CameraT