Ocean
Ocean::Geometry::MultipleViewGeometry Class Reference

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

Data Structures

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

Static Public Member Functions

static bool projectiveReconstructionFrom6PointsIF (const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *points3, const size_t correspondences, HomogenousMatrix4 &iFlippedProjectionMatrix1, HomogenousMatrix4 &iFlippedProjectionMatrix2, HomogenousMatrix4 &iFlippedProjectionMatrix3, 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. More...
 
static bool projectiveReconstructionFrom6PointsIF (const ConstIndexedAccessor< ImagePoints > &imagePointsPerPose, NonconstIndexedAccessor< HomogenousMatrix4 > *posesIF, 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. More...
 
static bool trifocalTensorIF (const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *points3, const size_t correspondences, HomogenousMatrix4 &iFlippedProjectionMatrix1, HomogenousMatrix4 &iFlippedProjectionMatrix2, HomogenousMatrix4 &iFlippedProjectionMatrix3, TrifocalTensor *trifocalTensor=nullptr)
 The normalized linear algorithm of computation of trifocal tensor. More...
 
static bool calibrateFromProjectionsMatricesIF (const ConstIndexedAccessor< HomogenousMatrix4 > &iFlippedProjectionMatrices, const unsigned int imageWidth, const unsigned int imageHeight, SquareMatrix3 &cameraIntrinsic, HomogenousMatrix4 *iFlippedPoses)
 Calibrate multiple projection matrices from a single camera. More...
 
static bool calibrateFromProjectionsMatricesIF (const HomogenousMatrix4 &iFlippedProjectionMatrix1, const HomogenousMatrix4 &iFlippedProjectionMatrix2, const HomogenousMatrix4 &iFlippedProjectionMatrix3, const unsigned int imageWidth, const unsigned int imageHeight, SquareMatrix3 &cameraIntrinsics, HomogenousMatrix4 &iFlippedPose1, HomogenousMatrix4 &iFlippedPose2, HomogenousMatrix4 &iFlippedPose3)
 Calibrate three projection matrices from a single camera. More...
 

Static Protected Member Functions

static bool trifocalTensorNormalizedLinear (const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *points3, const size_t correspondences, TrifocalTensor &trifocal)
 The normalized linear algorithm of computation of trifocal tensor. More...
 
static bool trifocalTensorMinimizingError (const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *points3, const size_t correspondences, TrifocalTensor &trifocal)
 Computing a geometric valid trifocal tensor minimizing algebraic error. More...
 
static bool trifocalTensorFromProjectionMatrices (const HomogenousMatrix4 &iFlippedProjectionMatrixB, const HomogenousMatrix4 &iFlippedProjectionMatrixC, 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]. More...
 
static bool trifocalTensorFromProjectionMatrices (const HomogenousMatrix4 &iFlippedProjectionMatrixA, const HomogenousMatrix4 &iFlippedProjectionMatrixB, const HomogenousMatrix4 &iFlippedProjectionMatrixC, 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]. More...
 
static bool epipoles (const TrifocalTensor &trifocal, Vector3 &normedEpipole2, Vector3 &normedEpipole3)
 Calculates the normalized epipoles of second and third view from trifocal tensor. More...
 
static bool epipolesIF (const TrifocalTensor &trifocal, Vector3 &iFlippedNormedEpipole2, Vector3 &iFlippedNormedEpipole3)
 Calculates the normalized epipoles of second and third view from trifocal tensor for inverted flipped cameras. More...
 
static bool fundamentalMatricesIF (const TrifocalTensor &trifocal, const Vector3 &iFlippedEpipole2, const Vector3 &iFlippedEpipole3, SquareMatrix3 &fundamental21, SquareMatrix3 &fundamental31)
 Calculates the fundamental matrices of second view and third view from trifocal tensor. More...
 
static bool cameraProjectionMatricesIF (const TrifocalTensor &trifocal, const Vector3 &iFlippedNormedEpipole2, const Vector3 &iFlippedNormedEpipole3, HomogenousMatrix4 &iFlippedProjectionMatrix2, HomogenousMatrix4 &iFlippedProjectionMatrix3)
 Calculates the camera projection matrices of second and third view. More...
 
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. More...
 

Static Private Member Functions

static bool trifocalTensorLinear (const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *points3, const size_t correspondences, Scalar *trifocal3x9, Matrix *matrixA=nullptr)
 Calculates the trifocal tensor using linear system. More...
 
static bool trifocalTensorNormalizedLinear (const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *points3, const size_t correspondences, Scalar *trifocal3x9, Matrix *matrixA=nullptr)
 The normalized linear algorithm of computation of trifocal tensor. More...
 
static Scalar errorMatrix (const TrifocalTensor &trifocal, const ImagePoint *points1, const ImagePoint *points2, const ImagePoint *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). More...
 
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. More...
 
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). More...
 

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 > &  iFlippedProjectionMatrices,
const unsigned int  imageWidth,
const unsigned int  imageHeight,
SquareMatrix3 cameraIntrinsic,
HomogenousMatrix4 iFlippedPoses 
)
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
iFlippedProjectionMatricesThe camera projection matrices (at least 3, inverted flipped)
imageWidthWidth of image
imageHeightHeight of image
cameraIntrinsicThe resulting intrinsic camera matrix
iFlippedPosesResulting 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 iFlippedProjectionMatrix1,
const HomogenousMatrix4 iFlippedProjectionMatrix2,
const HomogenousMatrix4 iFlippedProjectionMatrix3,
const unsigned int  imageWidth,
const unsigned int  imageHeight,
SquareMatrix3 cameraIntrinsics,
HomogenousMatrix4 iFlippedPose1,
HomogenousMatrix4 iFlippedPose2,
HomogenousMatrix4 iFlippedPose3 
)
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
iFlippedProjectionMatrix1First camera projection matrices (inverted flipped)
iFlippedProjectionMatrix2Second camera projection matrices (inverted flipped)
iFlippedProjectionMatrix3Third camera projection matrices (inverted flipped)
imageWidthWidth of image
imageHeightHeight of image
cameraIntrinsicsResulting camera intrinsics matrix
iFlippedPose1Resulting first camera pose (inverted flipped)
iFlippedPose2Resulting second camera pose (inverted flipped)
iFlippedPose3Resulting third camera pose (inverted flipped)
Returns
True, if succeeded
See also
calibrateFromProjectionsMatricesIF()

◆ cameraProjectionMatricesIF()

static bool Ocean::Geometry::MultipleViewGeometry::cameraProjectionMatricesIF ( const TrifocalTensor trifocal,
const Vector3 iFlippedNormedEpipole2,
const Vector3 iFlippedNormedEpipole3,
HomogenousMatrix4 iFlippedProjectionMatrix2,
HomogenousMatrix4 iFlippedProjectionMatrix3 
)
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
iFlippedNormedEpipole2Normalized epipole in second view
iFlippedNormedEpipole3Normalized epipole in third view
iFlippedProjectionMatrix2Resulting camera projection matrices of second view (determined only up to a common projective 3d transformation)
iFlippedProjectionMatrix3Resulting 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 iFlippedNormedEpipole2,
Vector3 iFlippedNormedEpipole3 
)
staticprotected

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

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

◆ errorMatrix()

static Scalar Ocean::Geometry::MultipleViewGeometry::errorMatrix ( const TrifocalTensor trifocal,
const ImagePoint points1,
const ImagePoint points2,
const ImagePoint 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 iFlippedEpipole2,
const Vector3 iFlippedEpipole3,
SquareMatrix3 fundamental21,
SquareMatrix3 fundamental31 
)
staticprotected

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

Parameters
trifocalTrifocal tensor matrices
iFlippedEpipole2Epipole in second view
iFlippedEpipole3Epipole 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< ImagePoints > &  imagePointsPerPose,
NonconstIndexedAccessor< HomogenousMatrix4 > *  posesIF,
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)
posesIFResulting 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 ImagePoint points1,
const ImagePoint points2,
const ImagePoint points3,
const size_t  correspondences,
HomogenousMatrix4 iFlippedProjectionMatrix1,
HomogenousMatrix4 iFlippedProjectionMatrix2,
HomogenousMatrix4 iFlippedProjectionMatrix3,
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)
iFlippedProjectionMatrix1Resulting camera projection matrix of first view (inverted flipped)
iFlippedProjectionMatrix2Resulting camera projection matrix of second view (inverted flipped)
iFlippedProjectionMatrix3Resulting 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 iFlippedProjectionMatrixA,
const HomogenousMatrix4 iFlippedProjectionMatrixB,
const HomogenousMatrix4 iFlippedProjectionMatrixC,
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
iFlippedProjectionMatrixAprojection matrix P_1 in homogeneous format
iFlippedProjectionMatrixBprojection matrix P_2 in homogeneous format
iFlippedProjectionMatrixCprojection 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 iFlippedProjectionMatrixB,
const HomogenousMatrix4 iFlippedProjectionMatrixC,
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
iFlippedProjectionMatrixBprojection matrix P_2 in homogeneous format
iFlippedProjectionMatrixCprojection matrix P_3 in homogeneous format
trifocalResulting trifocal tensor matrices
Returns
True, if succeeded

◆ trifocalTensorIF()

static bool Ocean::Geometry::MultipleViewGeometry::trifocalTensorIF ( const ImagePoint points1,
const ImagePoint points2,
const ImagePoint points3,
const size_t  correspondences,
HomogenousMatrix4 iFlippedProjectionMatrix1,
HomogenousMatrix4 iFlippedProjectionMatrix2,
HomogenousMatrix4 iFlippedProjectionMatrix3,
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)
iFlippedProjectionMatrix1Resulting camera projection matrix of first view (inverted flipped)
iFlippedProjectionMatrix2Resulting camera projection matrix of second view (inverted flipped)
iFlippedProjectionMatrix3Resulting 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 ImagePoint points1,
const ImagePoint points2,
const ImagePoint 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 ImagePoint points1,
const ImagePoint points2,
const ImagePoint 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 ImagePoint points1,
const ImagePoint points2,
const ImagePoint 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 ImagePoint points1,
const ImagePoint points2,
const ImagePoint 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: