Ocean
Loading...
Searching...
No Matches
Ocean::Geometry::MultipleViewGeometry Class Reference

This class implements epipolar geometry functions for multiple views. More...

#include <MultipleViewGeometry.h>

Data Structures

class  TrifocalTensor
 Definition of a trifocal tensor matrix. More...
 

Static Public Member Functions

static bool projectiveReconstructionFrom6PointsIF (const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, HomogenousMatrix4 &flippedCamera1_P_world, HomogenousMatrix4 &flippedCamera2_P_world, HomogenousMatrix4 &flippedCamera3_P_world, const Scalar squaredSuccessThreshold=(2.5 *2.5), Scalar *squaredProjectionError=nullptr)
 Computes geometric valid camera projection matrices which are determined up to a common 3d projection transformation.
 
static bool projectiveReconstructionFrom6PointsIF (const ConstIndexedAccessor< Vectors2 > &imagePointsPerPose, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedCameras_T_world, const Scalar squaredSuccessThreshold=Scalar(2.5 *2.5), Scalar *squaredProjectionError=nullptr)
 Computes geometric valid camera projection matrices which are determined up to a common 3d projection transformation.
 
static bool trifocalTensorIF (const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, HomogenousMatrix4 &flippedCamera1_P_world, HomogenousMatrix4 &flippedCamera2_P_world, HomogenousMatrix4 &flippedCamera3_P_world, TrifocalTensor *trifocalTensor=nullptr)
 The normalized linear algorithm of computation of trifocal tensor.
 
static bool calibrateFromProjectionsMatricesIF (const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_P_world, const unsigned int imageWidth, const unsigned int imageHeight, SquareMatrix3 &cameraIntrinsic, HomogenousMatrix4 *flippedCameras_T_world)
 Calibrate multiple projection matrices from a single camera.
 
static bool calibrateFromProjectionsMatricesIF (const HomogenousMatrix4 &flippedCamera1_P_world, const HomogenousMatrix4 &flippedCamera2_P_world, const HomogenousMatrix4 &flippedCamera3_P_world, const unsigned int imageWidth, const unsigned int imageHeight, SquareMatrix3 &cameraIntrinsics, HomogenousMatrix4 &flippedCamera1_T_world, HomogenousMatrix4 &flippedCamera2_T_world, HomogenousMatrix4 &flippedCamera3_T_world)
 Calibrate three projection matrices from a single camera.
 

Static Protected Member Functions

static bool trifocalTensorNormalizedLinear (const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, TrifocalTensor &trifocal)
 The normalized linear algorithm of computation of trifocal tensor.
 
static bool trifocalTensorMinimizingError (const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, TrifocalTensor &trifocal)
 Computing a geometric valid trifocal tensor minimizing algebraic error.
 
static bool trifocalTensorFromProjectionMatrices (const HomogenousMatrix4 &flippedCameraB_P_world, const HomogenousMatrix4 &flippedCameraC_P_world, TrifocalTensor &trifocal)
 Calculates the trifocal tensor by two projection matrix given: P_1 = [I | 0], P_2 = [A | a4], P_3 = [B | b4] and P = C * [Rt].
 
static bool trifocalTensorFromProjectionMatrices (const HomogenousMatrix4 &flippedCameraA_P_world, const HomogenousMatrix4 &flippedCameraB_P_world, const HomogenousMatrix4 &flippedCameraC_P_world, TrifocalTensor &trifocal)
 Calculates the trifocal tensor by three projection matrix given: P_1 = [A | a4], P_2 = [B | b4], P_3 = [C | c4] and P = CameraInstrinsics * [Rt].
 
static bool epipoles (const TrifocalTensor &trifocal, Vector3 &normedEpipole2, Vector3 &normedEpipole3)
 Calculates the normalized epipoles of second and third view from trifocal tensor.
 
static bool epipolesIF (const TrifocalTensor &trifocal, Vector3 &flippedCamera2NormedEpipole, Vector3 &flippedCamera3NormedEpipole)
 Calculates the normalized epipoles of second and third view from trifocal tensor for inverted flipped cameras.
 
static bool fundamentalMatricesIF (const TrifocalTensor &trifocal, const Vector3 &flippedCamera2Epipole, const Vector3 &flippedCamera3Epipole, SquareMatrix3 &fundamental21, SquareMatrix3 &fundamental31)
 Calculates the fundamental matrices of second view and third view from trifocal tensor.
 
static bool cameraProjectionMatricesIF (const TrifocalTensor &trifocal, const Vector3 &flippedCamera2NormedEpipole, const Vector3 &flippedCamera3NormedEpipole, HomogenousMatrix4 &flippedCamera2_P_world, HomogenousMatrix4 &flippedCamera3_P_world)
 Calculates the camera projection matrices of second and third view.
 
template<bool tUseIF>
static bool epipoles (const Scalar *const trifocal1, const Scalar *const trifocal2, const Scalar *const trifocal3, Vector3 &normedEpipole2, Vector3 &normedEpipole3)
 Calculates the normalized epipoles of second and third view from trifocal tensor.
 

Static Private Member Functions

static bool trifocalTensorLinear (const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, Scalar *trifocal3x9, Matrix *matrixA=nullptr)
 Calculates the trifocal tensor using linear system.
 
static bool trifocalTensorNormalizedLinear (const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, Scalar *trifocal3x9, Matrix *matrixA=nullptr)
 The normalized linear algorithm of computation of trifocal tensor.
 
static Scalar errorMatrix (const TrifocalTensor &trifocal, const Vector2 *points1, const Vector2 *points2, const Vector2 *points3, const size_t correspondences, SquareMatrix3 *errorMatrix=nullptr)
 Calculates the trifocal tensor error in point–point–point correspondence equation: [x_2]_x * (sum_i(x_1^i * T_i) * [x_3]_x).
 
static bool calculateProjectiveBasisTransform (const Vector2 &imagePointForTargetPoint100, const Vector2 &imagePointForTargetPoint010, const Vector2 &imagePointForTargetPoint001, const Vector2 &imagePointForTargetPoint111, SquareMatrix3 &baseTransformation)
 Calculates a transformation for a projective basis defined by four individual (image) target points each corresponding to a specific (projective/3D) reference points.
 
static bool pointIsCollinear (const Triangle2 &triangle, const Vector2 &point, const Scalar threshold=Scalar(0.01))
 Checks if a given 2D point is collinear to three given 2D points (defined by a 2D triangle).
 

Detailed Description

This class implements epipolar geometry functions for multiple views.

Member Function Documentation

◆ calculateProjectiveBasisTransform()

static bool Ocean::Geometry::MultipleViewGeometry::calculateProjectiveBasisTransform ( const Vector2 imagePointForTargetPoint100,
const Vector2 imagePointForTargetPoint010,
const Vector2 imagePointForTargetPoint001,
const Vector2 imagePointForTargetPoint111,
SquareMatrix3 baseTransformation 
)
staticprivate

Calculates a transformation for a projective basis defined by four individual (image) target points each corresponding to a specific (projective/3D) reference points.


The following projective reference points are used: e_i = (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 1).
The resulting transformation transforms the provided image points to projective references points:
si * ei = H * pi, each up to a scale factor si.

Parameters
imagePointForTargetPoint100Image point p0 corresponding to s0 * (1, 0, 0)
imagePointForTargetPoint010Image point p1 corresponding to s1 * (0, 1, 0)
imagePointForTargetPoint001Image point p2 corresponding to s2 * (0, 0, 1)
imagePointForTargetPoint111Image point p3 corresponding to s3 * (1, 1, 1)
baseTransformationResulting transformation
Returns
True, if succeeded

◆ calibrateFromProjectionsMatricesIF() [1/2]

static bool Ocean::Geometry::MultipleViewGeometry::calibrateFromProjectionsMatricesIF ( const ConstIndexedAccessor< HomogenousMatrix4 > &  flippedCameras_P_world,
const unsigned int  imageWidth,
const unsigned int  imageHeight,
SquareMatrix3 cameraIntrinsic,
HomogenousMatrix4 flippedCameras_T_world 
)
static

Calibrate multiple projection matrices from a single camera.

The projection matrices are transformed into metric transformation matrix using absolute conic ω and absolute dual quadric Q∞:
ω = P * Q∞ * P^T.
Q∞ = H * Î * H^T.
P_metric = P * H.
The camera intrinsics are determined by Cholesky decomposition of absolute conic ω = K * K^T.

Parameters
flippedCameras_P_worldThe camera projection matrices (at least 3, inverted flipped)
imageWidthWidth of image
imageHeightHeight of image
cameraIntrinsicThe resulting intrinsic camera matrix
flippedCameras_T_worldResulting inverted and flipped camera poses, one for each given camera projection matrix
Returns
True, if succeeded
See also
calibrateFromProjectionsMatricesIF()

◆ calibrateFromProjectionsMatricesIF() [2/2]

static bool Ocean::Geometry::MultipleViewGeometry::calibrateFromProjectionsMatricesIF ( const HomogenousMatrix4 flippedCamera1_P_world,
const HomogenousMatrix4 flippedCamera2_P_world,
const HomogenousMatrix4 flippedCamera3_P_world,
const unsigned int  imageWidth,
const unsigned int  imageHeight,
SquareMatrix3 cameraIntrinsics,
HomogenousMatrix4 flippedCamera1_T_world,
HomogenousMatrix4 flippedCamera2_T_world,
HomogenousMatrix4 flippedCamera3_T_world 
)
static

Calibrate three projection matrices from a single camera.

The projection matrices are transformed into metric transformation matrix using absolute conic ω and absolute dual quadric Q∞:
ω = P * Q∞ * P^T.
Q∞ = H * Î * H^T.
P_metric = P * H.
The camera intrinsics are determined by Cholesky decomposition of absolute conic ω = KK^T.

Parameters
flippedCamera1_P_worldFirst camera projection matrices (inverted flipped)
flippedCamera2_P_worldSecond camera projection matrices (inverted flipped)
flippedCamera3_P_worldThird camera projection matrices (inverted flipped)
imageWidthWidth of image
imageHeightHeight of image
cameraIntrinsicsResulting camera intrinsics matrix
flippedCamera1_T_worldResulting first camera pose (inverted flipped)
flippedCamera2_T_worldResulting second camera pose (inverted flipped)
flippedCamera3_T_worldResulting third camera pose (inverted flipped)
Returns
True, if succeeded
See also
calibrateFromProjectionsMatricesIF()

◆ cameraProjectionMatricesIF()

static bool Ocean::Geometry::MultipleViewGeometry::cameraProjectionMatricesIF ( const TrifocalTensor trifocal,
const Vector3 flippedCamera2NormedEpipole,
const Vector3 flippedCamera3NormedEpipole,
HomogenousMatrix4 flippedCamera2_P_world,
HomogenousMatrix4 flippedCamera3_P_world 
)
staticprotected

Calculates the camera projection matrices of second and third view.

The matrices are determined only up to a common projective transformation of 3-space. The projection matrix of first camera must be P_0 = [I | 0]

Parameters
trifocalTrifocal tensor matrices
flippedCamera2NormedEpipoleNormalized epipole in second view
flippedCamera3NormedEpipoleNormalized epipole in third view
flippedCamera2_P_worldResulting camera projection matrices of second view (determined only up to a common projective 3d transformation)
flippedCamera3_P_worldResulting camera projection matrices of third view (determined only up to a common projective 3d transformation)
Returns
True, if succeeded

◆ epipoles() [1/2]

template<bool tUseIF>
static bool Ocean::Geometry::MultipleViewGeometry::epipoles ( const Scalar *const  trifocal1,
const Scalar *const  trifocal2,
const Scalar *const  trifocal3,
Vector3 normedEpipole2,
Vector3 normedEpipole3 
)
staticprotected

Calculates the normalized epipoles of second and third view from trifocal tensor.

Parameters
trifocal1First trifocal tensor matrix T_1
trifocal2Second trifocal tensor matrix T_2
trifocal3Third trifocal tensor matrix T_3
normedEpipole2Resulting (normalized) epipole in second view
normedEpipole3Resulting (normalized) epipole in third view
Template Parameters
tUseIFCalculation for inverted flipped camera system, if set
Returns
True, if succeeded

◆ epipoles() [2/2]

static bool Ocean::Geometry::MultipleViewGeometry::epipoles ( const TrifocalTensor trifocal,
Vector3 normedEpipole2,
Vector3 normedEpipole3 
)
staticprotected

Calculates the normalized epipoles of second and third view from trifocal tensor.

Parameters
trifocalTrifocal tensor matrices
normedEpipole2Resulting (normalized) epipole in second view
normedEpipole3Resulting (normalized) epipole in third view
Returns
True, if succeeded

◆ epipolesIF()

static bool Ocean::Geometry::MultipleViewGeometry::epipolesIF ( const TrifocalTensor trifocal,
Vector3 flippedCamera2NormedEpipole,
Vector3 flippedCamera3NormedEpipole 
)
staticprotected

Calculates the normalized epipoles of second and third view from trifocal tensor for inverted flipped cameras.

Parameters
trifocalTrifocal tensor matrices
flippedCamera2NormedEpipoleResulting (normalized) epipole in second view
flippedCamera3NormedEpipoleResulting (normalized) epipole in third view
Returns
True, if succeeded

◆ errorMatrix()

static Scalar Ocean::Geometry::MultipleViewGeometry::errorMatrix ( const TrifocalTensor trifocal,
const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
SquareMatrix3 errorMatrix = nullptr 
)
staticprivate

Calculates the trifocal tensor error in point–point–point correspondence equation: [x_2]_x * (sum_i(x_1^i * T_i) * [x_3]_x).

Parameters
trifocalTrifocal tensor matrices
points1Image points of first set
points2Image points of second set
points3Image points of third set
correspondencesNumber of point correspondences (at least 7)
errorMatrixResulting 3x3 error matrix is needed
Returns
The absolute sum of 3x3 error matrix

◆ fundamentalMatricesIF()

static bool Ocean::Geometry::MultipleViewGeometry::fundamentalMatricesIF ( const TrifocalTensor trifocal,
const Vector3 flippedCamera2Epipole,
const Vector3 flippedCamera3Epipole,
SquareMatrix3 fundamental21,
SquareMatrix3 fundamental31 
)
staticprotected

Calculates the fundamental matrices of second view and third view from trifocal tensor.

Parameters
trifocalTrifocal tensor matrices
flippedCamera2EpipoleEpipole in second view
flippedCamera3EpipoleEpipole in third view
fundamental21Resulting fundamental matrix between second view and first view
fundamental31Resulting fundamental matrix between third view and first view
Returns
True, if succeeded

◆ pointIsCollinear()

bool Ocean::Geometry::MultipleViewGeometry::pointIsCollinear ( const Triangle2 triangle,
const Vector2 point,
const Scalar  threshold = Scalar(0.01) 
)
inlinestaticprivate

Checks if a given 2D point is collinear to three given 2D points (defined by a 2D triangle).

Parameters
triangleThe triangle defining the three points
pointThe point to be check
thresholdThreshold of variance from linearity condition, with range (0, 1]
Returns
True, if the given point is collinear to any of two corners of the triangle

◆ projectiveReconstructionFrom6PointsIF() [1/2]

static bool Ocean::Geometry::MultipleViewGeometry::projectiveReconstructionFrom6PointsIF ( const ConstIndexedAccessor< Vectors2 > &  imagePointsPerPose,
NonconstIndexedAccessor< HomogenousMatrix4 > *  flippedCameras_T_world,
const Scalar  squaredSuccessThreshold = Scalar(2.5 *2.5),
Scalar squaredProjectionError = nullptr 
)
static

Computes geometric valid camera projection matrices which are determined up to a common 3d projection transformation.

The calculation uses 6 point correspondences in which three of them are not collinear in any view The projection matrices are defined in inverted flipped coordinates system and are not metric and orthogonally: x_k = P_k * X.

Parameters
imagePointsPerPoseImage points per view (at least 3 views and at least 6 point correspondences)
flippedCameras_T_worldResulting camera projection matrices per view (inverted flipped)
squaredSuccessThresholdThreshold indicating successful matrices determination, optionally
squaredProjectionErrorSquared back-projection error, optionally
Returns
True, if succeeded and back-projection error is below threshold (note: a valid 3d scene is also maybe given with a higher error)
See also
projectiveReconstructionFrom6PointsIF()
calibrateFromProjectionsMatricesIF()

◆ projectiveReconstructionFrom6PointsIF() [2/2]

static bool Ocean::Geometry::MultipleViewGeometry::projectiveReconstructionFrom6PointsIF ( const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
HomogenousMatrix4 flippedCamera1_P_world,
HomogenousMatrix4 flippedCamera2_P_world,
HomogenousMatrix4 flippedCamera3_P_world,
const Scalar  squaredSuccessThreshold = (2.5 *2.5),
Scalar squaredProjectionError = nullptr 
)
static

Computes geometric valid camera projection matrices which are determined up to a common 3d projection transformation.


The calculation uses 6 point correspondences in which three of them are not collinear in any view The projection matrices are defined in inverted flipped coordinates system and are necessary metric and orthogonally: x_k = P_k * X.

Parameters
points1Image points of first view
points2Image points of second view
points3Image points of third view
correspondencesNumber of point correspondences (at least 6)
flippedCamera1_P_worldResulting camera projection matrix of first view (inverted flipped)
flippedCamera2_P_worldResulting camera projection matrix of second view (inverted flipped)
flippedCamera3_P_worldResulting camera projection matrix of third view (inverted flipped)
squaredSuccessThresholdThreshold indicating successful matrices determination, optionally
squaredProjectionErrorSquared back-projection error, optionally
Returns
True, if succeeded and back-projection error is below threshold (note: a valid 3d scene is also maybe given with a higher error)
See also
projectiveReconstructionFrom6PointsIF()
calibrateFromProjectionsMatricesIF()

◆ trifocalTensorFromProjectionMatrices() [1/2]

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorFromProjectionMatrices ( const HomogenousMatrix4 flippedCameraA_P_world,
const HomogenousMatrix4 flippedCameraB_P_world,
const HomogenousMatrix4 flippedCameraC_P_world,
TrifocalTensor trifocal 
)
staticprotected

Calculates the trifocal tensor by three projection matrix given: P_1 = [A | a4], P_2 = [B | b4], P_3 = [C | c4] and P = CameraInstrinsics * [Rt].

Parameters
flippedCameraA_P_worldprojection matrix P_1 in homogeneous format
flippedCameraB_P_worldprojection matrix P_2 in homogeneous format
flippedCameraC_P_worldprojection matrix P_3 in homogeneous format
trifocalResulting trifocal tensor matrices
Returns
True, if succeeded

◆ trifocalTensorFromProjectionMatrices() [2/2]

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorFromProjectionMatrices ( const HomogenousMatrix4 flippedCameraB_P_world,
const HomogenousMatrix4 flippedCameraC_P_world,
TrifocalTensor trifocal 
)
staticprotected

Calculates the trifocal tensor by two projection matrix given: P_1 = [I | 0], P_2 = [A | a4], P_3 = [B | b4] and P = C * [Rt].

Parameters
flippedCameraB_P_worldprojection matrix P_2 in homogeneous format
flippedCameraC_P_worldprojection matrix P_3 in homogeneous format
trifocalResulting trifocal tensor matrices
Returns
True, if succeeded

◆ trifocalTensorIF()

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorIF ( const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
HomogenousMatrix4 flippedCamera1_P_world,
HomogenousMatrix4 flippedCamera2_P_world,
HomogenousMatrix4 flippedCamera3_P_world,
TrifocalTensor trifocalTensor = nullptr 
)
static

The normalized linear algorithm of computation of trifocal tensor.

Calculates the trifocal tensor by three sets of at least seven corresponding image points and generates geometric valid camera projection matrices. The projection matrices are defined in inverted flipped coordinates system and are not metric and orthogonally: x_k = P_k * X.

Parameters
points1Image points of first view
points2Image points of second view
points3Image points of third view
correspondencesNumber of point correspondences (at least 7)
flippedCamera1_P_worldResulting camera projection matrix of first view (inverted flipped)
flippedCamera2_P_worldResulting camera projection matrix of second view (inverted flipped)
flippedCamera3_P_worldResulting camera projection matrix of third view (inverted flipped)
trifocalTensorOptional pointer to resulting trifocal tensor
Returns
True, if succeeded
See also
calibrateFromProjectionsMatricesIF()

◆ trifocalTensorLinear()

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorLinear ( const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
Scalar trifocal3x9,
Matrix matrixA = nullptr 
)
staticprivate

Calculates the trifocal tensor using linear system.

Parameters
points1Image points of first set
points2Image points of second set
points3Image points of third set
correspondencesNumber of point correspondences (at least 7)
trifocal3x9Pointer to resulting values of trifocal tensor matrices
matrixAPointer to constructed linear system, if needed
Returns
True, if succeeded

◆ trifocalTensorMinimizingError()

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorMinimizingError ( const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
TrifocalTensor trifocal 
)
staticprotected

Computing a geometric valid trifocal tensor minimizing algebraic error.

Calculates the trifocal tensor by three sets of at least seven corresponding image points.

Parameters
points1Image points of first set
points2Image points of second set
points3Image points of third set
correspondencesNumber of point correspondences (at least 7)
trifocalResulting trifocal tensor matrices
Returns
True, if succeeded

◆ trifocalTensorNormalizedLinear() [1/2]

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorNormalizedLinear ( const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
Scalar trifocal3x9,
Matrix matrixA = nullptr 
)
staticprivate

The normalized linear algorithm of computation of trifocal tensor.

Calculates the trifocal tensor by three sets of at least seven corresponding image points.

Parameters
points1Image points of first set
points2Image points of second set
points3Image points of third set
correspondencesNumber of point correspondences (at least 7)
trifocal3x9Pointer to resulting values of trifocal tensor matrices
matrixAPointer to constructed linear system, if needed
Returns
True, if succeeded

◆ trifocalTensorNormalizedLinear() [2/2]

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorNormalizedLinear ( const Vector2 points1,
const Vector2 points2,
const Vector2 points3,
const size_t  correspondences,
TrifocalTensor trifocal 
)
staticprotected

The normalized linear algorithm of computation of trifocal tensor.

Calculates the trifocal tensor by three sets of at least seven corresponding image points.

Parameters
points1Image points of first set
points2Image points of second set
points3Image points of third set
correspondencesNumber of point correspondences (at least 7)
trifocalResulting trifocal tensor matrices
Returns
True, if succeeded

The documentation for this class was generated from the following file: