8 #ifndef META_OCEAN_GEOMETRY_P3P_H
9 #define META_OCEAN_GEOMETRY_P3P_H
48 template <
typename TCamera,
typename TPo
int>
80 static inline VectorT3<T> constructClosestPointToCP(
const VectorT3<T>& objectPoint0,
const VectorT3<T>& objectPoint1,
const T objectDistance01,
const T objectDistanceToCP0,
const T objectDistanceToCP1);
102 template <
typename T>
103 static inline T
sqr(
const T value);
106 template <
typename T>
119 const T factor = T(-0.5) * (objectDistanceToCP1 * objectDistanceToCP1 - objectDistanceToCP0 * objectDistanceToCP0 - objectDistance01 * objectDistance01) / (objectDistance01 * objectDistance01);
121 return objectPoint0 * (T(1) - factor) + objectPoint1 * factor;
124 template <
typename T>
127 const VectorT3<T> objectDirection01 = objectPoint1 - objectPoint0;
128 const VectorT3<T> objectDirection02 = objectPoint2 - objectPoint0;
132 const VectorT3<T> objectPlaneNormal = objectDirection01.
cross(objectDirection02);
146 const LineT3<T> line01(closestPoint01, d01);
147 const LineT3<T> line02(closestPoint02, d02);
149 #ifdef OCEAN_INTENSIVE_DEBUG
152 const PlaneT3<T> debugPlane(objectPoint0, objectPoint1, objectPoint2);
173 point = (first + second) * T(0.5);
177 template <
typename T>
180 return value * value;
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
This class provides functions determining the camera's pose by a set of three 3D object and 2D image ...
Definition: P3P.h:28
static T sqr(const T value)
Returns the square of a value.
Definition: P3P.h:178
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 s...
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.
Definition: P3P.h:125
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 ...
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...
Definition: P3P.h:107
This class is the base class for all perspective pose classes.
Definition: PerspectivePose.h:27
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition: HomogenousMatrix4.h:110
This class implements an infinite line in 3D space.
Definition: Line3.h:70
bool nearestPoints(const LineT3< T > &line, VectorT3< T > &first, VectorT3< T > &second) const
Returns the two nearest points for two crossing lines.
Definition: Line3.h:484
const VectorT3< T > & point() const
Returns a point on the line.
Definition: Line3.h:271
This class provides basic numeric functionalities.
Definition: Numeric.h:57
This class implements a plane in 3D space.
Definition: Plane3.h:73
const VectorT3< T > & normal() const
Returns the normal of the plane.
Definition: Plane3.h:340
This class implements a vector with two elements.
Definition: Vector2.h:96
This class implements a vector with three elements.
Definition: Vector3.h:97
bool normalize()
Normalizes this vector.
Definition: Vector3.h:647
VectorT3< T > cross(const VectorT3< T > &vector) const
Returns the cross product of two vectors.
Definition: Vector3.h:597
VectorT3< T > normalizedOrZero() const
Returns the normalized vector.
Definition: Vector3.h:619
T length() const
Returns the length of the vector.
Definition: Vector3.h:664
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition: base/Utilities.h:1029
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15