Ocean
Ocean::Geometry::P3P Class Reference

This class provides functions determining the camera's pose by a set of three 3D object and 2D image point correspondences. More...

Inheritance diagram for Ocean::Geometry::P3P:

Static Public Member Functions

template<typename TCamera , typename TPoint >
static unsigned int poses (const AnyCameraT< TCamera > &anyCamera, const VectorT3< TPoint > *objectPoints, const VectorT2< TPoint > *imagePoints, HomogenousMatrixT4< TPoint > *world_T_cameras)
 Calculates the possible camera poses for three correspondences between 3D object points and 2D image points. More...
 
template<typename T >
static unsigned int poses (const VectorT3< T > *objectPoints, const VectorT3< T > *imageRays, HomogenousMatrixT4< T > *cameraPoses)
 Calculates the possible camera poses for three correspondences between 3D object points and 3D rays starting at the camera's center of projection and pointing towards the 3D object points. More...
 

Static Protected Member Functions

template<typename T >
static VectorT3< T > constructClosestPointToCP (const VectorT3< T > &objectPoint0, const VectorT3< T > &objectPoint1, const T objectDistance01, const T objectDistanceToCP0, const T objectDistanceToCP1)
 Constructs the closest point on the line between two object points and the camera's projection center. More...
 
template<typename T >
static bool constructClosestPointToCPOnObjectPlane (const VectorT3< T > &objectPoint0, const VectorT3< T > &objectPoint1, const VectorT3< T > &objectPoint2, const VectorT3< T > &closestPoint01, const VectorT3< T > &closestPoint02, VectorT3< T > &point)
 Constructs the closest point to the camera's projection center lying on the object surface triangle. More...
 
template<typename T >
static T sqr (const T value)
 Returns the square of a value. More...
 
- Static Protected Member Functions inherited from Ocean::Geometry::PerspectivePose
template<typename T >
static bool calculateCosineSolutions (const T x1, const T x1_2, const T cos12, const T d12_2, T &x2a, T &x2b)
 Calculates the two possible solutions for the law of cosines. More...
 
template<typename T >
static T calculateCosineResults (const T x1, const T x1_2, const T x2, const T x2_2, const T cos12, const T d12_2)
 Returns the result of the law of cosines. More...
 

Detailed Description

This class provides functions determining the camera's pose by a set of three 3D object and 2D image point correspondences.

Member Function Documentation

◆ constructClosestPointToCP()

template<typename T >
VectorT3< T > Ocean::Geometry::P3P::constructClosestPointToCP ( const VectorT3< T > &  objectPoint0,
const VectorT3< T > &  objectPoint1,
const T  objectDistance01,
const T  objectDistanceToCP0,
const T  objectDistanceToCP1 
)
inlinestaticprotected

Constructs the closest point on the line between two object points and the camera's projection center.

Parameters
objectPoint0First object point intersecting the line
objectPoint1Second object point intersecting the line
objectDistance01Distance between first and second object point
objectDistanceToCP0Distance between first object point and the camera's projection center
objectDistanceToCP1Distance between second object point and the camera's projection center
Returns
Resulting closest point
Template Parameters
TData type of e.g., the vector elements to be used, either 'float' or 'double'

We combine the following steps: const Scalar cos_ObjectPoint0 = (objectDistanceToCP1 * objectDistanceToCP1 - objectDistanceToCP0 * objectDistanceToCP0 - objectDistance01 * objectDistance01) / (-2 * objectDistanceToCP0 * objectDistance01); const Scalar distanceToClosesPoint = cos_ObjectPoint0 * objectDistanceToCP0; const Vector3 directionObjectPoint0To1 = (objectPoint1 - objectPoint0) / objectDistance01; return objectPoint0 + directionObjectPoint0To1 * distanceToClosesPoint;

◆ constructClosestPointToCPOnObjectPlane()

template<typename T >
bool Ocean::Geometry::P3P::constructClosestPointToCPOnObjectPlane ( const VectorT3< T > &  objectPoint0,
const VectorT3< T > &  objectPoint1,
const VectorT3< T > &  objectPoint2,
const VectorT3< T > &  closestPoint01,
const VectorT3< T > &  closestPoint02,
VectorT3< T > &  point 
)
inlinestaticprotected

Constructs the closest point to the camera's projection center lying on the object surface triangle.

Parameters
objectPoint0First object point intersecting the object surface triangle
objectPoint1Second object point intersecting the object surface triangle
objectPoint2Third object point intersecting the object surface triangle
closestPoint01Closest point to the camera's projection center lying on the line between first and second object point
closestPoint02Closest point to the camera's projection center lying on the line between first and third object point
pointResulting closes point
Returns
True, if succeeded
Template Parameters
TData type of e.g., the vector elements to be used, either 'float' or 'double'

◆ poses() [1/2]

template<typename TCamera , typename TPoint >
static unsigned int Ocean::Geometry::P3P::poses ( const AnyCameraT< TCamera > &  anyCamera,
const VectorT3< TPoint > *  objectPoints,
const VectorT2< TPoint > *  imagePoints,
HomogenousMatrixT4< TPoint > *  world_T_cameras 
)
static

Calculates the possible camera poses for three correspondences between 3D object points and 2D image points.

The 3D object points as well as the resulting camera poses are defined in relation to a common world coordinate system.
Each pose is defined using a default camera pointing into the negative z-space of the coordinate system, with x-axis to the right of the camera frame, and y-axis pointing upwards (this coordinate system is often used in Computer Graphics).
The resulting poses can be transformed to an inverted flipped coordinate system e.g., by using PinholeCamera::standard2InvertedFlipped().
An inverted and flipped pose is pointing into the positive z-space of the coordinate system, with x-axis to the right of the camera frame, and y-axis pointing downwards (this coordinate system is often used in Computer Vision).
The provided image points should be defined in the domain of a normal image (with origin in the upper left corner, x pointing to the right, y pointing downwards).
The p3p can result in at most four different poses due to the under-determined system of equations.

Parameters
anyCameraThe camera profile defining the projection, must be valid
objectPointsThree 3D objects points each corresponding to a different 2D image point, the points must not be collinear
imagePointsThree 2D image points each corresponding to a different 3D object point
world_T_camerasThe resulting transformation matrices receiving the different poses, the buffer must be large enough to store up to four resulting poses
Returns
Resulting number of different poses, with range [0, 4]
Template Parameters
TCameraThe data type of the camera profile, either 'float' or 'double'
TPointThe data type image and object points, either 'float' or 'double'
See also
PinholeCamera::standard2InvertedFlipped(), PinholeCamera::invertedFlipped2Standard(), PinholeCamera::undistort().

◆ poses() [2/2]

template<typename T >
static unsigned int Ocean::Geometry::P3P::poses ( const VectorT3< T > *  objectPoints,
const VectorT3< T > *  imageRays,
HomogenousMatrixT4< T > *  cameraPoses 
)
static

Calculates the possible camera poses for three correspondences between 3D object points and 3D rays starting at the camera's center of projection and pointing towards the 3D object points.

The 3D object points are defined in relation to a world coordinate system, while the 3D rays are defined in relation to the coordinate system of the camera.
Each pose is defined using a default camera pointing into the negative z-space of the coordinate system, with x-axis to the right of the camera frame and y-axis pointing upwards.
The resulting poses can be transformed to an inverted flipped coordinate system e.g., by using PinholeCamera::standard2InvertedFlipped().
The p3p can result in at most four different poses due to the under-determined system of equations.

Parameters
objectPointsThree 3D objects points each corresponding to a different 2D image point, the points must not be collinear
imageRaysThree 3D rays with unit length, defined in the coordinate system of the camera, starting at the camera's center of projection (equal to the origin), hitting the image plane at image points corresponding to the 3D object points and pointing towards the object points, each ray corresponds to one 3D object point
cameraPosesThe resulting transformation matrices receiving the different poses, the buffer must be large enough to store up to four resulting poses
Returns
Resulting number of different poses, with range [0, 4]
Template Parameters
TData type of e.g., the vector elements to be used, either 'float' or 'double'
See also
PinholeCamera::standard2InvertedFlipped(), PinholeCamera::invertedFlipped2Standard(), PinholeCamera::undistort().

◆ sqr()

template<typename T >
T Ocean::Geometry::P3P::sqr ( const T  value)
inlinestaticprotected

Returns the square of a value.

Parameters
valueThe value to square
Returns
The squared value
Template Parameters
TData type of e.g., the vector elements to be used, either 'float' or 'double'

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