8#ifndef META_OCEAN_GEOMETRY_STEREOSCOPIC_GEOMETRY_H
9#define META_OCEAN_GEOMETRY_STEREOSCOPIC_GEOMETRY_H
52 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));
75 template <
typename TAccessorObjectPo
ints,
typename TAccessorImagePo
ints0,
typename TAccessorImagePo
ints1,
bool tUseBorderDistortionIfOuts
ide>
76 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);
79template <
typename TAccessorObjectPo
ints,
typename TAccessorImagePo
ints0,
typename TAccessorImagePo
ints1,
bool tUseBorderDistortionIfOuts
ide>
80bool 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)
83 ocean_assert(flippedCamera0_T_world.
isValid());
84 ocean_assert(flippedCamera1_T_world.
isValid());
85 ocean_assert(objectPoints.size() == imagePoints0.size() && imagePoints0.size() == imagePoints1.size());
86 ocean_assert(maxSqrError >= 0);
88 ocean_assert(validIndices.empty());
93 for (
size_t n = 0u; n < imagePoints0.size(); ++n)
96 if (minimalValidCorrespondences != 0 && imagePoints0.size() + validIndices.size() - n < minimalValidCorrespondences)
99 if (onlyFrontObjectPoints)
108 const Scalar sqrDistance0 = camera.
projectToImageIF(flippedCamera0_T_world, objectPoints[n]).sqrDistance(imagePoints0[n]);
109 const Scalar sqrDistance1 = camera.
projectToImageIF(flippedCamera1_T_world, objectPoints[n]).sqrDistance(imagePoints1[n]);
111 if (sqrDistance0 < maxSqrError && sqrDistance1 < maxSqrError)
113 validIndices.push_back((
unsigned int)n);
114 error += sqrDistance0 + sqrDistance1;
118 if (totalSqrError !=
nullptr)
120 *totalSqrError = error;
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 function for stereoscopic geometry.
Definition StereoscopicGeometry.h:30
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...
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:80
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1806
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
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