8#ifndef META_OCEAN_GEOMETRY_RANSAC_H
9#define META_OCEAN_GEOMETRY_RANSAC_H
64 static unsigned int iterations(
const unsigned int model,
const Scalar successProbability =
Scalar(0.99),
const Scalar faultyRate =
Scalar(0.2),
const unsigned int maximalIterations = 1000000u);
83 static bool p3p(
const AnyCamera& anyCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera,
const unsigned int minimalValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndices =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const GravityConstraints* gravityConstraints =
nullptr);
108 static inline bool p3p(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
const unsigned int minimalValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights);
130 static inline bool p3p(
const HomogenousMatrix4& world_T_roughCamera,
const AnyCamera& camera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera,
const Vector3& maxPositionOffset =
Vector3(
Scalar(0.1),
Scalar(0.1),
Scalar(0.1)),
const Scalar maxOrientationOffset = Numeric::deg2rad(10),
const unsigned int minValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndices =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const Scalar* weights =
nullptr);
157 static inline bool p3p(
const HomogenousMatrix4& initialPose,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
const Vector3& maxPositionOffset =
Vector3(
Scalar(0.1),
Scalar(0.1),
Scalar(0.1)),
const Scalar maxOrientationOffset = Numeric::deg2rad(10),
const unsigned int minValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndices =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const Scalar* weights =
nullptr);
179 static inline bool p3pZoom(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
Scalar& zoom,
const unsigned int minimalValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndices =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const Scalar* weights =
nullptr);
206 static inline bool p3pZoom(
const HomogenousMatrix4& initialPose,
const Scalar initialZoom,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
Scalar& zoom,
const Vector3& maxPositionOffset =
Vector3(
Scalar(0.1),
Scalar(0.1),
Scalar(0.1)),
const Scalar maxOrientationOffset = Numeric::deg2rad(10),
const unsigned int minValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndices =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const Scalar* weights =
nullptr);
266 static bool orientation(
const AnyCamera& camera,
const ConstIndexedAccessor<Vector3>& objectPoints,
const ConstIndexedAccessor<Vector2>& imagePoints,
RandomGenerator& randomGenerator,
Quaternion& world_R_camera,
const unsigned int minValidCorrespondences = 5u,
const unsigned int iterations = 20u,
const Scalar maxSqrError =
Scalar(5 * 5),
Scalar* finalError =
nullptr,
Indices32* usedIndices =
nullptr,
const GravityConstraints* gravityConstraints =
nullptr);
284 static inline bool objectPoint(
const AnyCamera& camera,
const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras,
const ConstIndexedAccessor<Vector2>& imagePoints,
RandomGenerator& randomGenerator,
Vector3& objectPoint,
const unsigned int iterations = 20u,
const Scalar maximalSqrError =
Scalar(3 * 3),
const unsigned int minValidCorrespondences = 2u,
const bool onlyFrontObjectPoint =
true,
const Estimator::EstimatorType refinementEstimator = Estimator::ET_SQUARE,
Scalar* finalRobustError =
nullptr,
Indices32* usedIndices =
nullptr);
302 static bool objectPoint(
const ConstIndexedAccessor<const AnyCamera*>& cameras,
const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras,
const ConstIndexedAccessor<Vector2>& imagePoints,
RandomGenerator& randomGenerator,
Vector3& objectPoint,
const unsigned int iterations = 20u,
const Scalar maximalSqrError =
Scalar(3 * 3),
const unsigned int minValidCorrespondences = 2u,
const bool onlyFrontObjectPoint =
true,
const Estimator::EstimatorType refinementEstimator = Estimator::ET_SQUARE,
Scalar* finalRobustError =
nullptr,
Indices32* usedIndices =
nullptr);
322 static bool objectPoint(
const AnyCamera& camera,
const ConstIndexedAccessor<SquareMatrix3>& world_R_cameras,
const ConstIndexedAccessor<Vector2>& imagePoints,
RandomGenerator& randomGenerator,
Vector3& objectPoint,
const Scalar objectPointDistance,
const unsigned int iterations = 20u,
const Scalar maximalError =
Scalar(3 * 3),
const unsigned int minValidCorrespondences = 2u,
const bool onlyFrontObjectPoint =
true,
const Estimator::EstimatorType refinementEstimator = Estimator::ET_SQUARE,
Scalar* finalError =
nullptr,
Indices32* usedIndices =
nullptr);
354 static bool plane(
const Plane3& initialPlane,
const ConstIndexedAccessor<Vector3>& objectPoints,
RandomGenerator& randomGenerator,
Plane3& plane,
const unsigned int iterations = 20u,
const Scalar maximalNormalOrientationOffset = Numeric::deg2rad(30),
const Scalar medianDistanceFactor =
Scalar(0.1),
const unsigned int minValidCorrespondences = 3u,
const Estimator::EstimatorType refinementEstimator = Estimator::ET_SQUARE,
Scalar* finalError =
nullptr,
Indices32* usedIndices =
nullptr);
392 static bool extrinsicMatrix(
const PinholeCamera& leftCamera,
const PinholeCamera& rightCamera,
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
HomogenousMatrix4& transformation,
const unsigned int testCandidates = 8u,
const unsigned int iterations = 20u,
const Scalar squarePixelErrorThreshold =
Scalar(9),
const Box3& maxTranslation =
Box3(),
const Scalar maxRotation = Numeric::pi(),
Indices32* usedIndices =
nullptr);
414 static inline bool homographyMatrix(
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
RandomGenerator& randomGenerator,
SquareMatrix3& homography,
const unsigned int testCandidates = 8u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar squarePixelErrorThreshold =
Scalar(9),
Indices32* usedIndices =
nullptr,
Worker* worker =
nullptr,
const bool useSVD =
true);
439 static inline bool homographyMatrixForNonBijectiveCorrespondences(
const Vector2* leftImagePoints,
const size_t numberLeftImagePoints,
const Vector2* rightImagePoints,
const size_t numberRightImagePoints,
const IndexPair32* correspondences,
const size_t numberCorrespondences,
RandomGenerator& randomGenerator,
SquareMatrix3& right_H_left,
const unsigned int testCandidates = 8u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar squarePixelErrorThreshold =
Scalar(9),
Indices32* usedIndices =
nullptr,
Worker* worker =
nullptr,
const bool useSVD =
true);
461 template <
bool tRefine,
bool tUseSVD>
462 static bool homographyMatrix(
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
RandomGenerator& randomGenerator,
SquareMatrix3& homography,
const unsigned int testCandidates = 8u,
const unsigned int iterations = 20u,
const Scalar squarePixelErrorThreshold =
Scalar(9),
Indices32* usedIndices =
nullptr,
Worker* worker =
nullptr);
487 template <
bool tRefine,
bool tUseSVD>
488 static bool homographyMatrixForNonBijectiveCorrespondences(
const Vector2* leftImagePoints,
const size_t numberLeftImagePoints,
const Vector2* rightImagePoints,
const size_t numberRightImagePoints,
const IndexPair32* correspondences,
const size_t numberCorrespondences,
RandomGenerator& randomGenerator,
SquareMatrix3& right_H_left,
const unsigned int testCandidates = 8u,
const unsigned int iterations = 20u,
const Scalar squarePixelErrorThreshold =
Scalar(9),
Indices32* usedIndices =
nullptr,
Worker* worker =
nullptr);
509 static bool homographyMatrices(
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
const Vector2& leftQuadrantCenter,
RandomGenerator& randomGenerator,
SquareMatrix3 homographies[4],
const unsigned int testCandidates = 8u,
const unsigned int iterations = 20u,
const Scalar squarePixelErrorThreshold =
Scalar(9),
Indices32* usedIndices =
nullptr,
Worker* worker =
nullptr);
617 static bool objectTransformationStereo(
const AnyCamera& anyCameraA,
const AnyCamera& anyCameraB,
const HomogenousMatrix4& world_T_cameraA,
const HomogenousMatrix4& world_T_cameraB,
const ConstIndexedAccessor<Vector3>& objectPointsA,
const ConstIndexedAccessor<Vector3>& objectPointsB,
const ConstIndexedAccessor<Vector2>& imagePointsA,
const ConstIndexedAccessor<Vector2>& imagePointsB,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_object,
const unsigned int minimalValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndicesA =
nullptr,
Indices32* usedIndicesB =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const bool allowMonoObservation =
true);
641 static bool p3p(
const HomogenousMatrix4* world_T_roughCamera,
const AnyCamera& camera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera,
const Vector3* maxPositionOffset,
const Scalar* maxOrientationOffset,
const unsigned int minValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights);
668 static bool p3pZoom(
const HomogenousMatrix4* initialPose,
const Scalar* initialZoom,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
Scalar& zoom,
const Vector3* maxPositionOffset,
const Scalar* maxOrientationOffset,
const unsigned int minValidCorrespondences = 5u,
const bool refine =
true,
const unsigned int iterations = 20u,
const Scalar sqrPixelErrorThreshold =
Scalar(5 * 5),
Indices32* usedIndices =
nullptr,
Scalar* sqrAccuracy =
nullptr,
const Scalar* weights =
nullptr);
686 static bool geometricTransform(
const GeometricTransformFunction geometricTransformFunction,
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
RandomGenerator& randomGenerator,
SquareMatrix3& transformMatrix,
const unsigned int testCandidates,
const unsigned int iterations,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
Worker* worker);
707 static bool geometricTransformForNonBijectiveCorrespondences(
const GeometricTransformFunction geometricTransformFunction,
const Vector2* leftImagePoints,
const size_t numberLeftImagePoints,
const Vector2* rightImagePoints,
const size_t numberRightImagePoints,
const IndexPair32* correspondences,
const size_t numberCorrespondences,
RandomGenerator& randomGenerator,
SquareMatrix3& transformMatrix,
const unsigned int testCandidates,
const unsigned int iterations,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
Worker* worker);
727 static void geometricTransformSubset(
const GeometricTransformFunction geometricTransformFunction,
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
RandomGenerator* randomGenerator,
SquareMatrix3* transformMatrix,
const unsigned int testCandidates,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
unsigned int* maxValidCandidates,
Scalar* minSquareErrors,
Lock* lock,
const unsigned int firstIteration,
const unsigned int numberIterations);
750 static void geometricTransformForNonBijectiveCorrespondencesSubset(
const GeometricTransformFunction geometricTransformFunction,
const Vector2* leftImagePoints,
const size_t numberLeftImagePoints,
const Vector2* rightImagePoints,
const size_t numberRightImagePoints,
const IndexPair32* correspondences,
const size_t numberCorrespondences,
RandomGenerator* randomGenerator,
SquareMatrix3* transformMatrix,
const unsigned int testCandidates,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
unsigned int* maxValidCandidates,
Scalar* minSquareErrors,
Lock* lock,
const unsigned int firstIteration,
const unsigned int numberIterations);
767 static void projectiveReconstructionFrom6PointsIFSubset(
const ConstIndexedAccessor<Vectors2>* imagePointsPerPose,
const size_t views,
RandomGenerator* randomGenerator,
NonconstIndexedAccessor<HomogenousMatrix4>* posesIF,
const Scalar squarePixelErrorThreshold,
NonconstArrayAccessor<Vector3>* objectPointsIF,
Indices32* usedIndices,
Scalar* minSquareErrors,
Lock* lock,
const unsigned int firstIteration,
const unsigned int numberIterations);
780inline bool RANSAC::homographyMatrix(
const Vector2* leftImagePoints,
const Vector2* rightImagePoints,
const size_t correspondences,
RandomGenerator& randomGenerator,
SquareMatrix3& homography,
const unsigned int testCandidates,
const bool refine,
const unsigned int iterations,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
Worker* worker,
const bool useSVD)
782 ocean_assert(leftImagePoints !=
nullptr && rightImagePoints !=
nullptr);
783 ocean_assert(correspondences >= 4);
784 ocean_assert(testCandidates >= 4u);
785 ocean_assert(squarePixelErrorThreshold > 0);
791 return homographyMatrix<true, true>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
795 return homographyMatrix<true, false>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
802 return homographyMatrix<false, true>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
806 return homographyMatrix<false, false>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
811inline bool RANSAC::homographyMatrixForNonBijectiveCorrespondences(
const Vector2* leftImagePoints,
const size_t numberLeftImagePoints,
const Vector2* rightImagePoints,
const size_t numberRightImagePoints,
const IndexPair32* correspondences,
const size_t numberCorrespondences,
RandomGenerator& randomGenerator,
SquareMatrix3& right_H_left,
const unsigned int testCandidates,
const bool refine,
const unsigned int iterations,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
Worker* worker,
const bool useSVD)
813 ocean_assert(leftImagePoints !=
nullptr && rightImagePoints !=
nullptr);
814 ocean_assert(numberLeftImagePoints >= 4 && numberRightImagePoints >= 4);
815 ocean_assert(correspondences !=
nullptr);
816 ocean_assert(numberCorrespondences >= 4);
817 ocean_assert(testCandidates >= 4u);
818 ocean_assert(squarePixelErrorThreshold > 0);
824 return homographyMatrixForNonBijectiveCorrespondences<true, true>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
828 return homographyMatrixForNonBijectiveCorrespondences<true, false>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
835 return homographyMatrixForNonBijectiveCorrespondences<false, true>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
839 return homographyMatrixForNonBijectiveCorrespondences<false, false>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
844template <
bool tRefine,
bool tUseSVD>
847 ocean_assert(leftImagePoints !=
nullptr && rightImagePoints !=
nullptr);
848 ocean_assert(correspondences >= 4);
849 ocean_assert(testCandidates >= 4u);
850 ocean_assert(squarePixelErrorThreshold > 0);
852 if (testCandidates < 4u || correspondences < testCandidates)
858 Indices32* indices = (tRefine || usedIndices) ? &tmpIndices :
nullptr;
860 unsigned int maxValidCorrespondences = testCandidates - 1u;
863 if (worker !=
nullptr)
867 if constexpr (tUseSVD)
869 worker->
executeFunction(
Worker::Function::createStatic(&
geometricTransformSubset,
Homography::homographyMatrixSVD, leftImagePoints, rightImagePoints, correspondences, &randomGenerator, &homography, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors, (
Lock*)(&lock), 0u, 0u), 0u,
iterations, 12u, 13u, 5u);
873 worker->
executeFunction(
Worker::Function::createStatic(&
geometricTransformSubset,
Homography::homographyMatrixLinearWithoutOptimations, leftImagePoints, rightImagePoints, correspondences, &randomGenerator, &homography, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors, (
Lock*)(&lock), 0u, 0u), 0u,
iterations, 12u, 13u, 5u);
878 if constexpr (tUseSVD)
880 geometricTransformSubset(
Homography::homographyMatrixSVD, leftImagePoints, rightImagePoints, correspondences, &randomGenerator, &homography, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
884 geometricTransformSubset(
Homography::homographyMatrixLinearWithoutOptimations, leftImagePoints, rightImagePoints, correspondences, &randomGenerator, &homography, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
888 if (maxValidCorrespondences < testCandidates || homography.
isSingular())
895 if constexpr (tRefine)
897 ocean_assert(indices);
903 if (Geometry::NonLinearOptimizationHomography::optimizeHomography<Geometry::Estimator::ET_SQUARE>(homography, validLeftImagePoints.
data(), validRightImagePoints.data(), validLeftImagePoints.size(), 9u, optimizedHomography, 20u))
905 homography = optimizedHomography;
911 for (
size_t n = 0; n < correspondences; ++n)
913 if (rightImagePoints[n].
sqrDistance(homography * leftImagePoints[n]) <= squarePixelErrorThreshold)
915 indices->emplace_back(
Index32(n));
922 if (usedIndices !=
nullptr)
924 *usedIndices = std::move(tmpIndices);
930template <
bool tRefine,
bool tUseSVD>
931bool RANSAC::homographyMatrixForNonBijectiveCorrespondences(
const Vector2* leftImagePoints,
const size_t numberLeftImagePoints,
const Vector2* rightImagePoints,
const size_t numberRightImagePoints,
const IndexPair32* correspondences,
const size_t numberCorrespondences,
RandomGenerator& randomGenerator,
SquareMatrix3& right_H_left,
const unsigned int testCandidates,
const unsigned int iterations,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
Worker* worker)
933 ocean_assert(squarePixelErrorThreshold > 0);
934 ocean_assert(leftImagePoints && rightImagePoints);
935 ocean_assert(correspondences !=
nullptr);
936 ocean_assert(numberCorrespondences >= 4);
938 if (testCandidates < 4u || numberCorrespondences < testCandidates)
944 Indices32* indices = (tRefine || usedIndices) ? &tmpIndices :
nullptr;
946 unsigned int maxValidCorrespondences = testCandidates - 1u;
949 if (worker !=
nullptr)
953 if constexpr (tUseSVD)
955 worker->
executeFunction(
Worker::Function::createStatic(&
geometricTransformForNonBijectiveCorrespondencesSubset,
Homography::homographyMatrixSVD, leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, &randomGenerator, &right_H_left, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors, (
Lock*)&lock, 0u, 0u), 0u,
iterations, 15u, 16u, 5u);
959 worker->
executeFunction(
Worker::Function::createStatic(&
geometricTransformForNonBijectiveCorrespondencesSubset,
Homography::homographyMatrixLinearWithoutOptimations, leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, &randomGenerator, &right_H_left, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors, (
Lock*)&lock, 0u, 0u), 0u,
iterations, 15u, 16u, 5u);
964 if constexpr (tUseSVD)
966 geometricTransformForNonBijectiveCorrespondencesSubset(
Homography::homographyMatrixSVD, leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, &randomGenerator, &right_H_left, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
970 geometricTransformForNonBijectiveCorrespondencesSubset(
Homography::homographyMatrixLinearWithoutOptimations, leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, &randomGenerator, &right_H_left, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
974 if (maxValidCorrespondences < testCandidates || right_H_left.
isSingular())
981 if constexpr (tRefine)
983 ocean_assert(indices);
988 validLeftImagePoints.reserve(indices->size());
989 validRightImagePoints.reserve(indices->size());
991 for (
const Index32& index : *indices)
993 const IndexPair32& correspondencePair = correspondences[index];
995 const unsigned int leftIndex = correspondencePair.first;
996 const unsigned int rightIndex = correspondencePair.second;
998 validLeftImagePoints.push_back(leftImagePoints[leftIndex]);
999 validRightImagePoints.push_back(rightImagePoints[rightIndex]);
1003 if (Geometry::NonLinearOptimizationHomography::optimizeHomography<Geometry::Estimator::ET_SQUARE>(right_H_left, validLeftImagePoints.
data(), validRightImagePoints.data(), validLeftImagePoints.size(), 9u, optimizedHomography, 20u))
1005 right_H_left = optimizedHomography;
1011 for (
size_t n = 0; n < numberCorrespondences; ++n)
1013 const IndexPair32& correspondencePair = correspondences[n];
1015 const unsigned int leftIndex = correspondencePair.first;
1016 const unsigned int rightIndex = correspondencePair.second;
1018 if (rightImagePoints[rightIndex].
sqrDistance(right_H_left * leftImagePoints[leftIndex]) <= squarePixelErrorThreshold)
1020 indices->push_back((
unsigned int)n);
1027 if (usedIndices !=
nullptr)
1029 *usedIndices = std::move(tmpIndices);
1035inline bool RANSAC::p3p(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
const unsigned int minimalValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights)
1039 return p3p(
nullptr, anyCameraPinhole, objectPointAccessor, imagePointAccessor, randomGenerator, pose,
nullptr,
nullptr, minimalValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1042inline bool RANSAC::p3p(
const HomogenousMatrix4& world_T_roughCamera,
const AnyCamera& camera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
HomogenousMatrix4& world_T_camera,
const Vector3& maxPositionOffset,
const Scalar maxOrientationOffset,
const unsigned int minValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights)
1044 return p3p(&world_T_roughCamera, camera, objectPointAccessor, imagePointAccessor, randomGenerator, world_T_camera, &maxPositionOffset, &maxOrientationOffset, minValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1047inline bool RANSAC::p3p(
const HomogenousMatrix4& initialPose,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
const Vector3& maxPositionOffset,
const Scalar maxOrientationOffset,
const unsigned int minValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights)
1051 return p3p(&initialPose, anyCameraPinhole, objectPointAccessor, imagePointAccessor, randomGenerator, pose, &maxPositionOffset, &maxOrientationOffset, minValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1054inline bool RANSAC::p3pZoom(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
Scalar& zoom,
const unsigned int minimalValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights)
1056 return p3pZoom(
nullptr,
nullptr, pinholeCamera, objectPointAccessor, imagePointAccessor, randomGenerator, useDistortionParameters, pose, zoom,
nullptr,
nullptr, minimalValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1059inline bool RANSAC::p3pZoom(
const HomogenousMatrix4& initialPose,
const Scalar initialZoom,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<Vector3>& objectPointAccessor,
const ConstIndexedAccessor<Vector2>& imagePointAccessor,
RandomGenerator& randomGenerator,
const bool useDistortionParameters,
HomogenousMatrix4& pose,
Scalar& zoom,
const Vector3& maxPositionOffset,
const Scalar maxOrientationOffset,
const unsigned int minValidCorrespondences,
const bool refine,
const unsigned int iterations,
const Scalar sqrPixelErrorThreshold,
Indices32* usedIndices,
Scalar* sqrAccuracy,
const Scalar* weights)
1062 return p3pZoom(&initialPose, &initialZoom, pinholeCamera, objectPointAccessor, imagePointAccessor, randomGenerator, useDistortionParameters, pose, zoom, &maxPositionOffset, &maxOrientationOffset, minValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1065inline bool RANSAC::objectPoint(
const AnyCamera& camera,
const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras,
const ConstIndexedAccessor<Vector2>& imagePoints,
RandomGenerator& randomGenerator,
Vector3& objectPoint,
const unsigned int iterations,
const Scalar maximalSqrError,
const unsigned int minValidCorrespondences,
const bool onlyFrontObjectPoint,
const Estimator::EstimatorType refinementEstimator,
Scalar* finalRobustError,
Indices32* usedIndices)
1069 const AnyCamera* cameraPointer = &camera;
1075 return RANSAC::objectPoint(cameraAccessor, world_T_cameras, imagePoints, randomGenerator,
objectPoint,
iterations, maximalSqrError, minValidCorrespondences, onlyFrontObjectPoint, refinementEstimator, finalRobustError, usedIndices);
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
This class implements a specialized AnyCamera object wrapping the actual camera model.
Definition AnyCamera.h:608
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition Caller.h:2877
This class implements an accessor providing direct access to a constant array of elements while all e...
Definition Accessor.h:942
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
std::vector< Pattern > Patterns
Definition of a vector holding calibration patterns.
Definition CameraCalibration.h:136
EstimatorType
Definition of individual robust estimator types.
Definition Estimator.h:34
This class implements a container allowing to define gravity constraints during e....
Definition GravityConstraints.h:63
static void normalizeHomography(SquareMatrixT3< T > &homography)
Normalizes a given homography forcing a 1 in the lower right matrix corner.
Definition Homography.h:466
static bool homographyMatrixSVD(const Vector2 *leftPoints, const Vector2 *rightPoints, const size_t correspondences, SquareMatrix3 &right_H_left)
Calculates the homography (8DOF - translation, rotation, scale, aspect ratio, shear,...
static bool homographyMatrixLinearWithoutOptimations(const Vector2 *leftPoints, const Vector2 *rightPoints, const size_t correspondences, SquareMatrix3 &right_H_left)
Calculates the homography (8DOF - translation, rotation, scale, aspect ratio, shear,...
This class implements several RANSAC functions for pose determination.
Definition RANSAC.h:41
static bool geometricTransformForNonBijectiveCorrespondences(const GeometricTransformFunction geometricTransformFunction, const Vector2 *leftImagePoints, const size_t numberLeftImagePoints, const Vector2 *rightImagePoints, const size_t numberRightImagePoints, const IndexPair32 *correspondences, const size_t numberCorrespondences, RandomGenerator &randomGenerator, SquareMatrix3 &transformMatrix, const unsigned int testCandidates, const unsigned int iterations, const Scalar squarePixelErrorThreshold, Indices32 *usedIndices, Worker *worker)
Calculates the geometry transformation between two images transforming the given image points between...
static void geometricTransformSubset(const GeometricTransformFunction geometricTransformFunction, const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, RandomGenerator *randomGenerator, SquareMatrix3 *transformMatrix, const unsigned int testCandidates, const Scalar squarePixelErrorThreshold, Indices32 *usedIndices, unsigned int *maxValidCandidates, Scalar *minSquareErrors, Lock *lock, const unsigned int firstIteration, const unsigned int numberIterations)
Internal function to calculate the geometry transformation between two images transforming the projec...
static void subsetIndices(Indices32 &indices, const size_t subset, RandomGenerator &randomGenerator)
Selects random indices from a given vector of indices.
static bool p3p(const AnyCamera &anyCamera, const ConstIndexedAccessor< Vector3 > &objectPointAccessor, const ConstIndexedAccessor< Vector2 > &imagePointAccessor, RandomGenerator &randomGenerator, HomogenousMatrix4 &world_T_camera, const unsigned int minimalValidCorrespondences=5u, const bool refine=true, const unsigned int iterations=20u, const Scalar sqrPixelErrorThreshold=Scalar(5 *5), Indices32 *usedIndices=nullptr, Scalar *sqrAccuracy=nullptr, const GravityConstraints *gravityConstraints=nullptr)
Calculates a pose using the perspective pose problem with three point correspondences using any camer...
static bool extrinsicMatrix(const PinholeCamera &leftCamera, const PinholeCamera &rightCamera, const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, HomogenousMatrix4 &transformation, const unsigned int testCandidates=8u, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), const Box3 &maxTranslation=Box3(), const Scalar maxRotation=Numeric::pi(), Indices32 *usedIndices=nullptr)
Calculates the extrinsic camera matrix by given point correspondences for two stereo images.
static bool translation(const ConstIndexedAccessor< Vector2 > &translations, RandomGenerator &randomGenerator, Vector2 &translation, const bool refine=true, const unsigned int iterations=20u, const Scalar maxSqrError=Scalar(5 *5), Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr)
Determines the 2D translation (offset/translation vector) from a set of given 2D vectors.
bool(*)(const Vector2 *, const Vector2 *, const size_t, SquareMatrix3 &) GeometricTransformFunction
Definition of a function pointer determining a geometric transformation e.g., a affine transformation...
Definition RANSAC.h:52
static bool objectPoint(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector2 > &imagePoints, RandomGenerator &randomGenerator, Vector3 &objectPoint, const unsigned int iterations=20u, const Scalar maximalSqrError=Scalar(3 *3), const unsigned int minValidCorrespondences=2u, const bool onlyFrontObjectPoint=true, const Estimator::EstimatorType refinementEstimator=Estimator::ET_SQUARE, Scalar *finalRobustError=nullptr, Indices32 *usedIndices=nullptr)
Determines the 3D object point for a set of image points observing the same object point under indivi...
Definition RANSAC.h:1065
static bool p3pZoom(const HomogenousMatrix4 *initialPose, const Scalar *initialZoom, const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< Vector3 > &objectPointAccessor, const ConstIndexedAccessor< Vector2 > &imagePointAccessor, RandomGenerator &randomGenerator, const bool useDistortionParameters, HomogenousMatrix4 &pose, Scalar &zoom, const Vector3 *maxPositionOffset, const Scalar *maxOrientationOffset, const unsigned int minValidCorrespondences=5u, const bool refine=true, const unsigned int iterations=20u, const Scalar sqrPixelErrorThreshold=Scalar(5 *5), Indices32 *usedIndices=nullptr, Scalar *sqrAccuracy=nullptr, const Scalar *weights=nullptr)
Calculates a pose including zoom factor using the perspective pose problem with three point correspon...
static unsigned int iterations(const unsigned int model, const Scalar successProbability=Scalar(0.99), const Scalar faultyRate=Scalar(0.2), const unsigned int maximalIterations=1000000u)
Calculates the number of iterations necessary to find an outlier-free model data set.
static bool orientation(const AnyCamera &camera, const ConstIndexedAccessor< Vector3 > &objectPoints, const ConstIndexedAccessor< Vector2 > &imagePoints, RandomGenerator &randomGenerator, Quaternion &world_R_camera, const unsigned int minValidCorrespondences=5u, const unsigned int iterations=20u, const Scalar maxSqrError=Scalar(5 *5), Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr, const GravityConstraints *gravityConstraints=nullptr)
Determines the 3DOF rotation of a camera pose for a set of given 2D/3D point correspondences by minim...
static bool objectTransformationStereo(const AnyCamera &anyCameraA, const AnyCamera &anyCameraB, const HomogenousMatrix4 &world_T_cameraA, const HomogenousMatrix4 &world_T_cameraB, const ConstIndexedAccessor< Vector3 > &objectPointsA, const ConstIndexedAccessor< Vector3 > &objectPointsB, const ConstIndexedAccessor< Vector2 > &imagePointsA, const ConstIndexedAccessor< Vector2 > &imagePointsB, RandomGenerator &randomGenerator, HomogenousMatrix4 &world_T_object, const unsigned int minimalValidCorrespondences=5u, const bool refine=true, const unsigned int iterations=20u, const Scalar sqrPixelErrorThreshold=Scalar(5 *5), Indices32 *usedIndicesA=nullptr, Indices32 *usedIndicesB=nullptr, Scalar *sqrAccuracy=nullptr, const bool allowMonoObservation=true)
Determines the 6-DOF object transformation between world and object so that the transformation fits w...
static bool determineCameraCalibrationPlanar(const unsigned int width, const unsigned int height, const CameraCalibration::Patterns &calibrationPatterns, const Vector2 &calibrationPatternBoxSize, const unsigned int testCandidates, PinholeCamera &pinholeCamera, const unsigned int iterations=20u, Scalar *sqrAccuracy=nullptr, Worker *worker=nullptr, Indices32 *usedIndices=nullptr)
Determines the camera calibration for several given camera calibration patterns, each pattern object ...
static void projectiveReconstructionFrom6PointsIFSubset(const ConstIndexedAccessor< Vectors2 > *imagePointsPerPose, const size_t views, RandomGenerator *randomGenerator, NonconstIndexedAccessor< HomogenousMatrix4 > *posesIF, const Scalar squarePixelErrorThreshold, NonconstArrayAccessor< Vector3 > *objectPointsIF, Indices32 *usedIndices, Scalar *minSquareErrors, Lock *lock, const unsigned int firstIteration, const unsigned int numberIterations)
Internal function to calculate inverted flipped camera poses (up to a common 3d projection transforma...
static bool plane(const ConstIndexedAccessor< Vector3 > &objectPoints, RandomGenerator &randomGenerator, Plane3 &plane, const unsigned int iterations=20u, const Scalar medianDistanceFactor=Scalar(0.1), const unsigned int minValidCorrespondences=3u, const Estimator::EstimatorType refinementEstimator=Estimator::ET_SQUARE, Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr)
Determines a 3D plane best matching to a set of given 3D object points.
static bool affineMatrix(const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, RandomGenerator &randomGenerator, SquareMatrix3 &right_A_left, const unsigned int testCandidates=6u, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(3 *3), Indices32 *usedIndices=nullptr, Worker *worker=nullptr)
Calculates the affine transformation (6DOF - translation, rotation, scale, aspect ratio,...
static bool objectPoint(const AnyCamera &camera, const ConstIndexedAccessor< SquareMatrix3 > &world_R_cameras, const ConstIndexedAccessor< Vector2 > &imagePoints, RandomGenerator &randomGenerator, Vector3 &objectPoint, const Scalar objectPointDistance, const unsigned int iterations=20u, const Scalar maximalError=Scalar(3 *3), const unsigned int minValidCorrespondences=2u, const bool onlyFrontObjectPoint=true, const Estimator::EstimatorType refinementEstimator=Estimator::ET_SQUARE, Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr)
Determines the 3D object point for a set of image points observing the same object point under indivi...
static bool similarityMatrix(const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, RandomGenerator &randomGenerator, SquareMatrix3 &similarity, const unsigned int testCandidates=4u, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), Indices32 *usedIndices=nullptr, Worker *worker=nullptr)
Calculates the similarity transformation (4DOF - translation, rotation, scale) between two images tra...
static bool projectiveReconstructionFrom6PointsIF(const ConstIndexedAccessor< Vectors2 > &imagePointsPerPose, NonconstIndexedAccessor< HomogenousMatrix4 > *posesIF, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), NonconstArrayAccessor< Vector3 > *objectPointsIF=nullptr, Indices32 *usedIndices=nullptr, Worker *worker=nullptr)
Calculates inverted flipped camera poses (up to a common 3d projection transformation) for image poin...
static bool homographyMatrix(const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, RandomGenerator &randomGenerator, SquareMatrix3 &homography, const unsigned int testCandidates=8u, const bool refine=true, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), Indices32 *usedIndices=nullptr, Worker *worker=nullptr, const bool useSVD=true)
Calculates the homography between two images transforming the given image points between two images.
Definition RANSAC.h:780
static bool line(const ConstIndexedAccessor< Vector2 > &positions, RandomGenerator &randomGenerator, Line2 &line, const bool refine=true, const unsigned int iterations=20u, const Scalar maxSqrError=Scalar(5 *5), Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr)
Determines the 2D line best fitting to a set of given 2D positions.
static bool homographyMatrixForNonBijectiveCorrespondences(const Vector2 *leftImagePoints, const size_t numberLeftImagePoints, const Vector2 *rightImagePoints, const size_t numberRightImagePoints, const IndexPair32 *correspondences, const size_t numberCorrespondences, RandomGenerator &randomGenerator, SquareMatrix3 &right_H_left, const unsigned int testCandidates=8u, const bool refine=true, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), Indices32 *usedIndices=nullptr, Worker *worker=nullptr, const bool useSVD=true)
Calculates the homography between two images transforming the given image points between two images.
Definition RANSAC.h:811
static bool p3pZoom(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< Vector3 > &objectPointAccessor, const ConstIndexedAccessor< Vector2 > &imagePointAccessor, RandomGenerator &randomGenerator, const bool useDistortionParameters, HomogenousMatrix4 &pose, Scalar &zoom, const unsigned int minimalValidCorrespondences=5u, const bool refine=true, const unsigned int iterations=20u, const Scalar sqrPixelErrorThreshold=Scalar(5 *5), Indices32 *usedIndices=nullptr, Scalar *sqrAccuracy=nullptr, const Scalar *weights=nullptr)
Calculates a pose including zoom factor using the perspective pose problem with three point correspon...
Definition RANSAC.h:1054
static bool direction(const ConstIndexedAccessor< Vector2 > &directions, RandomGenerator &randomGenerator, Vector2 &direction, const bool acceptOppositeDirections, const bool refine=true, const unsigned int iterations=20u, const Scalar maxAngle=Numeric::deg2rad(5), Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr)
Determines the 2D direction from a set of given 2D directions provided as unit vectors.
static void geometricTransformForNonBijectiveCorrespondencesSubset(const GeometricTransformFunction geometricTransformFunction, const Vector2 *leftImagePoints, const size_t numberLeftImagePoints, const Vector2 *rightImagePoints, const size_t numberRightImagePoints, const IndexPair32 *correspondences, const size_t numberCorrespondences, RandomGenerator *randomGenerator, SquareMatrix3 *transformMatrix, const unsigned int testCandidates, const Scalar squarePixelErrorThreshold, Indices32 *usedIndices, unsigned int *maxValidCandidates, Scalar *minSquareErrors, Lock *lock, const unsigned int firstIteration, const unsigned int numberIterations)
Internal function to calculate the geometry transformation between two images transforming the projec...
static bool plane(const Plane3 &initialPlane, const ConstIndexedAccessor< Vector3 > &objectPoints, RandomGenerator &randomGenerator, Plane3 &plane, const unsigned int iterations=20u, const Scalar maximalNormalOrientationOffset=Numeric::deg2rad(30), const Scalar medianDistanceFactor=Scalar(0.1), const unsigned int minValidCorrespondences=3u, const Estimator::EstimatorType refinementEstimator=Estimator::ET_SQUARE, Scalar *finalError=nullptr, Indices32 *usedIndices=nullptr)
Optimizes an already known 3D plane by minimizing the error between the plane and a set of given 3D o...
static bool geometricTransform(const GeometricTransformFunction geometricTransformFunction, const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, RandomGenerator &randomGenerator, SquareMatrix3 &transformMatrix, const unsigned int testCandidates, const unsigned int iterations, const Scalar squarePixelErrorThreshold, Indices32 *usedIndices, Worker *worker)
Calculates the geometry transformation between two images transforming the given image points between...
static bool homographyMatrices(const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, const Vector2 &leftQuadrantCenter, RandomGenerator &randomGenerator, SquareMatrix3 homographies[4], const unsigned int testCandidates=8u, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), Indices32 *usedIndices=nullptr, Worker *worker=nullptr)
Calculates four homographies between two images transforming the given image points between two image...
static bool fundamentalMatrix(const Vector2 *leftImagePoints, const Vector2 *rightImagePoints, const size_t correspondences, RandomGenerator &randomGenerator, SquareMatrix3 &right_F_left, const size_t testCandidates=8, const unsigned int iterations=20u, const Scalar maxScalarProduct=Scalar(0.001), Indices32 *usedIndices=nullptr)
Determines the fundamental matrix for given image point correspondences for two stereo images.
static void determineCameraCalibrationPlanarIteration(const unsigned int width, const unsigned int height, const ConstIndexedAccessor< Vectors3 > *objectPointGroups, const ConstIndexedAccessor< Vectors2 > *imagePointGroups, Indices32 *indices, PinholeCamera *pinholeCamera, Scalar *sqrAccuracy)
Performs execution of a camera calibration for a given subset of the entire data provided.
static bool p3p(const HomogenousMatrix4 *world_T_roughCamera, const AnyCamera &camera, const ConstIndexedAccessor< Vector3 > &objectPointAccessor, const ConstIndexedAccessor< Vector2 > &imagePointAccessor, RandomGenerator &randomGenerator, HomogenousMatrix4 &world_T_camera, const Vector3 *maxPositionOffset, const Scalar *maxOrientationOffset, const unsigned int minValidCorrespondences, const bool refine, const unsigned int iterations, const Scalar sqrPixelErrorThreshold, Indices32 *usedIndices, Scalar *sqrAccuracy, const Scalar *weights)
Calculates a camera pose using the perspective pose problem with three point correspondences.
static bool objectPoint(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector2 > &imagePoints, RandomGenerator &randomGenerator, Vector3 &objectPoint, const unsigned int iterations=20u, const Scalar maximalSqrError=Scalar(3 *3), const unsigned int minValidCorrespondences=2u, const bool onlyFrontObjectPoint=true, const Estimator::EstimatorType refinementEstimator=Estimator::ET_SQUARE, Scalar *finalRobustError=nullptr, Indices32 *usedIndices=nullptr)
Determines the 3D object point for a set of image points observing the same object point under indivi...
This class implements an infinite line in 2D space.
Definition Line2.h:83
This class implements a recursive lock object.
Definition Lock.h:31
This class implements an accessor providing direct access to an array of elements.
Definition Accessor.h:707
This class implements a base class for all indexed-based accessors allowing a non-constant reference ...
Definition Accessor.h:284
static constexpr T eps()
Returns a small epsilon.
static constexpr T maxValue()
Returns the max scalar value.
Definition Numeric.h:3253
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
const T * data() const
Returns a pointer to the internal values.
Definition SquareMatrix3.h:1047
bool isSingular() const
Returns whether this matrix is singular (and thus cannot be inverted).
Definition SquareMatrix3.h:1342
static std::vector< T > subset(const std::vector< T > &objects, const std::vector< TIndex > &indices)
Extracts a subset of a given set of objects by usage of an index vector holding the indices of all ob...
Definition Subset.h:777
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition base/Utilities.h:1159
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
std::pair< Index32, Index32 > IndexPair32
Definition of a pair holding 32 bit indices.
Definition Base.h:138
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
PinholeCameraT< Scalar > PinholeCamera
Definition of an pinhole camera object with Scalar precision.
Definition PinholeCamera.h:39
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15