8 #ifndef META_OCEAN_GEOMETRY_RANSAC_H
9 #define META_OCEAN_GEOMETRY_RANSAC_H
63 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);
81 static bool p3p(
const AnyCamera& anyCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
106 static inline bool p3p(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
128 static inline bool p3p(
const HomogenousMatrix4& world_T_roughCamera,
const AnyCamera& camera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
155 static inline bool p3p(
const HomogenousMatrix4& initialPose,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
177 static inline bool p3pZoom(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
204 static inline bool p3pZoom(
const HomogenousMatrix4& initialPose,
const Scalar initialZoom,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
281 static inline bool objectPoint(
const AnyCamera& camera,
const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras,
const ConstIndexedAccessor<ImagePoint>& imagePoints,
RandomGenerator& randomGenerator,
ObjectPoint& 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);
299 static bool objectPoint(
const ConstIndexedAccessor<const AnyCamera*>& cameras,
const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras,
const ConstIndexedAccessor<ImagePoint>& imagePoints,
RandomGenerator& randomGenerator,
ObjectPoint& 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);
319 static bool objectPoint(
const AnyCamera& camera,
const ConstIndexedAccessor<SquareMatrix3>& world_R_cameras,
const ConstIndexedAccessor<ImagePoint>& imagePoints,
RandomGenerator& randomGenerator,
ObjectPoint& 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);
351 static bool plane(
const Plane3& initialPlane,
const ConstIndexedAccessor<ObjectPoint>& 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);
391 static bool extrinsicMatrix(
const PinholeCamera& leftCamera,
const PinholeCamera& rightCamera,
const ImagePoint* leftImagePoints,
const ImagePoint* 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);
413 static inline bool homographyMatrix(
const ImagePoint* leftImagePoints,
const ImagePoint* 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);
438 static inline bool homographyMatrixForNonBijectiveCorrespondences(
const ImagePoint* leftImagePoints,
const size_t numberLeftImagePoints,
const ImagePoint* 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);
460 template <
bool tRefine,
bool tUseSVD>
461 static bool homographyMatrix(
const ImagePoint* leftImagePoints,
const ImagePoint* 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);
486 template <
bool tRefine,
bool tUseSVD>
487 static bool homographyMatrixForNonBijectiveCorrespondences(
const ImagePoint* leftImagePoints,
const size_t numberLeftImagePoints,
const ImagePoint* 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);
508 static bool homographyMatrices(
const ImagePoint* leftImagePoints,
const ImagePoint* 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);
616 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);
640 static bool p3p(
const HomogenousMatrix4* world_T_roughCamera,
const AnyCamera& camera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
667 static bool p3pZoom(
const HomogenousMatrix4* initialPose,
const Scalar* initialZoom,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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);
685 static bool geometricTransform(
const GeometricTransformFunction geometricTransformFunction,
const ImagePoint* leftImagePoints,
const ImagePoint* rightImagePoints,
const size_t correspondences,
RandomGenerator& randomGenerator,
SquareMatrix3& transformMatrix,
const unsigned int testCandidates,
const unsigned int iterations,
const Scalar squarePixelErrorThreshold,
Indices32* usedIndices,
Worker* worker);
706 static bool geometricTransformForNonBijectiveCorrespondences(
const GeometricTransformFunction geometricTransformFunction,
const ImagePoint* leftImagePoints,
const size_t numberLeftImagePoints,
const ImagePoint* 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);
726 static void geometricTransformSubset(
const GeometricTransformFunction geometricTransformFunction,
const ImagePoint* leftImagePoints,
const ImagePoint* 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);
749 static void geometricTransformForNonBijectiveCorrespondencesSubset(
const GeometricTransformFunction geometricTransformFunction,
const ImagePoint* leftImagePoints,
const size_t numberLeftImagePoints,
const ImagePoint* 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);
766 static void projectiveReconstructionFrom6PointsIFSubset(
const ConstIndexedAccessor<ImagePoints>* imagePointsPerPose,
const size_t views,
RandomGenerator* randomGenerator,
NonconstIndexedAccessor<HomogenousMatrix4>* posesIF,
const Scalar squarePixelErrorThreshold,
NonconstArrayAccessor<ObjectPoint>* objectPointsIF,
Indices32* usedIndices,
Scalar* minSquareErrors,
Lock* lock,
const unsigned int firstIteration,
const unsigned int numberIterations);
769 inline bool RANSAC::homographyMatrix(
const ImagePoint* leftImagePoints,
const ImagePoint* 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)
771 ocean_assert(leftImagePoints !=
nullptr && rightImagePoints !=
nullptr);
772 ocean_assert(correspondences >= 4);
773 ocean_assert(testCandidates >= 4u);
774 ocean_assert(squarePixelErrorThreshold > 0);
780 return homographyMatrix<true, true>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
784 return homographyMatrix<true, false>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
791 return homographyMatrix<false, true>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
795 return homographyMatrix<false, false>(leftImagePoints, rightImagePoints, correspondences, randomGenerator, homography, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
800 inline bool RANSAC::homographyMatrixForNonBijectiveCorrespondences(
const ImagePoint* leftImagePoints,
const size_t numberLeftImagePoints,
const ImagePoint* 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)
802 ocean_assert(leftImagePoints !=
nullptr && rightImagePoints !=
nullptr);
803 ocean_assert(numberLeftImagePoints >= 4 && numberRightImagePoints >= 4);
804 ocean_assert(correspondences !=
nullptr);
805 ocean_assert(numberCorrespondences >= 4);
806 ocean_assert(testCandidates >= 4u);
807 ocean_assert(squarePixelErrorThreshold > 0);
813 return homographyMatrixForNonBijectiveCorrespondences<true, true>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
817 return homographyMatrixForNonBijectiveCorrespondences<true, false>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
824 return homographyMatrixForNonBijectiveCorrespondences<false, true>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
828 return homographyMatrixForNonBijectiveCorrespondences<false, false>(leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, randomGenerator, right_H_left, testCandidates,
iterations, squarePixelErrorThreshold, usedIndices, worker);
833 template <
bool tRefine,
bool tUseSVD>
836 ocean_assert(leftImagePoints !=
nullptr && rightImagePoints !=
nullptr);
837 ocean_assert(correspondences >= 4);
838 ocean_assert(testCandidates >= 4u);
839 ocean_assert(squarePixelErrorThreshold > 0);
841 if (testCandidates < 4u || correspondences < testCandidates)
847 Indices32* indices = (tRefine || usedIndices) ? &tmpIndices :
nullptr;
849 unsigned int maxValidCorrespondences = testCandidates - 1u;
852 if (worker !=
nullptr)
856 if constexpr (tUseSVD)
858 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);
862 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);
867 if constexpr (tUseSVD)
869 geometricTransformSubset(
Homography::homographyMatrixSVD, leftImagePoints, rightImagePoints, correspondences, &randomGenerator, &homography, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
873 geometricTransformSubset(
Homography::homographyMatrixLinearWithoutOptimations, leftImagePoints, rightImagePoints, correspondences, &randomGenerator, &homography, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
877 if (maxValidCorrespondences < testCandidates || homography.
isSingular())
884 if constexpr (tRefine)
886 ocean_assert(indices);
892 if (Geometry::NonLinearOptimizationHomography::optimizeHomography<Geometry::Estimator::ET_SQUARE>(homography, validLeftImagePoints.
data(), validRightImagePoints.data(), validLeftImagePoints.size(), 9u, optimizedHomography, 20u))
894 homography = optimizedHomography;
900 for (
size_t n = 0; n < correspondences; ++n)
902 if (rightImagePoints[n].
sqrDistance(homography * leftImagePoints[n]) <= squarePixelErrorThreshold)
904 indices->emplace_back(
Index32(n));
911 if (usedIndices !=
nullptr)
913 *usedIndices = std::move(tmpIndices);
919 template <
bool tRefine,
bool tUseSVD>
920 bool RANSAC::homographyMatrixForNonBijectiveCorrespondences(
const ImagePoint* leftImagePoints,
const size_t numberLeftImagePoints,
const ImagePoint* 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)
922 ocean_assert(squarePixelErrorThreshold > 0);
923 ocean_assert(leftImagePoints && rightImagePoints);
924 ocean_assert(correspondences !=
nullptr);
925 ocean_assert(numberCorrespondences >= 4);
927 if (testCandidates < 4u || numberCorrespondences < testCandidates)
933 Indices32* indices = (tRefine || usedIndices) ? &tmpIndices :
nullptr;
935 unsigned int maxValidCorrespondences = testCandidates - 1u;
938 if (worker !=
nullptr)
942 if constexpr (tUseSVD)
944 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);
948 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);
953 if constexpr (tUseSVD)
955 geometricTransformForNonBijectiveCorrespondencesSubset(
Homography::homographyMatrixSVD, leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, &randomGenerator, &right_H_left, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
959 geometricTransformForNonBijectiveCorrespondencesSubset(
Homography::homographyMatrixLinearWithoutOptimations, leftImagePoints, numberLeftImagePoints, rightImagePoints, numberRightImagePoints, correspondences, numberCorrespondences, &randomGenerator, &right_H_left, testCandidates, squarePixelErrorThreshold, indices, &maxValidCorrespondences, &minSquareErrors,
nullptr, 0u,
iterations);
963 if (maxValidCorrespondences < testCandidates || right_H_left.
isSingular())
970 if constexpr (tRefine)
972 ocean_assert(indices);
977 validLeftImagePoints.reserve(indices->size());
978 validRightImagePoints.reserve(indices->size());
980 for (
const Index32& index : *indices)
982 const IndexPair32& correspondencePair = correspondences[index];
984 const unsigned int leftIndex = correspondencePair.first;
985 const unsigned int rightIndex = correspondencePair.second;
987 validLeftImagePoints.push_back(leftImagePoints[leftIndex]);
988 validRightImagePoints.push_back(rightImagePoints[rightIndex]);
992 if (Geometry::NonLinearOptimizationHomography::optimizeHomography<Geometry::Estimator::ET_SQUARE>(right_H_left, validLeftImagePoints.
data(), validRightImagePoints.data(), validLeftImagePoints.size(), 9u, optimizedHomography, 20u))
994 right_H_left = optimizedHomography;
1000 for (
size_t n = 0; n < numberCorrespondences; ++n)
1002 const IndexPair32& correspondencePair = correspondences[n];
1004 const unsigned int leftIndex = correspondencePair.first;
1005 const unsigned int rightIndex = correspondencePair.second;
1007 if (rightImagePoints[rightIndex].
sqrDistance(right_H_left * leftImagePoints[leftIndex]) <= squarePixelErrorThreshold)
1009 indices->push_back((
unsigned int)n);
1016 if (usedIndices !=
nullptr)
1018 *usedIndices = std::move(tmpIndices);
1024 inline bool RANSAC::p3p(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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)
1028 return p3p(
nullptr, anyCameraPinhole, objectPointAccessor, imagePointAccessor, randomGenerator, pose,
nullptr,
nullptr, minimalValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1031 inline bool RANSAC::p3p(
const HomogenousMatrix4& world_T_roughCamera,
const AnyCamera& camera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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)
1033 return p3p(&world_T_roughCamera, camera, objectPointAccessor, imagePointAccessor, randomGenerator, world_T_camera, &maxPositionOffset, &maxOrientationOffset, minValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1036 inline bool RANSAC::p3p(
const HomogenousMatrix4& initialPose,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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)
1040 return p3p(&initialPose, anyCameraPinhole, objectPointAccessor, imagePointAccessor, randomGenerator, pose, &maxPositionOffset, &maxOrientationOffset, minValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1043 inline bool RANSAC::p3pZoom(
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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)
1045 return p3pZoom(
nullptr,
nullptr, pinholeCamera, objectPointAccessor, imagePointAccessor, randomGenerator, useDistortionParameters, pose, zoom,
nullptr,
nullptr, minimalValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1048 inline bool RANSAC::p3pZoom(
const HomogenousMatrix4& initialPose,
const Scalar initialZoom,
const PinholeCamera& pinholeCamera,
const ConstIndexedAccessor<ObjectPoint>& objectPointAccessor,
const ConstIndexedAccessor<ImagePoint>& 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)
1051 return p3pZoom(&initialPose, &initialZoom, pinholeCamera, objectPointAccessor, imagePointAccessor, randomGenerator, useDistortionParameters, pose, zoom, &maxPositionOffset, &maxOrientationOffset, minValidCorrespondences, refine,
iterations, sqrPixelErrorThreshold, usedIndices, sqrAccuracy, weights);
1054 inline bool RANSAC::objectPoint(
const AnyCamera& camera,
const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras,
const ConstIndexedAccessor<ImagePoint>& imagePoints,
RandomGenerator& randomGenerator,
ObjectPoint& objectPoint,
const unsigned int iterations,
const Scalar maximalSqrError,
const unsigned int minValidCorrespondences,
const bool onlyFrontObjectPoint,
const Estimator::EstimatorType refinementEstimator,
Scalar* finalRobustError,
Indices32* usedIndices)
1058 const AnyCamera* cameraPointer = &camera;
1064 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:494
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:2876
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
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
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:40
static bool fundamentalMatrix(const ImagePoint *leftImagePoints, const ImagePoint *rightImagePoints, const size_t correspondences, const unsigned int width, const unsigned int height, SquareMatrix3 &fundamental, const unsigned int testCandidates=8u, const unsigned int iterations=20u, const Scalar errorThreshold=Numeric::weakEps(), Indices32 *usedIndices=nullptr)
Calculates the fundamental matrix by given point correspondences for two stereo images.
static void geometricTransformForNonBijectiveCorrespondencesSubset(const GeometricTransformFunction geometricTransformFunction, const ImagePoint *leftImagePoints, const size_t numberLeftImagePoints, const ImagePoint *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 objectPoint(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< ImagePoint > &imagePoints, RandomGenerator &randomGenerator, ObjectPoint &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...
static bool geometricTransform(const GeometricTransformFunction geometricTransformFunction, const ImagePoint *leftImagePoints, const ImagePoint *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 p3p(const HomogenousMatrix4 *world_T_roughCamera, const AnyCamera &camera, const ConstIndexedAccessor< ObjectPoint > &objectPointAccessor, const ConstIndexedAccessor< ImagePoint > &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 AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< ImagePoint > &imagePoints, RandomGenerator &randomGenerator, ObjectPoint &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:1054
static bool projectiveReconstructionFrom6PointsIF(const ConstIndexedAccessor< ImagePoints > &imagePointsPerPose, NonconstIndexedAccessor< HomogenousMatrix4 > *posesIF, const unsigned int iterations=20u, const Scalar squarePixelErrorThreshold=Scalar(9), NonconstArrayAccessor< ObjectPoint > *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 homographyMatrices(const ImagePoint *leftImagePoints, const ImagePoint *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 p3pZoom(const HomogenousMatrix4 *initialPose, const Scalar *initialZoom, const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< ObjectPoint > &objectPointAccessor, const ConstIndexedAccessor< ImagePoint > &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 bool similarityMatrix(const ImagePoint *leftImagePoints, const ImagePoint *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 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.
static bool p3p(const AnyCamera &anyCamera, const ConstIndexedAccessor< ObjectPoint > &objectPointAccessor, const ConstIndexedAccessor< ImagePoint > &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)
Calculates a pose using the perspective pose problem with three point correspondences using any camer...
static bool orientation(const AnyCamera &camera, const ConstIndexedAccessor< ObjectPoint > &objectPoints, const ConstIndexedAccessor< ImagePoint > &imagePoints, RandomGenerator &randomGenerator, SquareMatrix3 &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)
Determines the 3DOF rotation of a camera pose for a set of given 2D/3D point correspondences by minim...
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 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 void projectiveReconstructionFrom6PointsIFSubset(const ConstIndexedAccessor< ImagePoints > *imagePointsPerPose, const size_t views, RandomGenerator *randomGenerator, NonconstIndexedAccessor< HomogenousMatrix4 > *posesIF, const Scalar squarePixelErrorThreshold, NonconstArrayAccessor< ObjectPoint > *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 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 bool objectPoint(const AnyCamera &camera, const ConstIndexedAccessor< SquareMatrix3 > &world_R_cameras, const ConstIndexedAccessor< ImagePoint > &imagePoints, RandomGenerator &randomGenerator, ObjectPoint &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 geometricTransformForNonBijectiveCorrespondences(const GeometricTransformFunction geometricTransformFunction, const ImagePoint *leftImagePoints, const size_t numberLeftImagePoints, const ImagePoint *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 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 void geometricTransformSubset(const GeometricTransformFunction geometricTransformFunction, const ImagePoint *leftImagePoints, const ImagePoint *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 bool affineMatrix(const ImagePoint *leftImagePoints, const ImagePoint *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 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 bool plane(const Plane3 &initialPlane, const ConstIndexedAccessor< ObjectPoint > &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 homographyMatrixForNonBijectiveCorrespondences(const ImagePoint *leftImagePoints, const size_t numberLeftImagePoints, const ImagePoint *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:800
static bool plane(const ConstIndexedAccessor< ObjectPoint > &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 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 homographyMatrix(const ImagePoint *leftImagePoints, const ImagePoint *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:769
static bool extrinsicMatrix(const PinholeCamera &leftCamera, const PinholeCamera &rightCamera, const ImagePoint *leftImagePoints, const ImagePoint *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 p3pZoom(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< ObjectPoint > &objectPointAccessor, const ConstIndexedAccessor< ImagePoint > &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:1043
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 deg2rad(const T deg)
Converts deg to rad.
Definition: Numeric.h:3232
static constexpr T weakEps()
Returns a weak epsilon.
static constexpr T pi()
Returns PI which is equivalent to 180 degree.
Definition: Numeric.h:926
static constexpr T eps()
Returns a small epsilon.
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
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:1046
bool isSingular() const
Returns whether this matrix is singular (and thus cannot be inverted).
Definition: SquareMatrix3.h:1341
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:751
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:1089
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
std::pair< Index32, Index32 > IndexPair32
Definition of a pair holding 32 bit indices.
Definition: Base.h:138
uint32_t Index32
Definition of a 32 bit index value.
Definition: Base.h:84
float Scalar
Definition of a scalar type.
Definition: Math.h:128
BoxT3< Scalar > Box3
Definition of the Box3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single or...
Definition: Box3.h:21
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
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:32
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15