astrix.project module

class CameraLike[source]

Bases: ABC

A marker interface for camera-like objects.

abstractmethod convert_to(backend)[source]

Convert the camera to a different backend.

Return type:

CameraLike

Parameters:

backend (str | Any | None)

abstractmethod fov(zoom)[source]

Field of view in degrees (horizontal, vertical).

Return type:

tuple[float, float]

Parameters:

zoom (float | None)

has_zoom()[source]

Whether the camera has a zoom level associated with it.

Return type:

bool

interp_zoom(time)[source]

Interpolate the zoom level at the given time. Returns None if the camera has no zoom level.

Return type:

Any

Parameters:

time (TimeLike)

abstractmethod mat(time)[source]

Camera intrinsic matrix.

Return type:

Any

Parameters:

time (TimeLike)

abstractmethod rad_coef(time)[source]

Radial distortion coefficients.

Return type:

Any

Parameters:

time (TimeLike)

abstract property has_dist: bool

Whether the camera has distortion coefficients.

property res: tuple[int, int]

Image resolution (width, height) in pixels.

property sensor_size

Physical sensor size (width, height) in mm.

class FixedZoomCamera(res, sensor_size, focal_length, rad_coef=None, backend=None)[source]

Bases: CameraLike

A simple pinhole camera model with fixed zoom.

Notes

The camera intrinsic matrix is given by:

[ fx 0 cx ] [ 0 fy cy ] [ 0 0 1 ]

where:

fx = focal_length * res[0] / sensor_size[0] fy = focal_length * res[1] / sensor_size[1] cx = res[0] / 2 cy = res[1] / 2

The field of view is given by:

fov_x = 2 * arctan(sensor_size[0] / (2 * focal_length)) fov_y = 2 * arctan(sensor_size[1] / (2 * focal_length))

Parameters:
  • res (tuple[int, int])

  • sensor_size (tuple[float, float])

  • focal_length (float)

  • rad_coef (Array | None)

  • backend (BackendArg)

classmethod from_hoz_fov(res, hoz_fov, sensor_size, rad_coef=None, backend=None)[source]

Create a FixedZoomCamera from horizontal field of view.

Parameters:
  • res (tuple[int, int]) – Image resolution (width, height) in pixels.

  • hoz_fov (float) – Horizontal field of view in degrees.

  • sensor_size (tuple[float, float]) – Physical sensor size (width, height) in mm.

  • rad_coef (optional) – Radial distortion coefficients.

  • backend (optional) – Backend to use. Either “numpy” or “jax”.

Return type:

FixedZoomCamera

convert_to(backend)[source]

Convert the camera to a different backend.

Return type:

FixedZoomCamera

Parameters:

backend (str | Any | None)

fov(zoom=None)[source]

Field of view in degrees (horizontal, vertical).

Return type:

tuple[float, float]

Parameters:

zoom (float | None)

mat(time=TimeInvariant object)[source]

Camera intrinsic matrix. No zoom parameter needed as this is a fixed zoom camera.

Return type:

Any

Parameters:

time (TimeLike)

rad_coef(time=TimeInvariant object)[source]

Radial distortion coefficients.

Return type:

Any

Parameters:

time (TimeLike)

property backend: str

Backend used by the camera.

property has_dist

Whether the camera has distortion coefficients.

class Pixel(uv, time=TimeInvariant object, backend=None)[source]

Bases: object

A pixel in an image.

Notes

The pixel coordinates are given in the image coordinate system, where the origin is at the top-left corner of the image, and the u-axis points to the right and the v-axis points down.

Parameters:
  • uv (Array)

  • time (TimeLike)

  • backend (BackendArg)

property backend: str

Backend used by the pixel.

property has_time: bool

Whether the pixel has a time associated with it.

property time: TimeLike
property uv: Any

Pixel coordinates (u, v) in pixels.