paralleldomain.utilities.projection¶
- class DistortionLookupTable¶
Container object for distortion lookup tables used in distortion model pd_fisheye. Can be accessed like any np.ndarray
- classmethod from_ndarray(data)¶
Takes a np.ndarray and creates a
DistortionLookupTable
instance from it.- Parameters
data (numpy.ndarray) – np.ndarray of shape (N x 2). Array will be sorted by first column. Last two rows will be used to extrapolate for maximum valid angle value of Pi.
- Returns
Distortion lookup table to be used with projection functions using distortion model pd_fisheye.
- Return type
- project_points_3d_to_2d(k_matrix, camera_model, points_3d, distortion_parameters=None, distortion_lookup=None)¶
Projects an array of 3D points in Cartesian coordinates onto an image plane.
- Parameters
k_matrix (numpy.ndarray) – Camera intrinsic matrix. Definition can be found in OpenCV documentation.
camera_model (str) – One of opencv_pinhole, opencv_fisheye, pd_fisheye. More details in
CameraModel
.points_3d (numpy.ndarray) – A matrix with dimensions (nx3) containing the points. Points must be already in the camera’s coordinate system.
distortion_parameters (Optional[numpy.ndarray]) – Array of applicable distortion parameters for distortion models opencv_pinhole and opencv_fisheye.
distortion_lookup (Optional[paralleldomain.utilities.projection.DistortionLookupTable]) – Table of undistorted and distorted angles. Required for pd_fisheye model.
- Returns
A matrix with dimensions (nx2) containing the point projections.
dtype
isfloat
and values need to be rounded to integers by the user to receive actual pixel coordinates. Includes all points, independent if they are on the image plane or outside. Points behind the image plane will be projected, too. If values are not valid (e.g., for undistorted pinhole cameras), filtering needs to be applied by the calling function.- Return type
ndarray
- project_points_2d_to_3d(k_matrix, camera_model, points_2d, depth, distortion_parameters=None, distortion_lookup=None, interpolate=True)¶
Maps image plane coordinates to 3D points in Cartesian coordinates.
- Parameters
k_matrix (numpy.ndarray) –
Camera intrinsic matrix. Definition can be found in OpenCV documentation.
camera_model (str) – One of opencv_pinhole, opencv_fisheye, pd_fisheye. More details in
CameraModel
.points_2d (numpy.ndarray) – A matrix with dimensions (nx2) containing the points. Points must be in image coordinate system (x,y).
depth (numpy.ndarray) – Depth mask with the same dimensions as the image canvas.
distortion_parameters (Optional[numpy.ndarray]) – Array of applicable distortion parameters for distortion models opencv_pinhole and opencv_fisheye.
distortion_lookup (Optional[paralleldomain.utilities.projection.DistortionLookupTable]) – Table of undistorted and distorted angles. Required for pd_fisheye model.
interpolate (bool) – When points are not exactly on an image pixel, apply bi-linear interpolation to estimate the corresponding depth value. Default: True.
- Returns
A matrix with dimensions (nx3) containing the point projections in 3D using the provided depth mask.
- Return type
ndarray
- points_2d_inside_image(width, height, camera_model, points_2d, points_3d=None)¶
Returns the indices for an array of 2D image points that are inside the image canvas.
- Parameters
width (int) – Pixel width of the image canvas.
height (int) – Pixel height of the image canvas.
camera_model (str) – One of opencv_pinhole, opencv_fisheye, pd_fisheye. More details in
CameraModel
.points_2d (numpy.ndarray) – A matrix with dimensions (nx2) containing the points that should be tested if inside the image canvas. Points must be in image coordinate system (x,y).
points_3d (Optional[numpy.ndarray]) – Optional array of size (nx3) which provides the 3D camera coordinates for each point. Required for camera models opencv_pinhole and opencv_fisheye.
- Returns
An array with dimensions (n,).
- Return type
ndarray