Skip to content

nextcv.sensors.camera ⚓︎

Sensor representation and manipulation utilities.

CLASS DESCRIPTION
Camera

Represents a camera with its intrinsics, pose, and image resolution.

PinholeCamera

Represents a pinhole camera with its intrinsics and pose.

nextcv.sensors.camera.Camera ⚓︎

Bases: BaseModel

Represents a camera with its intrinsics, pose, and image resolution.

PARAMETER DESCRIPTION
width

Image width in pixels

TYPE: int DEFAULT: None

height

Image height in pixels

TYPE: int DEFAULT: None

fx

Focal length along x-axis in pixels

TYPE: float DEFAULT: None

fy

Focal length along y-axis in pixels

TYPE: float DEFAULT: None

cx

Principal point x-coordinate in pixels

TYPE: float DEFAULT: None

cy

Principal point y-coordinate in pixels

TYPE: float DEFAULT: None

roll

Camera roll angle in degrees (rotation around z-axis)

TYPE: float DEFAULT: None

pitch

Camera pitch angle in degrees (rotation around x-axis)

TYPE: float DEFAULT: None

yaw

Camera yaw angle in degrees (rotation around y-axis)

TYPE: float DEFAULT: None

METHOD DESCRIPTION
compute_homography_to

Compute homography matrix that maps points from this cam to target cam.

from_dict

Create a Camera instance from intrinsics and pose dictionaries.

maps_from

Create remapping maps from source camera to this camera.

must_be_even

Ensure width and height are positive integers.

ATTRIBUTE DESCRIPTION
size

Get the camera size as an opencv-compatible tuple of width and height.

TYPE: Tuple[int, int]

size property ⚓︎

size: Tuple[int, int]

Get the camera size as an opencv-compatible tuple of width and height.

compute_homography_to ⚓︎

compute_homography_to(target: Camera, neg_focal_length: bool = True) -> ndarray

Compute homography matrix that maps points from this cam to target cam.

from_dict classmethod ⚓︎

from_dict(data: Dict[str, Any]) -> T

Create a Camera instance from intrinsics and pose dictionaries.

PARAMETER DESCRIPTION
data

Dictionary with keys "fx", "fy", "cx", "cy", "width", "height", "roll", "pitch", "yaw"

TYPE: Dict[str, Any]

RETURNS DESCRIPTION
T

Camera instance of the correct subclass type

maps_from ⚓︎

maps_from(src: Camera, neg_focal_length: bool = True) -> Tuple[ndarray, ndarray]

Create remapping maps from source camera to this camera.

must_be_even ⚓︎

must_be_even(v: int) -> int

Ensure width and height are positive integers.

nextcv.sensors.camera.PinholeCamera ⚓︎

Bases: Camera

Represents a pinhole camera with its intrinsics and pose.

PARAMETER DESCRIPTION
width

Image width in pixels

TYPE: int DEFAULT: None

height

Image height in pixels

TYPE: int DEFAULT: None

fx

Focal length along x-axis in pixels

TYPE: float DEFAULT: None

fy

Focal length along y-axis in pixels

TYPE: float DEFAULT: None

cx

Principal point x-coordinate in pixels

TYPE: float DEFAULT: None

cy

Principal point y-coordinate in pixels

TYPE: float DEFAULT: None

roll

Camera roll angle in degrees (rotation around z-axis)

TYPE: float DEFAULT: None

pitch

Camera pitch angle in degrees (rotation around x-axis)

TYPE: float DEFAULT: None

yaw

Camera yaw angle in degrees (rotation around y-axis)

TYPE: float DEFAULT: None

METHOD DESCRIPTION
compute_homography_to

Compute homography matrix that maps points from this camera to target camera.

crop

Return a new PinholeCamera cropped by margins (left, top, right, bottom).

hconcat

Create a virtual camera by concatenating left and right cams horizontally.

maps_from

Create remapping maps from source camera to this camera.

vconcat

Create a virtual camera by concatenating top and bottom cams vertically.

ATTRIBUTE DESCRIPTION
K

Get the camera intrinsics matrix.

TYPE: ndarray

R

Get the camera rotation matrix from Euler angles with pinhole convention.

TYPE: ndarray

K property ⚓︎

Get the camera intrinsics matrix.

R property ⚓︎

Get the camera rotation matrix from Euler angles with pinhole convention.

The pinhole convention is: - x is right - y is down - z is forward

compute_homography_to ⚓︎

compute_homography_to(target: PinholeCamera, neg_focal_length: bool = True) -> ndarray

Compute homography matrix that maps points from this camera to target camera.

PARAMETER DESCRIPTION
target

Target camera to compute homography to

TYPE: PinholeCamera

neg_focal_length

Whether to negate the focal length

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
ndarray

Homography matrix that transforms points from this camera to target camera

crop ⚓︎

crop(left: float, top: float, right: float, bottom: float, force_even: bool = True) -> PinholeCamera

Return a new PinholeCamera cropped by margins (left, top, right, bottom).

hconcat classmethod ⚓︎

hconcat(left: PinholeCamera, right: PinholeCamera) -> PinholeCamera

Create a virtual camera by concatenating left and right cams horizontally.

maps_from ⚓︎

maps_from(src: PinholeCamera, neg_focal_length: bool = True) -> Tuple[ndarray, ndarray]

Create remapping maps from source camera to this camera.

vconcat classmethod ⚓︎

vconcat(top: PinholeCamera, bottom: PinholeCamera) -> PinholeCamera

Create a virtual camera by concatenating top and bottom cams vertically.