geometry
geometry
#
The projective geometry the reconstruction stages share, in OpenCV's frame.
- Cameras. A
Camerasbundle holds a set of poses as OpenCV world-to-camera extrinsics (xright,ydown,zforward) and 3×3 calibrations, stacked so a whole model projects in one call.Cameras.ofconverts from the OpenGL camera-to-worldPose;pose_from_extrinsicsconverts back. Keypoint pixels are OpenCV's, integer at the pixel centre, so aPose's principal point (continuous, ascameras.raysreads it) shifts by half a pixel in the calibration. - Triangulation.
triangulatedis the N-view DLT on calibrated rays;rejectionnames why a point fails the geometric checks — too small a triangulation angle, behind a camera, or a reprojection too far off. - Two-view and one-view solves.
relative_poseinitialises a pair from the essential matrix;absolute_poseregisters a view against known points with PnP RANSAC.
FLIP = np.diag([1.0, -1.0, -1.0])
module-attribute
#
OpenGL camera axes to OpenCV's: y up becomes down, -z forward becomes z.
Cameras
dataclass
#
A set of cameras as stacked OpenCV extrinsics and calibrations.
Attributes:
| Name | Type | Description |
|---|---|---|
rotations |
ndarray
|
C×3×3 world-to-camera rotations. |
translations |
ndarray
|
C×3 world-to-camera translations. |
calibrations |
ndarray
|
C×3×3 pinhole matrices in keypoint pixels. |
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
__len__()
#
centres()
#
in_camera(camera, points)
#
World points (M×3) in the frame of the camera at each row of camera (M).
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
of(poses)
classmethod
#
The cameras of poses.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a pose carries no intrinsics. |
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
project(camera, points)
#
The M×2 pixels of world points (M×3) seen by the camera at each row of camera.
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
subset(indices)
#
The cameras at indices, in that order.
absolute_pose(points, pixels, calibration)
#
The world-to-camera pose seeing world points (N×3) at pixels (N×2), by PnP RANSAC.
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
pose explains enough of the correspondences. |
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
calibration(pose)
#
The 3×3 pinhole matrix of pose in keypoint pixels.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
calibration_of(focal, width, height)
#
A 3×3 pinhole matrix in keypoint pixels with focal and the centre of the image.
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
extrinsics(pose)
#
The OpenCV world-to-camera (rotation, translation) of pose.
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
pose_from_extrinsics(rotation, translation, like, calibration=None)
#
A Pose at the OpenCV world-to-camera (rotation, translation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotation
|
ndarray
|
The 3×3 world-to-camera rotation. |
required |
translation
|
ndarray
|
The world-to-camera translation. |
required |
like
|
Pose
|
The pose whose intrinsics, tracking state and time carry over. |
required |
calibration
|
ndarray | None
|
A 3×3 matrix in keypoint pixels replacing |
None
|
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
rejection(cameras, views, pixels, point, min_angle_degrees, max_error_px)
#
Why point fails as the triangulation of pixels in views, or None.
Returns:
| Type | Description |
|---|---|
str | None
|
|
str | None
|
(a point the DLT could not place at all counts as this: parallel |
str | None
|
rays are what leave it unplaced), |
str | None
|
|
str | None
|
|
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
relative_pose(pixels_a, pixels_b, calibration_a, calibration_b)
#
The pose of view b relative to a at unit baseline, from the essential matrix.
Returns:
| Type | Description |
|---|---|
ndarray
|
|
ndarray
|
|
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
rotated(vectors, points)
#
points (M×3) each turned by the Rodrigues vector on the same row of vectors.
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
rotation_matrices(vectors)
#
The C×3×3 rotation matrices of C×3 Rodrigues vectors.
rotation_vectors(rotations)
#
The C×3 Rodrigues vectors of C×3×3 rotation matrices.
triangulated(cameras, views, pixels)
#
The world point the DLT places on the rays of pixels (V×2) seen by views (V).
Source code in capturegraph-recipes/capturegraph_recipes/sfm/camera/geometry.py
triangulation_angle_degrees(point, centres)
#
The widest angle at point between rays from any two of centres.
A point lying on a camera centre subtends no angle at all.