Ocean
Ocean::Geometry::PnP Class Reference

This class provides functions determining the camera's pose based on at least five 3D object and corresponding 2D image points. More...

Inheritance diagram for Ocean::Geometry::PnP:

Static Public Member Functions

static bool pose (const AnyCamera &camera, const Vector3 *objectPoints, const Vector2 *imagePoints, const size_t correspondences, HomogenousMatrix4 &world_T_camera)
 Calculates the pose of a camera by a set of at least five image and object points. More...
 

Static Protected Member Functions

static bool calculatePointDistances (const Vector3 *objectPoints, const Vector3 *imageRays, const size_t correspondences, Scalars &distances)
 Calculates distances between camera center and at least five 3D object points. More...
 
static bool calculateResultant (const Scalar cos12, const Scalar cos13, const Scalar cos23, const Scalar d12_2, const Scalar d13_2, const Scalar d23_2, Scalar &a0, Scalar &a1, Scalar &a2, Scalar &a3, Scalar &a4)
 Calculates the eighth degree polynomial resulting from three law of cosine polynomials. More...
 
static bool calculateResultantOptimized (const Scalar cos12, const Scalar cos13, const Scalar cos23, const Scalar d12_2, const Scalar d13_2, const Scalar d23_2, Scalar &a0, Scalar &a1, Scalar &a2, Scalar &a3, Scalar &a4)
 Calculates the eighth degree polynomial resulting from three law of cosine polynomials. 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 based on at least five 3D object and corresponding 2D image points.

Member Function Documentation

◆ calculatePointDistances()

static bool Ocean::Geometry::PnP::calculatePointDistances ( const Vector3 objectPoints,
const Vector3 imageRays,
const size_t  correspondences,
Scalars distances 
)
staticprotected

Calculates distances between camera center and at least five 3D object points.

Parameters
objectPointsThe object points for which the distances will be determined, must be valid
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, must be valid
correspondencesNumber of point correspondences, with range [5, infinity)
distancesResulting distances between camera center and each of the object points
Returns
True, if succeeded

◆ calculateResultant()

static bool Ocean::Geometry::PnP::calculateResultant ( const Scalar  cos12,
const Scalar  cos13,
const Scalar  cos23,
const Scalar  d12_2,
const Scalar  d13_2,
const Scalar  d23_2,
Scalar a0,
Scalar a1,
Scalar a2,
Scalar a3,
Scalar a4 
)
staticprotected

Calculates the eighth degree polynomial resulting from three law of cosine polynomials.

It uses the method of Sylvester resultants.

g(x) = a4 x^8 + a3 x^6 + a2 x^4 + a1 x1^2 + a0 = 0
Parameters
cos12Cosine value of angle between first and second leg
cos13Cosine value of angle between first and third leg
cos23Cosine value of angle between second and third leg
d12_2Square of distance between first and second object point
d13_2Square of distance between first and third object point
d23_2Square of distance between second and third object point
a0Resulting parameter for x1^0
a1Resulting parameter for x1^2
a2Resulting parameter for x1^4
a3Resulting parameter for x1^6
a4Resulting parameter for x1^8
Returns
True, if succeeded

◆ calculateResultantOptimized()

static bool Ocean::Geometry::PnP::calculateResultantOptimized ( const Scalar  cos12,
const Scalar  cos13,
const Scalar  cos23,
const Scalar  d12_2,
const Scalar  d13_2,
const Scalar  d23_2,
Scalar a0,
Scalar a1,
Scalar a2,
Scalar a3,
Scalar a4 
)
staticprotected

Calculates the eighth degree polynomial resulting from three law of cosine polynomials.

It uses the method of Sylvester resultants.
It's optimized to performance.

g(x) = a4 x^8 + a3 x^6 + a2 x^4 + a1 x1^2 + a0 = 0
Parameters
cos12Cosine value of angle between first and second leg
cos13Cosine value of angle between first and third leg
cos23Cosine value of angle between second and third leg
d12_2Square of distance between first and second object point
d13_2Square of distance between first and third object point
d23_2Square of distance between second and third object point
a0Resulting parameter for x1^0
a1Resulting parameter for x1^2
a2Resulting parameter for x1^4
a3Resulting parameter for x1^6
a4Resulting parameter for x1^8
Returns
True, if succeeded

◆ pose()

static bool Ocean::Geometry::PnP::pose ( const AnyCamera camera,
const Vector3 objectPoints,
const Vector2 imagePoints,
const size_t  correspondences,
HomogenousMatrix4 world_T_camera 
)
static

Calculates the pose of a camera by a set of at least five image and object points.

Parameters
cameraThe camera profile defining the projection, must be valid
objectPointsThe 3D object points for which the camera pose will be determined, defined in world, must be valid
imagePointsThe 2D image points located in the camera image, one for each 3D object point, must be valid
correspondencesNumber of point correspondences, with range [5, infinity)
world_T_cameraResulting camera pose, with default camera pointing towards the negative z-space, with y-axis upwards
Returns
True, if succeeded

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