camera
¶
Top-level entry-point for the pupil_labs.camera package
Modules:
-
radial– -
utils–
Classes:
-
Camera–A camera model with radial distortion.
Functions:
-
get_perspective_transform–Computes a perspective transformation matrix from four point correspondences.
-
perspective_transform–Applies a perspective transformation to 2D points.
Camera
¶
Camera(pixel_width: int, pixel_height: int, camera_matrix: CameraMatrixLike, distortion_coefficients: DistortionCoefficientsLike | None = None, use_optimal_camera_matrix: bool = False)
A camera model with radial distortion.
Methods:
-
distort_image–Distorts the provided image.
-
distort_points–Distorts 2D image points using the camera's intrinsics.
-
project_points–Projects 3D points onto the 2D image plane using the camera's intrinsics.
-
undistort_image–Undistorts the provided image.
-
undistort_points–Undistorts 2D image points using the camera's intrinsics.
-
unproject_points–Unprojects 2D image points to 3D space using the camera's intrinsics.
Attributes:
-
optimal_camera_matrix(CameraMatrix) –The "optimal" camera matrix for undistorting images.
Source code in src/pupil_labs/camera/radial.py
16 17 18 19 20 21 22 23 24 25 26 27 28 | |
optimal_camera_matrix
cached
property
¶
optimal_camera_matrix: CameraMatrix
The "optimal" camera matrix for undistorting images.
This method uses OpenCV's getOptimalNewCameraMatrix to calculate a new camera
matrix that maximizes the retirval of sensible pixels in the undistortion
process, while avoiding "virtual" black pixels stemming from outside the
captured distorted image.
distort_image
¶
distort_image(image: Image, use_optimal_camera_matrix: bool | None = None) -> Image
Distorts the provided image.
This implementation uses cv2.remap with a precomputed map, instead of cv2.undistort. This is significantly faster when undistorting multiple images because the undistortion maps are computed only once.
Parameters:
-
image(Image) –Image array
-
use_optimal_camera_matrix(bool | None, default:None) –If True applies optimal camera matrix
Source code in src/pupil_labs/camera/radial.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
distort_points
¶
distort_points(points_2d: Points2DLike, use_optimal_camera_matrix: bool | None = None) -> Points2D
Distorts 2D image points using the camera's intrinsics.
Parameters:
-
points_2d(Points2DLike) –Array-like of 2D point(s) to be distorted.
-
use_optimal_camera_matrix(bool | None, default:None) –If True applies optimal camera matrix
Source code in src/pupil_labs/camera/radial.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
project_points
¶
project_points(points_3d: Points3DLike, use_distortion: bool = True, use_optimal_camera_matrix: bool | None = None) -> Points2D
Projects 3D points onto the 2D image plane using the camera's intrinsics.
Parameters:
-
points_3d(Points3DLike) –Array of 3D point(s) to be projected.
-
use_distortion(bool, default:True) –If True, applies distortion using the camera's distortion coefficients. If False, ignores distortion.
-
use_optimal_camera_matrix(bool | None, default:None) –If True applies optimal camera matrix
Source code in src/pupil_labs/camera/radial.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
undistort_image
¶
undistort_image(image: Image, use_optimal_camera_matrix: bool | None = None) -> Image
Undistorts the provided image.
This implementation uses cv2.remap with a precomputed map, instead of cv2.undistort. This is significantly faster when undistorting multiple images because the undistortion maps are computed only once.
Parameters:
-
image(Image) –Image array
-
use_optimal_camera_matrix(bool | None, default:None) –If True applies optimal camera matrix
Source code in src/pupil_labs/camera/radial.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
undistort_points
¶
undistort_points(points_2d: Points2DLike, use_optimal_camera_matrix: bool | None = None) -> Points2D
Undistorts 2D image points using the camera's intrinsics.
Parameters:
-
points_2d(Points2DLike) –Array-like of 2D point(s) to be undistorted.
-
use_optimal_camera_matrix(bool | None, default:None) –If True applies optimal camera matrix
Source code in src/pupil_labs/camera/radial.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
unproject_points
¶
unproject_points(points_2d: Points2DLike, use_distortion: bool = True, use_optimal_camera_matrix: bool | None = None) -> Points3D
Unprojects 2D image points to 3D space using the camera's intrinsics.
Parameters:
-
points_2d(Points2DLike) –Array-like of 2D point(s) to be unprojected.
-
use_distortion(bool, default:True) –If True, applies distortion correction using the camera's distortion coefficients. If False, ignores distortion correction.
-
use_optimal_camera_matrix(bool | None, default:None) –If True applies optimal camera matrix
Source code in src/pupil_labs/camera/radial.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
get_perspective_transform
¶
get_perspective_transform(points1: Points2DLike, points2: Points2DLike) -> NDArray[float64]
Computes a perspective transformation matrix from four point correspondences.
Parameters:
-
points1(Points2DLike) –Array-like of 4 source 2D points.
-
points2(Points2DLike) –Array-like of 4 destination 2D points.
Returns:
-
NDArray[float64]–3x3 perspective transformation matrix.
Source code in src/pupil_labs/camera/utils.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
perspective_transform
¶
perspective_transform(points: Points2DLike, transform: NDArray[floating]) -> Points2D
Applies a perspective transformation to 2D points.
Parameters:
-
points(Points2DLike) –Array-like of 2D point(s) to be transformed.
-
transform(NDArray[floating]) –3x3 perspective transformation matrix.
Returns:
-
Points2D–Transformed 2D points with the same shape as input.
Source code in src/pupil_labs/camera/utils.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |