8#ifndef META_OCEAN_GEOMETRY_STEREOSCOPIC_GEOMETRY_H
9#define META_OCEAN_GEOMETRY_STEREOSCOPIC_GEOMETRY_H
53 static inline bool cameraPose(
const AnyCamera& camera,
const ConstIndexedAccessor<Vector2>& imagePoints0,
const ConstIndexedAccessor<Vector2>& imagePoints1,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera1,
Vectors3* objectPoints =
nullptr,
Indices32* validIndices =
nullptr,
const Scalar maxRotationalSqrError =
Scalar(1.5 * 1.5),
const Scalar maxArbitrarySqrError =
Scalar(3.5 * 3.5),
const unsigned int iterations = 100u,
const Scalar rotationalMotionMinimalValidCorrespondencesPercent =
Scalar(0.9));
75 static bool cameraPose(
const AnyCamera& camera,
const ConstIndexedAccessor<Vector2>& imagePoints0,
const ConstIndexedAccessor<Vector2>& imagePoints1,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera0,
HomogenousMatrix4& world_T_camera1,
const GravityConstraints* gravityConstraints =
nullptr,
Vectors3* objectPoints =
nullptr,
Indices32* validIndices =
nullptr,
const Scalar maxRotationalSqrError =
Scalar(1.5 * 1.5),
const Scalar maxArbitrarySqrError =
Scalar(3.5 * 3.5),
const unsigned int iterations = 100u,
const Scalar rotationalMotionMinimalValidCorrespondencesPercent =
Scalar(0.9));
97 template <
typename TAccessorObjectPo
ints,
typename TAccessorImagePo
ints0,
typename TAccessorImagePo
ints1>
98 static bool determineValidCorrespondencesIF(
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera0_T_world,
const HomogenousMatrix4& flippedCamera1_T_world,
const TAccessorObjectPoints& objectPoints,
const TAccessorImagePoints0& imagePoints0,
const TAccessorImagePoints1& imagePoints1,
Indices32& validIndices,
const Scalar maxSqrError =
Scalar(3.5 * 3.5),
const bool onlyFrontObjectPoints =
true,
Scalar* totalSqrError =
nullptr,
const size_t minimalValidCorrespondences = 0);
101inline bool StereoscopicGeometry::cameraPose(
const AnyCamera& camera,
const ConstIndexedAccessor<Vector2>& accessorImagePoints0,
const ConstIndexedAccessor<Vector2>& accessorImagePoints1,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera1,
Vectors3* objectPoints,
Indices32* validIndices,
const Scalar maxRotationalSqrError,
const Scalar maxArbitrarySqrError,
const unsigned int iterations,
const Scalar rotationalMotionMinimalValidCorrespondencesPercent)
105 if (!
cameraPose(camera, accessorImagePoints0, accessorImagePoints1, randomGenerator, world_T_camera0, world_T_camera1,
nullptr , objectPoints, validIndices, maxRotationalSqrError, maxArbitrarySqrError, iterations, rotationalMotionMinimalValidCorrespondencesPercent))
115template <
typename TAccessorObjectPo
ints,
typename TAccessorImagePo
ints0,
typename TAccessorImagePo
ints1>
116bool StereoscopicGeometry::determineValidCorrespondencesIF(
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera0_T_world,
const HomogenousMatrix4& flippedCamera1_T_world,
const TAccessorObjectPoints& objectPoints,
const TAccessorImagePoints0& imagePoints0,
const TAccessorImagePoints1& imagePoints1,
Indices32& validIndices,
const Scalar maxSqrError,
const bool onlyFrontObjectPoints,
Scalar* totalSqrError,
const size_t minimalValidCorrespondences)
118 ocean_assert(camera.
isValid());
119 ocean_assert(flippedCamera0_T_world.
isValid());
120 ocean_assert(flippedCamera1_T_world.
isValid());
121 ocean_assert(objectPoints.size() == imagePoints0.size() && imagePoints0.size() == imagePoints1.size());
122 ocean_assert(maxSqrError >= 0);
124 ocean_assert(validIndices.empty());
125 validIndices.clear();
129 for (
size_t n = 0u; n < imagePoints0.size(); ++n)
132 if (minimalValidCorrespondences != 0 && imagePoints0.size() + validIndices.size() - n < minimalValidCorrespondences)
137 if (onlyFrontObjectPoints)
146 const Scalar sqrDistance0 = camera.
projectToImageIF(flippedCamera0_T_world, objectPoints[n]).sqrDistance(imagePoints0[n]);
147 const Scalar sqrDistance1 = camera.
projectToImageIF(flippedCamera1_T_world, objectPoints[n]).sqrDistance(imagePoints1[n]);
149 if (sqrDistance0 < maxSqrError && sqrDistance1 < maxSqrError)
151 validIndices.push_back(
Index32(n));
153 error += sqrDistance0 + sqrDistance1;
157 if (totalSqrError !=
nullptr)
159 *totalSqrError = error;
162 return !validIndices.empty();
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
virtual VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual bool isValid() const =0
Returns whether this camera is valid.
static bool isObjectPointInFrontIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, const T epsilon=NumericT< T >::eps())
Determines whether a given 3D object point lies in front of a camera while the location of the camera...
Definition Camera.h:811
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
This class implements a container allowing to define gravity constraints during e....
Definition GravityConstraints.h:63
This class implements function for stereoscopic geometry.
Definition StereoscopicGeometry.h:31
static bool cameraPose(const AnyCamera &camera, const ConstIndexedAccessor< Vector2 > &imagePoints0, const ConstIndexedAccessor< Vector2 > &imagePoints1, RandomGenerator &randomGenerator, HomogenousMatrix4 &world_T_camera1, Vectors3 *objectPoints=nullptr, Indices32 *validIndices=nullptr, const Scalar maxRotationalSqrError=Scalar(1.5 *1.5), const Scalar maxArbitrarySqrError=Scalar(3.5 *3.5), const unsigned int iterations=100u, const Scalar rotationalMotionMinimalValidCorrespondencesPercent=Scalar(0.9))
Determines the pose transformation between two given camera frames from which corresponding image poi...
Definition StereoscopicGeometry.h:101
static bool determineValidCorrespondencesIF(const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera0_T_world, const HomogenousMatrix4 &flippedCamera1_T_world, const TAccessorObjectPoints &objectPoints, const TAccessorImagePoints0 &imagePoints0, const TAccessorImagePoints1 &imagePoints1, Indices32 &validIndices, const Scalar maxSqrError=Scalar(3.5 *3.5), const bool onlyFrontObjectPoints=true, Scalar *totalSqrError=nullptr, const size_t minimalValidCorrespondences=0)
Determines valid correspondences between 2D image points and 3D camera points for two individual came...
Definition StereoscopicGeometry.h:116
static bool cameraPose(const AnyCamera &camera, const ConstIndexedAccessor< Vector2 > &imagePoints0, const ConstIndexedAccessor< Vector2 > &imagePoints1, RandomGenerator &randomGenerator, HomogenousMatrix4 &world_T_camera0, HomogenousMatrix4 &world_T_camera1, const GravityConstraints *gravityConstraints=nullptr, Vectors3 *objectPoints=nullptr, Indices32 *validIndices=nullptr, const Scalar maxRotationalSqrError=Scalar(1.5 *1.5), const Scalar maxArbitrarySqrError=Scalar(3.5 *3.5), const unsigned int iterations=100u, const Scalar rotationalMotionMinimalValidCorrespondencesPercent=Scalar(0.9))
Determines the pose transformation between two given camera frames from which corresponding image poi...
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1806
bool isIdentity() const
Returns whether this matrix is an identity matrix.
Definition HomogenousMatrix4.h:1812
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
The namespace covering the entire Ocean framework.
Definition Accessor.h:15