camera_utils.py
cpas_toolbox.camera_utils ¶
This module provides a pinhole camera class.
Camera ¶
Pinhole camera parameters.
This class allows conversion between different pixel conventions, i.e., pixel center at (0.5, 0.5) (as common in computer graphics), and (0, 0) as common in computer vision.
Source code in cpas_toolbox/camera_utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
__init__ ¶
__init__(
width: int,
height: int,
fx: float,
fy: float,
cx: float,
cy: float,
s: float = 0.0,
pixel_center: float = 0.0,
) -> None
Initialize camera parameters.
Note that the principal point is only fully defined in combination with pixel_center.
The pixel_center defines the relation between continuous image plane coordinates and discrete pixel coordinates.
A discrete image coordinate (x, y) will correspond to the continuous image coordinate (x + pixel_center, y + pixel_center). Normally pixel_center will be either 0 or 0.5. During calibration it depends on the convention the point features used to compute the calibration matrix.
Note that if pixel_center == 0, the corresponding continuous coordinate interval for a pixel are [x-0.5, x+0.5). I.e., proper rounding has to be done to convert from continuous coordinate to the corresponding discrete coordinate.
For pixel_center == 0.5, the corresponding continuous coordinate interval for a pixel are [x, x+1). I.e., floor is sufficient to convert from continuous coordinate to the corresponding discrete coordinate.
PARAMETER | DESCRIPTION |
---|---|
width |
Number of pixels in horizontal direction.
TYPE:
|
height |
Number of pixels in vertical direction.
TYPE:
|
fx |
Horizontal focal length.
TYPE:
|
fy |
Vertical focal length.
TYPE:
|
cx |
Principal point x-coordinate.
TYPE:
|
cy |
Principal point y-coordinate.
TYPE:
|
s |
Skew.
TYPE:
|
pixel_center |
The center offset for the provided principal point.
TYPE:
|
Source code in cpas_toolbox/camera_utils.py
get_o3d_pinhole_camera_parameters ¶
Convert camera to Open3D pinhole camera parameters.
Open3D camera is at (0,0,0) looking along positive z axis (i.e., positive z values are in front of camera). Open3D expects camera with pixel_center = 0 and does not support skew.
RETURNS | DESCRIPTION |
---|---|
PinholeCameraParameters()
|
The pinhole camera parameters. |
Source code in cpas_toolbox/camera_utils.py
get_pinhole_camera_parameters ¶
Convert camera to general camera parameters.
PARAMETER | DESCRIPTION |
---|---|
pixel_center |
At which ratio of a square the pixel center should be for the resulting parameters. Typically 0 or 0.5. See class documentation for more info.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple
|
|
Tuple
|
|
Tuple
|
|