8 #ifndef META_OCEAN_TRACKING_SOLVER_3_H
9 #define META_OCEAN_TRACKING_SOLVER_3_H
55 CM_ROTATIONAL = (1 << 1),
57 CM_TRANSLATIONAL = (1 << 2),
59 CM_ROTATIONAL_TINY = CM_ROTATIONAL | (1 << 3),
61 CM_ROTATIONAL_MODERATE = CM_ROTATIONAL | (1 << 4),
63 CM_ROTATIONAL_SIGNIFICANT = CM_ROTATIONAL | (1 << 5),
65 CM_TRANSLATIONAL_TINY = CM_TRANSLATIONAL | (1 << 6),
67 CM_TRANSLATIONAL_MODERATE = CM_TRANSLATIONAL | (1 << 7),
69 CM_TRANSLATIONAL_SIGNIFICANT = CM_TRANSLATIONAL | (1 << 8),
71 CM_UNKNOWN = CM_ROTATIONAL | CM_TRANSLATIONAL | (1 << 9)
86 AM_MEAN_DIRECTION_MEDIAN_COSINE
102 inline RelativeThreshold(
const unsigned int lowerBoundary,
const Scalar factor,
const unsigned int upperBoundary);
108 inline unsigned int lowerBoundary()
const;
114 inline Scalar factor()
const;
120 inline unsigned int upperBoundary()
const;
127 inline unsigned int threshold(
const unsigned int value)
const;
135 inline bool hasValidThreshold(
const unsigned int value,
unsigned int* threshold =
nullptr)
const;
144 template <
unsigned int tLowerBoundary>
145 inline bool hasValidThreshold(
const unsigned int value,
unsigned int* threshold =
nullptr)
const;
428 static bool determineInitialObjectPointsFromSparseKeyFrames(
const Database& database,
const PinholeCamera& pinholeCamera,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int startFrame,
const unsigned int upperFrame,
const Scalar maximalStaticImagePointFilterRatio,
Vectors3& initialObjectPoints,
Indices32& initialObjectPointIds,
const RelativeThreshold& pointsThreshold =
RelativeThreshold(20u,
Scalar(0.5), 100u),
const unsigned int minimalKeyFrames = 3u,
const unsigned int maximalKeyFrames = 10u,
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Indices32* usedPoseIds =
nullptr,
Scalar* finalSqrError =
nullptr,
Scalar* finalImagePointDistance =
nullptr,
bool* abort =
nullptr);
456 static bool determineInitialObjectPointsFromDenseFrames(
const Database& database,
const PinholeCamera& pinholeCamera,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int startFrame,
const unsigned int upperFrame,
const CV::SubRegion& regionOfInterest,
const Scalar maximalStaticImagePointFilterRatio,
Vectors3& initialObjectPoints,
Indices32& initialObjectPointIds,
const RelativeThreshold& pointsThreshold =
RelativeThreshold(20u,
Scalar(0.5), 100u),
const Scalar minimalTrackedFramesRatio =
Scalar(0.1),
const unsigned int minimalKeyFrames = 3u,
const unsigned int maximalKeyFrames = 10u,
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Indices32* usedPoseIds =
nullptr,
Scalar* finalSqrError =
nullptr,
bool* abort =
nullptr);
481 static bool determineInitialObjectPointsFromSparseKeyFramesBySteps(
const Database& database,
const unsigned int steps,
const PinholeCamera& pinholeCamera,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const Scalar maximalStaticImagePointFilterRatio,
Vectors3& initialObjectPoints,
Indices32& initialObjectPointIds,
const RelativeThreshold& pointsThreshold =
RelativeThreshold(20u,
Scalar(0.5), 100u),
const unsigned int minimalKeyFrames = 2u,
const unsigned int maximalKeyFrames = 10u,
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Indices32* usedPoseIds =
nullptr,
Worker* worker =
nullptr,
bool* abort =
nullptr);
514 static bool determineInitialObjectPointsFromSparseKeyFramesRANSAC(
const PinholeCamera& pinholeCamera,
const Database::ImagePointGroups& imagePointGroups,
RandomGenerator& randomGenerator,
HomogenousMatrices4& validPoses,
Indices32& validPoseIndices,
Vectors3& objectPoints,
Indices32& validObjectPointIndices,
const unsigned int iterations = 20u,
const RelativeThreshold& minimalValidObjectPoints =
RelativeThreshold(10u,
Scalar(0.3), 20u),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
const Database* database =
nullptr,
const Indices32* keyFrameIds =
nullptr,
const Indices32* objectPointIds =
nullptr,
bool* abort =
nullptr);
543 static bool determineInitialObjectPointsFromDenseFramesRANSAC(
const PinholeCamera& pinholeCamera,
const ImagePointGroups& imagePointGroups,
RandomGenerator& randomGenerator,
HomogenousMatrices4& validPoses,
Indices32& validPoseIds,
Vectors3& objectPoints,
Indices32& validObjectPointIndices,
const unsigned int iterations = 20u,
const RelativeThreshold& minimalValidObjectPoints =
RelativeThreshold(10u,
Scalar(0.3), 20u),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Worker* worker =
nullptr,
bool* abort =
nullptr);
574 static bool determineInitialObjectPointsFromSparseKeyFrames(
const PinholeCamera& pinholeCamera,
const Database::ImagePointGroups& imagePointGroups,
RandomGenerator& randomGenerator,
const unsigned int firstGroupIndex,
const unsigned int secondGroupIndex,
HomogenousMatrices4& poses,
Indices32& validPoseIndices,
Vectors3& objectPoints,
Indices32& validObjectPointIndices,
const RelativeThreshold& minimalValidObjectPoints =
RelativeThreshold(10u,
Scalar(0.3), 20u),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5));
604 static bool determineInitialObjectPointsFromDenseFrames(
const PinholeCamera& pinholeCamera,
const ImagePointGroups& imagePointGroups,
RandomGenerator& randomGenerator,
const unsigned int firstGroupIndex,
const unsigned int secondGroupIndex,
HomogenousMatrices4& validPoses,
Indices32& validPoseIds,
Scalar& totalSqrError,
Vectors3& objectPoints,
Indices32& validObjectPointIndices,
const RelativeThreshold& minimalValidObjectPoints =
RelativeThreshold(10u,
Scalar(0.3), 20u),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5));
630 static bool optimizeInitialObjectPoints(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int startFrame,
const unsigned int upperFrame,
const Vectors3& initialObjectPoints,
const Indices32& initialObjectPointIds,
Vectors3& optimizedObjectPoints,
Indices32& optimizedObjectPointIds,
const unsigned int minimalObjectPoints = 5u,
const unsigned int minimalKeyFrames = 3u,
const unsigned int maximalKeyFrames = 10u,
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Indices32* usedPoseIds =
nullptr,
Scalar* initialSqrError =
nullptr,
Scalar* finalSqrError =
nullptr,
bool* abort =
nullptr);
650 static bool determineUnknownObjectPoints(
const Database& database,
const AnyCamera& camera,
const unsigned int lowerFrame,
const unsigned int upperFrame,
Vectors3& newObjectPoints,
Indices32& newObjectPointIds,
const unsigned int minimalKeyFrames = 3u,
const unsigned int maximalKeyFrames = 10u,
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Worker* worker =
nullptr,
bool* abort =
nullptr);
673 static bool determineUnknownObjectPoints(
const Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
const Indices32& unknownObjectPointIds,
Vectors3& newObjectPoints,
Indices32& newObjectPointIds,
RandomGenerator& randomGenerator,
Indices32* newObjectPointObservations =
nullptr,
const unsigned int minimalObservations = 2u,
const bool useAllObservations =
true,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar ransacMaximalSqrError =
Scalar(3.5 * 3.5),
const Scalar averageRobustError =
Scalar(3.5 * 3.5),
const Scalar maximalSqrError =
Numeric::maxValue(),
Worker* worker =
nullptr,
bool* abort =
nullptr);
698 static inline bool determineUnknownObjectPoints(
const Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
Vectors3& newObjectPoints,
Indices32& newObjectPointIds,
RandomGenerator& randomGenerator,
Indices32* newObjectPointObservations =
nullptr,
const Scalar minimalObjectPointPriority =
Scalar(-1),
const unsigned int minimalObservations = 10u,
const bool useAllObservations =
true,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar ransacMaximalSqrError =
Scalar(3.5 * 3.5),
const Scalar averageRobustError =
Scalar(3.5 * 3.5),
const Scalar maximalSqrError =
Numeric::maxValue(),
Worker* worker =
nullptr,
bool* abort =
nullptr);
726 template <
bool tVisibleInAllPoses>
727 static inline bool determineUnknownObjectPoints(
const Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
const Index32 lowerPoseId,
const Index32 upperPoseId,
Vectors3& newObjectPoints,
Indices32& newObjectPointIds,
RandomGenerator& randomGenerator,
Indices32* newObjectPointObservations =
nullptr,
const Scalar minimalObjectPointPriority =
Scalar(-1),
const unsigned int minimalObservations = 10u,
const bool useAllObservations =
true,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar ransacMaximalSqrError =
Scalar(3.5 * 3.5),
const Scalar averageRobustError =
Scalar(3.5 * 3.5),
const Scalar maximalSqrError =
Numeric::maxValue(),
Worker* worker =
nullptr,
bool* abort =
nullptr);
746 static bool optimizeObjectPointsWithFixedPoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const CameraMotion cameraMotion,
const Indices32& objectPointIds,
Vectors3& optimizedObjectPoints,
Indices32& optimizedObjectPointIds,
unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar maximalRobustError =
Scalar(3.5 * 3.5),
Worker* worker =
nullptr,
bool* abort =
nullptr);
771 static bool optimizeObjectPointsWithVariablePoses(
const Database& database,
const PinholeCamera& pinholeCamera,
Vectors3& optimizedObjectPoints,
Indices32& optimizedObjectPointIds,
HomogenousMatrices4* optimizedKeyFramePoses =
nullptr,
Indices32* optimizedKeyFramePoseIds =
nullptr,
const unsigned int minimalKeyFrames = 3u,
const unsigned int maximalKeyFrames = 20u,
const unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
794 static bool optimizeObjectPointsWithVariablePoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const Indices32& keyFrameIds,
Vectors3& optimizedObjectPoints,
Indices32& optimizedObjectPointIds,
HomogenousMatrices4* optimizedKeyFramePoses =
nullptr,
const unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
818 static bool optimizeObjectPointsWithVariablePoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const Indices32& keyFrameIds,
const Indices32& objectPointIds,
Vectors3& optimizedObjectPoints,
Indices32& optimizedObjectPointIds,
HomogenousMatrices4* optimizedKeyFramePoses =
nullptr,
const unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
820 static bool optimizeObjectPointsWithVariablePoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const Index32 lowerPoseId,
const Index32 upperPoseId,
const Indices32& objectPointIds,
Indices32& usedKeyFrameIds,
Vectors3& optimizedObjectPoints,
const unsigned int minimalObservations = 10u,
const unsigned int minimalKeyFrames = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
849 static bool supposeRotationalCameraMotion(
const Database& database,
const PinholeCamera& pinholeCamera,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const bool findInitialFieldOfView,
const PinholeCamera::OptimizationStrategy optimizationStrategy,
PinholeCamera& optimizedCamera,
Database& optimizedDatabase,
const unsigned int minimalObservations = 0u,
const unsigned int minimalKeyframes = 3u,
const unsigned int maximalKeyframes = 20u,
const Scalar lowerFovX =
Numeric::deg2rad(20),
const Scalar upperFovX =
Numeric::deg2rad(140),
const Scalar maximalSqrError = (1.5 * 1.5),
Worker* worker =
nullptr,
bool* abort =
nullptr,
Scalar* finalMeanSqrError =
nullptr);
876 static bool optimizeCamera(
const Database& database,
const PinholeCamera& pinholeCamera,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const bool findInitialFieldOfView,
const PinholeCamera::OptimizationStrategy optimizationStrategy,
PinholeCamera& optimizedCamera,
Database& optimizedDatabase,
const unsigned int minimalObservationsInKeyframes = 2u,
const unsigned int minimalKeyframes = 3u,
const unsigned int maximalKeyframes = 20u,
const Scalar lowerFovX =
Numeric::deg2rad(20),
const Scalar upperFovX =
Numeric::deg2rad(140),
Worker* worker =
nullptr,
bool* abort =
nullptr,
Scalar* finalMeanSqrError =
nullptr);
903 static bool optimizeCameraWithVariableObjectPointsAndPoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const PinholeCamera::OptimizationStrategy optimizationStrategy,
PinholeCamera& optimizedCamera,
Vectors3* optimizedObjectPoints =
nullptr,
Indices32* optimizedObjectPointIds =
nullptr,
HomogenousMatrices4* optimizedKeyFramePoses =
nullptr,
Indices32* optimizedKeyFramePoseIds =
nullptr,
const unsigned int minimalKeyFrames = 3u,
const unsigned int maximalKeyFrames = 20u,
const unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
928 static bool optimizeCameraWithVariableObjectPointsAndPoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const PinholeCamera::OptimizationStrategy optimizationStrategy,
const Indices32& keyFrameIds,
PinholeCamera& optimizedCamera,
Vectors3* optimizedObjectPoints =
nullptr,
Indices32* optimizedObjectPointIds =
nullptr,
HomogenousMatrices4* optimizedKeyFramePoses =
nullptr,
const unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
954 static bool optimizeCameraWithVariableObjectPointsAndPoses(
const Database& database,
const PinholeCamera& pinholeCamera,
const PinholeCamera::OptimizationStrategy optimizationStrategy,
const Indices32& keyFrameIds,
const Indices32& objectPointIds,
PinholeCamera& optimizedCamera,
Vectors3* optimizedObjectPoints =
nullptr,
Indices32* optimizedObjectPointIds =
nullptr,
HomogenousMatrices4* optimizedKeyFramePoses =
nullptr,
const unsigned int minimalObservations = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const unsigned int iterations = 50u,
Scalar* initialRobustError =
nullptr,
Scalar* finalRobustError =
nullptr);
979 static bool updatePoses(
Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int startFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar ransacMaximalSqrError =
Scalar(3.5 * 3.5),
const Scalar maximalRobustError =
Scalar(3.5 * 3.5),
Scalar* finalAverageError =
nullptr,
size_t* validPoses =
nullptr,
bool* abort =
nullptr);
1003 static bool updatePoses(
Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar ransacMaximalSqrError =
Scalar(3.5 * 3.5),
const Scalar maximalRobustError =
Scalar(3.5 * 3.5),
Scalar* finalAverageError =
nullptr,
size_t* validPoses =
nullptr,
Worker* worker =
nullptr,
bool* abort =
nullptr);
1028 static bool determinePoses(
const Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
const IndexSet32& priorityObjectPointIds,
const bool solePriorityPoints,
RandomGenerator& randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
ShiftVector<HomogenousMatrix4>& poses,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar ransacMaximalSqrError =
Scalar(3.5 * 3.5),
const Scalar maximalRobustError =
Scalar(3.5 * 3.5),
Scalar* finalAverageError =
nullptr,
Worker* worker =
nullptr,
bool* abort =
nullptr);
1049 static bool trackObjectPoints(
const Database& database,
const Indices32& objectPointIds,
const unsigned int lowerFrame,
const unsigned int startFrame,
const unsigned int upperFrame,
const unsigned int minimalTrackedObjectPoints,
const unsigned int minimalTrackedFrames,
const unsigned int maximalTrackedObjectPoints,
Indices32& trackedObjectPointIds,
ImagePointGroups& trackedImagePointGroups,
Indices32* trackedValidIndices =
nullptr,
bool* abort =
nullptr);
1074 static bool trackObjectPoints(
const Database& database,
const Indices32& priorityObjectPointIds,
const Indices32& remainingObjectPointIds,
const unsigned int lowerFrame,
const unsigned int startFrame,
const unsigned int upperFrame,
const unsigned int minimalTrackedPriorityObjectPoints,
const Scalar minimalRemainingFramesRatio,
const unsigned int maximalTrackedPriorityObjectPoints,
const unsigned int maximalTrackedRemainingObjectPoints,
Indices32& trackedObjectPointIds,
ImagePointGroups& trackedImagePointGroups,
Indices32* trackedValidPriorityIndices =
nullptr,
Indices32* trackedValidRemainingIndices =
nullptr,
bool* abort =
nullptr);
1124 static inline HomogenousMatrix4 determinePose(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const HomogenousMatrix4& roughPose =
HomogenousMatrix4(
false),
const unsigned int minimalCorrespondences = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Scalar* finalRobustError =
nullptr,
unsigned int* correspondences =
nullptr);
1143 static inline HomogenousMatrix4 determinePose(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const IndexSet32& priorityObjectPointIds,
const bool solePriorityPoints,
const HomogenousMatrix4& roughPose =
HomogenousMatrix4(
false),
const unsigned int minimalCorrespondences = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Scalar* finalRobustError =
nullptr,
unsigned int* correspondences =
nullptr);
1160 static inline HomogenousMatrix4 determinePose(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const ConstIndexedAccessor<ObjectPoint>& objectPoints,
const ConstIndexedAccessor<Index32>& objectPointIds,
const HomogenousMatrix4& roughPose =
HomogenousMatrix4(
false),
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Scalar* finalRobustError =
nullptr);
1210 static inline SquareMatrix3 determineOrientation(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const SquareMatrix3& roughOrientation =
SquareMatrix3(
false),
const unsigned int minimalCorrespondences = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Scalar* finalRobustError =
nullptr,
unsigned int* correspondences =
nullptr);
1229 static inline SquareMatrix3 determineOrientation(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const IndexSet32& priorityObjectPointIds,
const bool solePriorityPoints,
const SquareMatrix3& roughOrientation =
SquareMatrix3(
false),
const unsigned int minimalCorrespondences = 10u,
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Scalar* finalRobustError =
nullptr,
unsigned int* correspondences =
nullptr);
1247 static inline SquareMatrix3 determineOrientation(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const ObjectPoint* objectPoints,
const Index32* objectPointIds,
const size_t numberObjectPoints,
const SquareMatrix3& roughOrientation =
SquareMatrix3(
false),
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_SQUARE,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Scalar* finalRobustError =
nullptr);
1301 static size_t determineValidPoses(
const AnyCamera& camera,
const Vectors3& objectPoints,
const ImagePointGroups& imagePointGroups,
RandomGenerator& randomGenerator,
const CameraMotion cameraMotion,
const unsigned int firstValidPoseIndex,
const HomogenousMatrix4& firstValidPose,
const unsigned int secondValidPoseIndex,
const HomogenousMatrix4& secondValidPose,
const Scalar minimalValidCorrespondenceRatio =
Scalar(1),
const Scalar maximalSqrError =
Scalar(3.5 * 3.5),
Indices32* validObjectPointIndices =
nullptr,
HomogenousMatrices4* poses =
nullptr,
Indices32* poseIds =
nullptr,
Scalar* totalSqrError =
nullptr);
1319 static CameraMotion determineCameraMotion(
const Database& database,
const PinholeCamera& pinholeCamera,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const bool onlyVisibleObjectPoints =
true,
Worker* worker =
nullptr,
const Scalar minimalTinyTranslationObservationAngle =
Numeric::deg2rad(
Scalar(0.15)),
const Scalar minimalModerateTranslationObservationAngle =
Numeric::deg2rad(1),
const Scalar minimalSignificantTranslationObservationAngle =
Numeric::deg2rad(5),
const Scalar minimalTinyRotationAngle =
Numeric::deg2rad(
Scalar(0.25)),
const Scalar minimalModerateRotationAngle =
Numeric::deg2rad(5),
const Scalar minimalSignificantRotationAngle =
Numeric::deg2rad(10));
1389 static bool determineProjectionErrors(
const Database& database,
const PinholeCamera& pinholeCamera,
const Indices32& objectPointIds,
const bool useDistortionParameters,
const unsigned int lowerFrame = (
unsigned int)(-1),
const unsigned int upperFrame = (
unsigned int)(-1),
Scalar* minimalSqrErrors =
nullptr,
Scalar* averagedSqrErrors =
nullptr,
Scalar* maximalSqrErrors =
nullptr,
unsigned int* observations =
nullptr,
Worker* worker =
nullptr);
1416 static bool determineNumberCorrespondences(
const Database& database,
const bool needValidPose,
const unsigned int lowerFrame,
const unsigned int upperFrame,
unsigned int* minimalCorrespondences =
nullptr,
Scalar* averageCorrespondences =
nullptr,
unsigned int* medianCorrespondences =
nullptr,
unsigned int* maximalCorrespondences =
nullptr,
Worker* worker =
nullptr);
1458 static bool determinePlane(
const Database& database,
const Index32 frameIndex,
const CV::SubRegion& subRegion,
RandomGenerator& randomGenerator,
Plane3& plane,
const RelativeThreshold& minimalValidObjectPoints =
RelativeThreshold(3u,
Scalar(0.5), 20u),
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_HUBER,
Scalar* finalError =
nullptr,
Indices32* usedObjectPointIds =
nullptr);
1478 static bool determinePlane(
const Database& database,
const PinholeCamera& pinholeCamera,
const unsigned int lowerFrameIndex,
const unsigned int subRegionFrameIndex,
const unsigned int upperFrameIndex,
const CV::SubRegion& subRegion,
RandomGenerator& randomGenerator,
Plane3& plane,
const bool useDistortionParameters,
const RelativeThreshold& minimalValidObjectPoints =
RelativeThreshold(3u,
Scalar(0.5), 20u),
const Scalar medianDistanceFactor =
Scalar(6),
const Geometry::Estimator::EstimatorType estimator =
Geometry::Estimator::ET_HUBER,
Scalar* finalError =
nullptr,
Indices32* usedObjectPointIds =
nullptr);
1590 static void determineInitialObjectPointsFromSparseKeyFramesByStepsSubset(
const Database* database,
const PinholeCamera* pinholeCamera,
RandomGenerator* randomGenerator,
const unsigned int lowerFrame,
const Indices32* startFrames,
const unsigned int upperFrame,
const Scalar maximalStaticImagePointFilterRatio,
Vectors3* initialObjectPoints,
Indices32* initialObjectPointIds,
Indices32* initialPoseIds,
Scalar* initialPointDistance,
const RelativeThreshold* pointsThreshold,
const unsigned int minimalKeyFrames,
const unsigned int maximalKeyFrames,
const Scalar maximalSqrError,
Lock* lock,
bool* abort,
const unsigned int numberThreads,
const unsigned int threadIndex,
const unsigned int numberThreadsOne);
1621 static void determineInitialObjectPointsFromDenseFramesRANSACSubset(
const PinholeCamera* pinholeCamera,
const ImagePointGroups* imagePointGroups,
RandomGenerator* randomGenerator,
HomogenousMatrices4* validPoses,
Indices32* validPoseIds,
Vectors3* objectPoints,
Indices32* validObjectPointIndices,
Scalar* totalError,
const RelativeThreshold* minimalValidObjectPoints,
const Scalar maximalSqrError,
unsigned int* remainingIterations,
Lock* lock,
bool* abort,
unsigned int firstIteration,
unsigned int numberIterations);
1644 static void updatePosesSubset(
Database* database,
const AnyCamera* camera,
RandomGenerator* randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar ransacMaximalSqrError,
const Scalar maximalRobustError,
Scalar* totalError,
size_t* validPoses,
Lock* lock,
bool* abort,
const unsigned int numberThreads,
const unsigned int threadIndex,
const unsigned int numberThreadsOne);
1667 static void updateOrientationsSubset(
Database* database,
const AnyCamera* camera,
RandomGenerator* randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar ransacMaximalSqrError,
const Scalar maximalRobustError,
Scalar* totalError,
size_t* validPoses,
Lock* lock,
bool* abort,
const unsigned int numberThreads,
const unsigned int threadIndex,
const unsigned int numberThreadsOne);
1692 static void determinePosesSubset(
const Database* database,
const AnyCamera* camera,
const IndexSet32* priorityObjectPointIds,
const bool solePriorityPoints,
RandomGenerator* randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
ShiftVector<HomogenousMatrix4>* poses,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar ransacMaximalSqrError,
const Scalar maximalRobustError,
Scalar* totalError,
Lock* lock,
bool* abort,
const unsigned int numberThreads,
const unsigned int threadIndex,
const unsigned int numberThreadsOne);
1717 static void determineOrientationsSubset(
const Database* database,
const AnyCamera* camera,
const IndexSet32* priorityObjectPointIds,
const bool solePriorityPoints,
RandomGenerator* randomGenerator,
const unsigned int lowerFrame,
const unsigned int upperFrame,
const unsigned int minimalCorrespondences,
ShiftVector<HomogenousMatrix4>* poses,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar ransacMaximalSqrError,
const Scalar maximalRobustError,
Scalar* totalError,
Lock* lock,
bool* abort,
const unsigned int numberThreads,
const unsigned int threadIndex,
const unsigned int numberThreadsOne);
1749 static void determineUnknownObjectPointsSubset(
const AnyCamera* camera,
const Database* database,
const Database::PoseImagePointTopologyGroups* objectPointsData,
RandomGenerator* randomGenerator,
const Scalar maximalSqrError,
bool* abort,
Lock* lock,
Vectors3* newObjectPoints,
Indices32* newObjectPointIds,
unsigned int firstObjectPoint,
unsigned int numberObjectPoints);
1772 static void determineUnknownObjectPointsSubset(
const Database* database,
const AnyCamera* camera,
const CameraMotion cameraMotion,
const Index32* objectPointIds,
Vectors3* newObjectPoints,
Indices32* newObjectPointIds,
Indices32* newObjectPointObservations,
RandomGenerator* randomGenerator,
const unsigned int minimalObservations,
const bool useAllObservations,
const Geometry::Estimator::EstimatorType estimator,
const Scalar ransacMaximalSqrError,
const Scalar averageRobustError,
const Scalar maximalSqrError,
Lock* look,
bool* abort,
const unsigned int firstObjectPoint,
const unsigned int numberObjectPoints);
1791 static void optimizeObjectPointsWithFixedPosesSubset(
const Database* database,
const PinholeCamera* pinholeCamera,
const CameraMotion cameraMotion,
const Index32* objectPointIds,
Vectors3* optimizedObjectPoints,
Indices32* optimizedObjectPointIds,
const unsigned int minimalObservations,
const Geometry::Estimator::EstimatorType estimator,
const Scalar maximalRobustError,
Lock* look,
bool* abort,
const unsigned int firstObjectPoint,
const unsigned int numberObjectPoints);
1824 static void determineProjectionErrorsSubset(
const Database* database,
const PinholeCamera* pinholeCamera,
const Index32* objectPointIds,
const HomogenousMatrix4* posesIF,
const Index32 lowerPoseId,
const unsigned int upperPoseId,
const bool useDistortionParameters,
Scalar* minimalSqrErrors,
Scalar* averagedSqrErrors,
Scalar* maximalSqrErrors,
unsigned int* observations,
const unsigned int firstObjectPoint,
const unsigned int numberObjectPoints);
1836 thresholdLowerBoundary(lowerBoundary),
1837 thresholdFactor(factor),
1838 thresholdUpperBoundary(upperBoundary)
1845 return thresholdLowerBoundary;
1850 return thresholdFactor;
1855 return thresholdUpperBoundary;
1860 return min(minmax<unsigned int>(thresholdLowerBoundary, (
unsigned int)
Numeric::round32(
Scalar(value) * thresholdFactor), thresholdUpperBoundary), value);
1865 const unsigned int result = min(minmax<unsigned int>(thresholdLowerBoundary, (
unsigned int)
Numeric::round32(
Scalar(value) * thresholdFactor), thresholdUpperBoundary), value);
1867 if (value < thresholdLowerBoundary)
1870 ocean_assert(result <= value);
1871 ocean_assert(result >= thresholdLowerBoundary);
1872 ocean_assert(result <= thresholdUpperBoundary);
1875 *threshold = result;
1880 template <
unsigned int tLowerBoundary>
1883 const unsigned int result = min(minmax<unsigned int>(max(thresholdLowerBoundary, tLowerBoundary), (
unsigned int)
Numeric::round32(
Scalar(value) * thresholdFactor), thresholdUpperBoundary), value);
1885 if (value < tLowerBoundary || value < thresholdLowerBoundary)
1888 ocean_assert(result <= value);
1889 ocean_assert(result >= thresholdLowerBoundary);
1890 ocean_assert(result <= thresholdUpperBoundary);
1893 *threshold = result;
1899 PoseGroupsAccessor(accessor.elementGroups_)
1905 PoseGroupsAccessor(std::move(accessor.elementGroups_))
1912 PoseGroupsAccessor::operator=(accessor);
1918 PoseGroupsAccessor::operator=(std::move(accessor));
1923 ObjectPointGroupsAccessor(accessor.elementGroups_)
1929 ObjectPointGroupsAccessor(std::move(accessor.elementGroups_))
1936 elementGroups_.reserve(validGroupIndices.size());
1938 for (Indices32::const_iterator i = validGroupIndices.begin(); i != validGroupIndices.end(); ++i)
1940 ocean_assert(*i < accessor.elementGroups_.size());
1941 elementGroups_.emplace_back(std::move(accessor.elementGroups_[*i]));
1947 ObjectPointGroupsAccessor::operator=(accessor);
1953 ObjectPointGroupsAccessor::operator=(std::move(accessor));
1958 ObjectPointGroupsAccessor(accessor.elementGroups_)
1964 ObjectPointGroupsAccessor(std::move(accessor.elementGroups_))
1971 ObjectPointGroupsAccessor::operator=(accessor);
1977 ObjectPointGroupsAccessor::operator=(std::move(accessor));
1981 inline bool Solver3::determineUnknownObjectPoints(
const Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
Vectors3& newObjectPoints,
Indices32& newObjectPointIds,
RandomGenerator& randomGenerator,
Indices32* newObjectPointObservations,
const Scalar minimalObjectPointPriority,
const unsigned int minimalObservations,
const bool useAllObservations,
const Geometry::Estimator::EstimatorType estimator,
const Scalar ransacMaximalSqrError,
const Scalar averageRobustError,
const Scalar maximalSqrError,
Worker* worker,
bool* abort)
1987 return determineUnknownObjectPoints(database, camera, cameraMotion, invalidObjectPointIds, newObjectPoints, newObjectPointIds, randomGenerator, newObjectPointObservations, minimalObservations, useAllObservations, estimator, ransacMaximalSqrError, averageRobustError, maximalSqrError, worker, abort);
1990 template <
bool tVisibleInAllPoses>
1991 inline bool Solver3::determineUnknownObjectPoints(
const Database& database,
const AnyCamera& camera,
const CameraMotion cameraMotion,
const Index32 lowerPoseId,
const Index32 upperPoseId,
Vectors3& newObjectPoints,
Indices32& newObjectPointIds,
RandomGenerator& randomGenerator,
Indices32* newObjectPointObservations,
const Scalar minimalObjectPointPriority,
const unsigned int minimalObservations,
const bool useAllObservations,
const Geometry::Estimator::EstimatorType estimator,
const Scalar ransacMaximalSqrError,
const Scalar averageRobustError,
const Scalar maximalSqrError,
Worker* worker,
bool* abort)
1994 ocean_assert(lowerPoseId <= upperPoseId);
1998 return determineUnknownObjectPoints(database, camera, cameraMotion, invalidObjectPointIds, newObjectPoints, newObjectPointIds, randomGenerator, newObjectPointObservations, minimalObservations, useAllObservations, estimator, ransacMaximalSqrError, averageRobustError, maximalSqrError, worker, abort);
2001 inline HomogenousMatrix4 Solver3::determinePose(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const HomogenousMatrix4& roughPose,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar maximalSqrError,
Scalar* finalRobustError,
unsigned int* correspondences)
2003 ocean_assert(camera.
isValid());
2008 ocean_assert(imagePoints.size() == objectPoints.size());
2010 if (correspondences !=
nullptr)
2012 *correspondences = (
unsigned int)imagePoints.size();
2016 if (imagePoints.size() < minimalCorrespondences)
2024 inline HomogenousMatrix4 Solver3::determinePose(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const IndexSet32& priorityObjectPointIds,
const bool solePriorityPoints,
const HomogenousMatrix4& roughPose,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar maximalSqrError,
Scalar* finalRobustError,
unsigned int* correspondences)
2026 ocean_assert(camera.
isValid());
2028 ocean_assert(!priorityObjectPointIds.empty());
2030 Vectors2 priorityImagePoints, remainingImagePoints;
2031 Vectors3 priorityObjectPoints, remainingObjectPoints;
2033 ocean_assert(priorityImagePoints.size() == priorityObjectPoints.size());
2034 ocean_assert(remainingImagePoints.size() == remainingObjectPoints.size());
2036 if (solePriorityPoints)
2038 if (correspondences !=
nullptr)
2040 *correspondences = (
unsigned int)priorityImagePoints.size();
2043 if (priorityImagePoints.size() < minimalCorrespondences)
2052 if (correspondences !=
nullptr)
2054 *correspondences = (
unsigned int)(priorityImagePoints.size() + remainingImagePoints.size());
2058 if (priorityImagePoints.size() + remainingImagePoints.size() < minimalCorrespondences)
2063 const size_t priorityCorrespondences = priorityImagePoints.size();
2065 priorityImagePoints.insert(priorityImagePoints.end(), remainingImagePoints.begin(), remainingImagePoints.end());
2066 priorityObjectPoints.insert(priorityObjectPoints.end(), remainingObjectPoints.begin(), remainingObjectPoints.end());
2072 inline HomogenousMatrix4 Solver3::determinePose(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const ConstIndexedAccessor<ObjectPoint>& objectPoints,
const ConstIndexedAccessor<Index32>& objectPointIds,
const HomogenousMatrix4& roughPose,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar maximalSqrError,
Scalar* finalRobustError)
2078 ocean_assert(scopedObjectPointIdMemoryAccessor.
size() == validIndices.size());
2085 ocean_assert(camera.
isValid());
2086 ocean_assert(objectPoints.
size() == imagePoints.
size());
2087 ocean_assert(minimalValidCorrespondenceRatio >= 0 && minimalValidCorrespondenceRatio <= 1);
2094 if (!previousPose.
isValid() || minimalValidCorrespondenceRatio < 1)
2096 Geometry::RANSAC::p3p(camera, objectPoints, imagePoints, randomGenerator, previousPose, 5u,
true, 50u, maximalSqrError, &internalValidIndices);
2100 if (minimalValidCorrespondenceRatio < 1 &&
Scalar(internalValidIndices.size()) <
Scalar(objectPoints.
size()) * minimalValidCorrespondenceRatio && objectPoints.
size() - internalValidIndices.size() > 2)
2108 if (minimalValidCorrespondenceRatio < 1 && internalValidIndices.size() != objectPoints.
size())
2110 Geometry::NonLinearOptimizationPose::optimizePose(camera, previousPose,
ConstIndexedAccessorSubsetAccessor<Vector3, Index32>(objectPoints, internalValidIndices),
ConstIndexedAccessorSubsetAccessor<Vector2, Index32>(imagePoints, internalValidIndices),currentPose, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError);
2114 *validIndices = std::move(internalValidIndices);
2119 Geometry::NonLinearOptimizationPose::optimizePose(camera, previousPose, objectPoints, imagePoints, currentPose, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError);
2133 ocean_assert(camera.
isValid());
2134 ocean_assert(objectPoints.
size() == imagePoints.
size());
2135 ocean_assert(minimalValidCorrespondenceRatio >= 0 && minimalValidCorrespondenceRatio <= 1);
2142 if (!previousPose.
isValid() || minimalValidCorrespondenceRatio < 1)
2144 Geometry::RANSAC::p3p(camera, objectPoints, imagePoints, randomGenerator, previousPose, 5u,
true, 50u, maximalSqrError, &validIndices);
2148 if (minimalValidCorrespondenceRatio < 1 &&
Scalar(validIndices.size()) <
Scalar(objectPoints.
size()) * minimalValidCorrespondenceRatio && objectPoints.
size() - validIndices.size() > 2)
2159 const Scalar sigmaRemainingInvSqr(1 / (sigmaRemaining * sigmaRemaining));
2160 const SquareMatrix2 remainingInvertedCovariance(sigmaRemainingInvSqr, 0, 0, sigmaRemainingInvSqr);
2168 if (minimalValidCorrespondenceRatio < 1 && validIndices.size() != objectPoints.
size())
2170 Matrix invertedCovariances(validIndices.size(), 2);
2172 for (
size_t n = 0; n < validIndices.size(); ++n)
2174 const Index32 index = validIndices[n];
2176 if (index < priorityCorrespondences)
2178 priorityInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2182 remainingInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2186 Geometry::NonLinearOptimizationPose::optimizePose(camera, previousPose,
ConstIndexedAccessorSubsetAccessor<Vector3, Index32>(objectPoints, validIndices),
ConstIndexedAccessorSubsetAccessor<Vector2, Index32>(imagePoints, validIndices), currentPose, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError, &invertedCovariances);
2190 Matrix invertedCovariances(2 * objectPoints.
size(), 2);
2192 for (
size_t n = 0; n < priorityCorrespondences; ++n)
2194 priorityInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2197 for (
size_t n = priorityCorrespondences; n < objectPoints.
size(); ++n)
2199 remainingInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2202 Geometry::NonLinearOptimizationPose::optimizePose(camera, previousPose, objectPoints, imagePoints, currentPose, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError, &invertedCovariances);
2209 inline SquareMatrix3 Solver3::determineOrientation(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const SquareMatrix3& roughOrientation,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar maximalSqrError,
Scalar* finalRobustError,
unsigned int* correspondences)
2211 ocean_assert(camera.
isValid());
2216 ocean_assert(imagePoints.size() == objectPoints.size());
2218 if (correspondences !=
nullptr)
2220 *correspondences = (
unsigned int)imagePoints.size();
2224 if (imagePoints.size() < minimalCorrespondences)
2232 inline SquareMatrix3 Solver3::determineOrientation(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const IndexSet32& priorityObjectPointIds,
const bool solePriorityPoints,
const SquareMatrix3& roughOrientation,
const unsigned int minimalCorrespondences,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar maximalSqrError,
Scalar* finalRobustError,
unsigned int* correspondences)
2234 ocean_assert(camera.
isValid());
2235 ocean_assert(!priorityObjectPointIds.empty());
2237 Vectors2 priorityImagePoints, remainingImagePoints;
2238 Vectors3 priorityObjectPoints, remainingObjectPoints;
2240 ocean_assert(priorityImagePoints.size() == priorityObjectPoints.size());
2241 ocean_assert(remainingImagePoints.size() == remainingObjectPoints.size());
2243 if (solePriorityPoints)
2245 if (correspondences !=
nullptr)
2247 *correspondences = (
unsigned int)priorityImagePoints.size();
2251 if (priorityImagePoints.size() < minimalCorrespondences)
2260 if (correspondences !=
nullptr)
2262 *correspondences = (
unsigned int)(priorityImagePoints.size() + remainingImagePoints.size());
2266 if (priorityImagePoints.size() + remainingImagePoints.size() < minimalCorrespondences)
2271 const size_t priorityCorrespondences = priorityImagePoints.size();
2273 priorityImagePoints.insert(priorityImagePoints.end(), remainingImagePoints.begin(), remainingImagePoints.end());
2274 priorityObjectPoints.insert(priorityObjectPoints.end(), remainingObjectPoints.begin(), remainingObjectPoints.end());
2280 inline SquareMatrix3 Solver3::determineOrientation(
const Database& database,
const AnyCamera& camera,
RandomGenerator& randomGenerator,
const unsigned int frameId,
const ObjectPoint* objectPoints,
const Index32* objectPointIds,
const size_t numberObjectPoints,
const SquareMatrix3& roughOrientation,
const Geometry::Estimator::EstimatorType estimator,
const Scalar minimalValidCorrespondenceRatio,
const Scalar maximalSqrError,
Scalar* finalRobustError)
2282 ocean_assert(camera.
isValid());
2286 ocean_assert(numberObjectPoints == validIndices.size());
2293 ocean_assert(camera.
isValid());
2294 ocean_assert(objectPoints.
size() == imagePoints.
size());
2295 ocean_assert(minimalValidCorrespondenceRatio >= 0 && minimalValidCorrespondenceRatio <= 1);
2300 if (previousOrientation.
isNull() || minimalValidCorrespondenceRatio < 1)
2302 Geometry::RANSAC::orientation(camera, objectPoints, imagePoints, randomGenerator, previousOrientation, 5u, 50u, maximalSqrError,
nullptr, &internalValidIndices);
2306 if (minimalValidCorrespondenceRatio < 1 &&
Scalar(internalValidIndices.size()) <
Scalar(objectPoints.
size()) * minimalValidCorrespondenceRatio && objectPoints.
size() - internalValidIndices.size() > 2)
2312 if (!previousOrientation.
isNull())
2314 if (minimalValidCorrespondenceRatio < 1)
2316 Geometry::NonLinearOptimizationOrientation::optimizeOrientation(camera, previousOrientation,
ConstIndexedAccessorSubsetAccessor<Vector3, unsigned int>(objectPoints, internalValidIndices),
ConstIndexedAccessorSubsetAccessor<Vector2, unsigned int>(imagePoints, internalValidIndices), currentOrientation, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError);
2318 if (validIndices !=
nullptr)
2320 *validIndices = std::move(internalValidIndices);
2325 Geometry::NonLinearOptimizationOrientation::optimizeOrientation(camera, previousOrientation, objectPoints, imagePoints, currentOrientation, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError);
2327 if (validIndices !=
nullptr)
2334 return currentOrientation;
2339 ocean_assert(camera.
isValid());
2340 ocean_assert(objectPoints.
size() == imagePoints.
size());
2341 ocean_assert(minimalValidCorrespondenceRatio >= 0 && minimalValidCorrespondenceRatio <= 1);
2346 if (previousOrientation.
isNull() || minimalValidCorrespondenceRatio < 1)
2348 Geometry::RANSAC::orientation(camera, objectPoints, imagePoints, randomGenerator, previousOrientation, 5u, 50u, maximalSqrError,
nullptr, &validIndices);
2352 if (minimalValidCorrespondenceRatio < 1 &&
Scalar(validIndices.size()) <
Scalar(objectPoints.
size()) * minimalValidCorrespondenceRatio && objectPoints.
size() - validIndices.size() > 2)
2363 const Scalar sigmaRemainingInvSqr(1 / (sigmaRemaining * sigmaRemaining));
2364 const SquareMatrix2 remainingInvertedCovariance(sigmaRemainingInvSqr, 0, 0, sigmaRemainingInvSqr);
2370 if (!previousOrientation.
isNull())
2372 if (minimalValidCorrespondenceRatio < 1)
2377 subsetObjectPoints.reserve(validIndices.size());
2378 subsetImagePoints.reserve(validIndices.size());
2380 Matrix invertedCovariances(validIndices.size(), 2);
2382 for (
size_t n = 0; n < validIndices.size(); ++n)
2384 const Index32 index = validIndices[n];
2386 if (index < priorityCorrespondences)
2388 priorityInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2392 remainingInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2395 subsetObjectPoints.push_back(objectPoints[index]);
2396 subsetImagePoints.push_back(imagePoints[index]);
2399 Geometry::NonLinearOptimizationOrientation::optimizeOrientation(camera, previousOrientation,
ConstArrayAccessor<Vector3>(subsetObjectPoints),
ConstArrayAccessor<Vector2>(subsetImagePoints), currentOrientation, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError, &invertedCovariances);
2403 Matrix invertedCovariances(2 * objectPoints.
size(), 2);
2405 for (
size_t n = 0; n < priorityCorrespondences; ++n)
2407 priorityInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2410 for (
size_t n = priorityCorrespondences; n < objectPoints.
size(); ++n)
2412 remainingInvertedCovariance.
copyElements(invertedCovariances[2 * n],
false);
2415 Geometry::NonLinearOptimizationOrientation::optimizeOrientation(camera, previousOrientation, objectPoints, imagePoints, currentOrientation, 20u, estimator,
Scalar(0.001),
Scalar(5),
nullptr, finalRobustError, &invertedCovariances);
2419 return currentOrientation;
2424 ocean_assert(objectPoints.
size() >= 3);
2430 ocean_assert(objectPointIds.size() >= 3);
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
virtual bool isValid() const =0
Returns whether this camera is valid.
This class implement a sub-region either defined by 2D triangles or defined by a binary mask.
Definition: SubRegion.h:32
This class implements an accessor providing direct access to a constant array of elements.
Definition: Accessor.h:400
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition: Accessor.h:241
This class implements an indexed-based constant accessor providing access to a subset of elements sto...
Definition: Accessor.h:1356
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
@ ET_HUBER
The Huber estimator type.
Definition: Estimator.h:84
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
This class implements an abstract specialization of the accessor for groups of pairs for object point...
Definition: NonLinearOptimization.h:159
This class implements an abstract specialization of the accessor for groups of pairs for poses.
Definition: NonLinearOptimization.h:185
static bool optimizeOrientation(const AnyCamera &camera, const SquareMatrix3 &world_R_camera, const ConstIndexedAccessor< ObjectPoint > &objectPoints, const ConstIndexedAccessor< ImagePoint > &imagePoints, SquareMatrix3 &world_R_optimizedCamera, const unsigned int iterations, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
Minimizes the projection error of a given 3DOF orientation.
Definition: NonLinearOptimizationOrientation.h:134
static bool optimizePose(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &world_T_camera, const ConstIndexedAccessor< Vector3 > &objectPoints, const ConstIndexedAccessor< Vector2 > &imagePoints, const bool distortImagePoints, HomogenousMatrix4 &world_T_optimizedCamera, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Deprecated.
Definition: NonLinearOptimizationPose.h:282
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 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 SquareMatrix2 covarianceMatrix(const ImagePoint *imagePoints, const size_t number, const Scalar minimalSigma=0)
Creates the covariance matrix for a given set of image points.
Definition: geometry/Utilities.h:510
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
This class implements a recursive lock object.
Definition: Lock.h:31
static constexpr T deg2rad(const T deg)
Converts deg to rad.
Definition: Numeric.h:3232
static constexpr T minValue()
Returns the min scalar value.
Definition: Numeric.h:3250
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition: Numeric.h:2064
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
OptimizationStrategy
Definition of individual optimization strategies for camera parameters.
Definition: PinholeCamera.h:129
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements an accessor that guarantees memory access to the elements of an indexed accesso...
Definition: Accessor.h:1459
const T * data() const
Returns the pointer to the memory block providing the data of the accessor.
Definition: Accessor.h:2621
size_t size() const
Returns the number of elements the accessor provides.
Definition: Accessor.h:2629
This class implements a vector with shifted elements.
Definition: ShiftVector.h:27
This class implements a 2x2 square matrix.
Definition: SquareMatrix2.h:73
void copyElements(U *arrayValues, const bool columnAligned=true) const
Copies the elements of this matrix to an array with floating point values of type U.
Definition: SquareMatrix2.h:884
bool isNull() const
Returns whether this matrix is a zero matrix.
Definition: SquareMatrix3.h:1333
This class implements a database for 3D object points, 2D image points and 6DOF camera poses.
Definition: Database.h:67
std::vector< std::pair< Index32, PoseImagePointTopology > > PoseImagePointTopologyGroups
Definition of a vector holding several groups of pairs of pose and image point ids.
Definition: Database.h:250
Indices32 objectPointIds(Vectors3 *objectPoints=nullptr, Scalars *priorities=nullptr) const
Returns the ids of all object points that are part of this database.
Definition: Database.h:3829
std::vector< Vectors2 > ImagePointGroups
Definition of a vector holding 2D vectors.
Definition: Database.h:109
Vectors2 imagePointsFromObjectPoints(const Index32 poseId, Indices32 &objectPointIds, Indices32 *imagePointIds=nullptr) const
Returns all image points which are located in a specified frame and which are projections of a set of...
Definition: Database.h:4437
void imagePointsObjectPoints(const Index32 poseId, Vectors2 &imagePoints, Vectors3 &objectPoints, const Vector3 &referencePosition=invalidObjectPoint(), const size_t minimalObservations=0, Indices32 *imagePointIds=nullptr, Indices32 *objectPointIds=nullptr) const
Returns corresponding object points and image points for a given camera pose.
Definition: Database.h:4651
Vectors3 objectPoints() const
Returns the positions of all 3D object points.
Definition: Database.h:2379
This class implements an accessor for groups of pairs of pose indices (not pose ids) and image points...
Definition: Solver3.h:237
ObjectPointToPoseImagePointCorrespondenceAccessor(const ObjectPointToPoseImagePointCorrespondenceAccessor &accessor)
Copy constructor.
Definition: Solver3.h:1922
ObjectPointToPoseImagePointCorrespondenceAccessor(const Database &database, const Indices32 &poseIds, const Indices32 &objectPointCandidateIds, const unsigned int minimalObservationsInKeyframes=2u, Indices32 *validObjectPoints=nullptr)
Creates a new accessor object and extracts the necessary information from a given database.
ObjectPointToPoseImagePointCorrespondenceAccessor & operator=(const ObjectPointToPoseImagePointCorrespondenceAccessor &accessor)
Assign operator.
Definition: Solver3.h:1945
ObjectPointToPoseImagePointCorrespondenceAccessor(const Database &database, const Index32 lowerPoseId, const Index32 upperPoseId, const Indices32 &objectPointIds, const unsigned int minimalObservationsInKeyframes=2u, const unsigned int minimalKeyFrames=2u, Indices32 *usedKeyFrameIds=nullptr)
Creates a new accessor object and extracts the necessary information from a given database.
This class implements an accessor providing access to observation pairs (the observation of a project...
Definition: Solver3.h:331
ObjectPointToPoseIndexImagePointCorrespondenceAccessor(const ShiftVector< Vectors2 > &imagePointGroups, const Indices32 &posesSubsetBlock)
Creates a new accessor object.
ObjectPointToPoseIndexImagePointCorrespondenceAccessor(const std::vector< Vectors2 > &imagePointGroups, const Indices32 &posesSubsetBlock)
Creates a new accessor object.
ObjectPointToPoseIndexImagePointCorrespondenceAccessor(const std::vector< Vectors2 > &imagePointGroups, const Indices32 &posesSubsetBlock, const Indices32 &objectPointsSubset)
Creates a new accessor object.
ObjectPointToPoseIndexImagePointCorrespondenceAccessor & operator=(const ObjectPointToPoseIndexImagePointCorrespondenceAccessor &accessor)
Assign operator.
Definition: Solver3.h:1969
ObjectPointToPoseIndexImagePointCorrespondenceAccessor(const ObjectPointToPoseIndexImagePointCorrespondenceAccessor &accessor)
Copy constructor.
Definition: Solver3.h:1957
ObjectPointToPoseIndexImagePointCorrespondenceAccessor(const ShiftVector< Vectors2 > &imagePointGroups, const Indices32 &posesSubsetBlock, const Indices32 &objectPointsSubset)
Creates a new accessor object.
This class implements an accessor for groups of pairs of object point ids and image points.
Definition: Solver3.h:177
PoseToObjectPointIdImagePointCorrespondenceAccessor & operator=(const PoseToObjectPointIdImagePointCorrespondenceAccessor &accessor)
Assign operator.
Definition: Solver3.h:1910
PoseToObjectPointIdImagePointCorrespondenceAccessor(const PoseToObjectPointIdImagePointCorrespondenceAccessor &accessor)
Copy constructor.
Definition: Solver3.h:1898
PoseToObjectPointIdImagePointCorrespondenceAccessor(const Database &database, const Indices32 &poseIds, const Indices32 &objectPointIds, const unsigned int minimalVisibleObjectPoints=10u, Indices32 *validPoseIndices=nullptr, Indices32 *usedObjectPointIndices=nullptr)
Creates a new accessor object and extracts the necessary information from a given database.
Definition of a class allowing to define a relative threshold with lower and upper boundary for indiv...
Definition: Solver3.h:93
bool hasValidThreshold(const unsigned int value, unsigned int *threshold=nullptr) const
Returns whether for a given reference value a valid relative threshold can be determined.
Definition: Solver3.h:1863
RelativeThreshold(const unsigned int lowerBoundary, const Scalar factor, const unsigned int upperBoundary)
Creates a new threshold object.
Definition: Solver3.h:1835
unsigned int thresholdUpperBoundary
The upper boundary of the relative threshold.
Definition: Solver3.h:156
Scalar factor() const
Returns the factor of this object.
Definition: Solver3.h:1848
Scalar thresholdFactor
The factor defining the relative threshold.
Definition: Solver3.h:153
unsigned int threshold(const unsigned int value) const
Returns the relative threshold for a given reference value.
Definition: Solver3.h:1858
unsigned int upperBoundary() const
Returns the upper boundary of this object.
Definition: Solver3.h:1853
unsigned int lowerBoundary() const
Returns the lower boundary of this object.
Definition: Solver3.h:1843
unsigned int thresholdLowerBoundary
The lower boundary of the relative threshold.
Definition: Solver3.h:150
This class implements a Structure From Motion solver for unconstrained 3D object points and unconstra...
Definition: Solver3.h:42
static std::string translateCameraMotion(const CameraMotion cameraMotion)
Translates a camera motion value to a string providing the detailed motion as readable string.
static bool determinePerpendicularPlane(const Database &database, const PinholeCamera &pinholeCamera, const unsigned int frameIndex, const Vector2 &imagePoint, const Scalar distance, Plane3 &plane, const bool useDistortionParameters, Vector3 *pointOnPlane=nullptr)
Determines a 3D plane perpendicular to the camera with specified distance to the camera.
static void determineProjectionErrorsSubset(const Database *database, const PinholeCamera *pinholeCamera, const Index32 *objectPointIds, const HomogenousMatrix4 *posesIF, const Index32 lowerPoseId, const unsigned int upperPoseId, const bool useDistortionParameters, Scalar *minimalSqrErrors, Scalar *averagedSqrErrors, Scalar *maximalSqrErrors, unsigned int *observations, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints)
Determines the maximal squared pixel errors between the projections of a subset of individual 3D obje...
static Indices32 determineRepresentativePoses(const Database &database, const Indices32 &poseIds, const size_t numberRepresentative)
Determines a set of representative camera poses from a given database from a set of given camera pose...
static HomogenousMatrix4 determinePose(const Database &database, const AnyCamera &camera, RandomGenerator &randomGenerator, const unsigned int frameId, const HomogenousMatrix4 &roughPose=HomogenousMatrix4(false), const unsigned int minimalCorrespondences=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar minimalValidCorrespondenceRatio=Scalar(1), const Scalar maximalSqrError=Scalar(3.5 *3.5), Scalar *finalRobustError=nullptr, unsigned int *correspondences=nullptr)
Determines the camera 6-DOF pose for a specific camera frame.
Definition: Solver3.h:2001
static bool updateDatabaseToRotationalMotion(Database &database, const PinholeCamera &pinholeCamera, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalObservations, IndexSet32 *relocatedObjectPointIds)
Determines the semi-precise location of 3D object points and the camera poses for a sole rotational c...
static size_t filterStaticImagePoints(ImagePointGroups &imagePointGroups, Indices32 &objectPointIds, const Scalar maximalStaticImagePointFilterRatio)
Determines a subset of perfectly static image points which may be image points located (visible) at s...
std::pair< Index32, Scalar > PoseErrorPair
Definition of a pair combining a pose id and an error parameter.
Definition: Solver3.h:394
static Scalar determineObjectPointAccuracy(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 *poses, const Vector2 *imagePoints, const size_t observations, const AccuracyMethod accuracyMethod)
Measures the accuracy of a 3D object point in combination with a set of camera poses and image points...
static CameraMotion determineCameraMotion(const Database &database, const PinholeCamera &pinholeCamera, const unsigned int lowerFrame, const unsigned int upperFrame, const bool onlyVisibleObjectPoints=true, Worker *worker=nullptr, const Scalar minimalTinyTranslationObservationAngle=Numeric::deg2rad(Scalar(0.15)), const Scalar minimalModerateTranslationObservationAngle=Numeric::deg2rad(1), const Scalar minimalSignificantTranslationObservationAngle=Numeric::deg2rad(5), const Scalar minimalTinyRotationAngle=Numeric::deg2rad(Scalar(0.25)), const Scalar minimalModerateRotationAngle=Numeric::deg2rad(5), const Scalar minimalSignificantRotationAngle=Numeric::deg2rad(10))
Determines the camera motion from the camera poses within a specified frame range covering only valid...
static bool determineUnknownObjectPoints(const Database &database, const AnyCamera &camera, const CameraMotion cameraMotion, const Indices32 &unknownObjectPointIds, Vectors3 &newObjectPoints, Indices32 &newObjectPointIds, RandomGenerator &randomGenerator, Indices32 *newObjectPointObservations=nullptr, const unsigned int minimalObservations=2u, const bool useAllObservations=true, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar ransacMaximalSqrError=Scalar(3.5 *3.5), const Scalar averageRobustError=Scalar(3.5 *3.5), const Scalar maximalSqrError=Numeric::maxValue(), Worker *worker=nullptr, bool *abort=nullptr)
Determines the positions of a set of (currently unknown) object points.
static bool determineInitialObjectPointsFromSparseKeyFramesBySteps(const Database &database, const unsigned int steps, const PinholeCamera &pinholeCamera, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const Scalar maximalStaticImagePointFilterRatio, Vectors3 &initialObjectPoints, Indices32 &initialObjectPointIds, const RelativeThreshold &pointsThreshold=RelativeThreshold(20u, Scalar(0.5), 100u), const unsigned int minimalKeyFrames=2u, const unsigned int maximalKeyFrames=10u, const Scalar maximalSqrError=Scalar(3.5 *3.5), Indices32 *usedPoseIds=nullptr, Worker *worker=nullptr, bool *abort=nullptr)
Determines the initial positions of 3D object points in a database if no camera poses or structure in...
static bool optimizeObjectPointsWithVariablePoses(const Database &database, const PinholeCamera &pinholeCamera, const Index32 lowerPoseId, const Index32 upperPoseId, const Indices32 &objectPointIds, Indices32 &usedKeyFrameIds, Vectors3 &optimizedObjectPoints, const unsigned int minimalObservations=10u, const unsigned int minimalKeyFrames=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
static size_t removeObjectPointsNotInFrontOfCamera(Database &database, Indices32 *removedObjectPointIds=nullptr)
Removes all valid 3D object points (and their corresponding 2D image points) from the database which ...
static bool determineProjectionErrors(const Database &database, const PinholeCamera &pinholeCamera, const Indices32 &objectPointIds, const bool useDistortionParameters, const unsigned int lowerFrame=(unsigned int)(-1), const unsigned int upperFrame=(unsigned int)(-1), Scalar *minimalSqrErrors=nullptr, Scalar *averagedSqrErrors=nullptr, Scalar *maximalSqrErrors=nullptr, unsigned int *observations=nullptr, Worker *worker=nullptr)
Determines the averaged and maximal squared pixel errors between the projections of individual 3D obj...
static bool determinePlane(const Database &database, const PinholeCamera &pinholeCamera, const unsigned int lowerFrameIndex, const unsigned int subRegionFrameIndex, const unsigned int upperFrameIndex, const CV::SubRegion &subRegion, RandomGenerator &randomGenerator, Plane3 &plane, const bool useDistortionParameters, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(3u, Scalar(0.5), 20u), const Scalar medianDistanceFactor=Scalar(6), const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_HUBER, Scalar *finalError=nullptr, Indices32 *usedObjectPointIds=nullptr)
Determines a 3D plane best fitting to image points in a specified sub-region in a specified frame and...
static size_t removeObjectPointsWithoutEnoughObservations(Database &database, const size_t minimalNumberObservations, Indices32 *removedObjectPointIds=nullptr)
Removes any 3D object point (and it's corresponding 2D image points) from the database with less then...
static bool determineInitialObjectPointsFromDenseFrames(const Database &database, const PinholeCamera &pinholeCamera, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame, const CV::SubRegion ®ionOfInterest, const Scalar maximalStaticImagePointFilterRatio, Vectors3 &initialObjectPoints, Indices32 &initialObjectPointIds, const RelativeThreshold &pointsThreshold=RelativeThreshold(20u, Scalar(0.5), 100u), const Scalar minimalTrackedFramesRatio=Scalar(0.1), const unsigned int minimalKeyFrames=3u, const unsigned int maximalKeyFrames=10u, const Scalar maximalSqrError=Scalar(3.5 *3.5), Indices32 *usedPoseIds=nullptr, Scalar *finalSqrError=nullptr, bool *abort=nullptr)
Determines the initial positions of 3D object points in a database if no camera poses or structure in...
static bool optimizeObjectPointsWithVariablePoses(const Database &database, const PinholeCamera &pinholeCamera, Vectors3 &optimizedObjectPoints, Indices32 &optimizedObjectPointIds, HomogenousMatrices4 *optimizedKeyFramePoses=nullptr, Indices32 *optimizedKeyFramePoseIds=nullptr, const unsigned int minimalKeyFrames=3u, const unsigned int maximalKeyFrames=20u, const unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
Optimizes 3D object points (having a quite good accuracy already) and optimizes the camera poses conc...
static void determinePosesOrientation(const Database &database, const unsigned int lowerFrame, const unsigned int upperFrame, Scalar *xOrientations, Scalar *yOrientations, Scalar *zOrientations)
Determines the individual cosine values between the mean coordinate axis of a range of poses and the ...
static void determineProjectionErrors(const AnyCamera &camera, const Vector3 &objectPoint, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector2 > &imagePoints, Scalar *minimalSqrError=nullptr, Scalar *averageSqrError=nullptr, Scalar *maximalSqrError=nullptr)
Determines the projection errors of a 3D object point in combination with a set of camera poses and i...
static bool determinePoses(const Database &database, const AnyCamera &camera, const CameraMotion cameraMotion, const IndexSet32 &priorityObjectPointIds, const bool solePriorityPoints, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, ShiftVector< HomogenousMatrix4 > &poses, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar minimalValidCorrespondenceRatio=Scalar(1), const Scalar ransacMaximalSqrError=Scalar(3.5 *3.5), const Scalar maximalRobustError=Scalar(3.5 *3.5), Scalar *finalAverageError=nullptr, Worker *worker=nullptr, bool *abort=nullptr)
Determines the camera poses depending on valid 2D/3D points correspondence within a range of camera f...
static Indices32 trackObjectPointsToNeighborFrames(const Database &database, const Indices32 &objectPointIds, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame)
This function tracks a group of object points from one frame to both (if available) neighbor frames a...
static bool optimizeCamera(const Database &database, const PinholeCamera &pinholeCamera, const unsigned int lowerFrame, const unsigned int upperFrame, const bool findInitialFieldOfView, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, Database &optimizedDatabase, const unsigned int minimalObservationsInKeyframes=2u, const unsigned int minimalKeyframes=3u, const unsigned int maximalKeyframes=20u, const Scalar lowerFovX=Numeric::deg2rad(20), const Scalar upperFovX=Numeric::deg2rad(140), Worker *worker=nullptr, bool *abort=nullptr, Scalar *finalMeanSqrError=nullptr)
Optimizes the camera profile for a given database with stable camera poses determined by initial but ...
static bool determineInitialObjectPointsFromSparseKeyFramesRANSAC(const PinholeCamera &pinholeCamera, const Database::ImagePointGroups &imagePointGroups, RandomGenerator &randomGenerator, HomogenousMatrices4 &validPoses, Indices32 &validPoseIndices, Vectors3 &objectPoints, Indices32 &validObjectPointIndices, const unsigned int iterations=20u, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(10u, Scalar(0.3), 20u), const Scalar maximalSqrError=Scalar(3.5 *3.5), const Database *database=nullptr, const Indices32 *keyFrameIds=nullptr, const Indices32 *objectPointIds=nullptr, bool *abort=nullptr)
Determines the initial object point positions for a set of key frames (image point groups) observing ...
static bool determineNumberCorrespondences(const Database &database, const bool needValidPose, const unsigned int lowerFrame, const unsigned int upperFrame, unsigned int *minimalCorrespondences=nullptr, Scalar *averageCorrespondences=nullptr, unsigned int *medianCorrespondences=nullptr, unsigned int *maximalCorrespondences=nullptr, Worker *worker=nullptr)
Determines the number of valid correspondences between image points and object points for each frame ...
std::vector< PoseErrorPair > PoseErrorPairs
Definition of a vector holding pose error pairs.
Definition: Solver3.h:399
std::map< unsigned int, unsigned int > IndexMap32
Definition of a map mapping 32 bit indices to 32 bit indices.
Definition: Solver3.h:308
static bool optimizeCameraWithVariableObjectPointsAndPoses(const Database &database, const PinholeCamera &pinholeCamera, const PinholeCamera::OptimizationStrategy optimizationStrategy, const Indices32 &keyFrameIds, const Indices32 &objectPointIds, PinholeCamera &optimizedCamera, Vectors3 *optimizedObjectPoints=nullptr, Indices32 *optimizedObjectPointIds=nullptr, HomogenousMatrices4 *optimizedKeyFramePoses=nullptr, const unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
Optimizes 3D object points (having a quite good accuracy already) and optimizes the camera poses and ...
static void determineInitialObjectPointsFromSparseKeyFramesByStepsSubset(const Database *database, const PinholeCamera *pinholeCamera, RandomGenerator *randomGenerator, const unsigned int lowerFrame, const Indices32 *startFrames, const unsigned int upperFrame, const Scalar maximalStaticImagePointFilterRatio, Vectors3 *initialObjectPoints, Indices32 *initialObjectPointIds, Indices32 *initialPoseIds, Scalar *initialPointDistance, const RelativeThreshold *pointsThreshold, const unsigned int minimalKeyFrames, const unsigned int maximalKeyFrames, const Scalar maximalSqrError, Lock *lock, bool *abort, const unsigned int numberThreads, const unsigned int threadIndex, const unsigned int numberThreadsOne)
Determines the initial positions of 3D object points in a database if no camera poses or structure in...
static bool determinePerpendicularPlane(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &pose, const Vector2 &imagePoint, const Scalar distance, Plane3 &plane, const bool useDistortionParameters, Vector3 *pointOnPlane=nullptr)
Determines a 3D plane perpendicular to the camera with specified distance to the camera.
static void determineUnknownObjectPointsSubset(const AnyCamera *camera, const Database *database, const Database::PoseImagePointTopologyGroups *objectPointsData, RandomGenerator *randomGenerator, const Scalar maximalSqrError, bool *abort, Lock *lock, Vectors3 *newObjectPoints, Indices32 *newObjectPointIds, unsigned int firstObjectPoint, unsigned int numberObjectPoints)
Determines the positions of new object points from a database within a specified frame range.
static void determineObjectPointsAccuracySubset(const Database *database, const PinholeCamera *pinholeCamera, const Index32 *objectPointIds, const AccuracyMethod accuracyMethhod, const unsigned int lowerFrame, const unsigned int upperFrame, Scalar *values, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints)
Measures the accuracy of a subset of several 3D object points.
static bool optimizeObjectPointsWithFixedPoses(const Database &database, const PinholeCamera &pinholeCamera, const CameraMotion cameraMotion, const Indices32 &objectPointIds, Vectors3 &optimizedObjectPoints, Indices32 &optimizedObjectPointIds, unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar maximalRobustError=Scalar(3.5 *3.5), Worker *worker=nullptr, bool *abort=nullptr)
Optimizes a set of 3D object points (having a quite good accuracy already) without optimizing the cam...
static bool optimizeCameraWithVariableObjectPointsAndPoses(const Database &database, const PinholeCamera &pinholeCamera, const PinholeCamera::OptimizationStrategy optimizationStrategy, const Indices32 &keyFrameIds, PinholeCamera &optimizedCamera, Vectors3 *optimizedObjectPoints=nullptr, Indices32 *optimizedObjectPointIds=nullptr, HomogenousMatrices4 *optimizedKeyFramePoses=nullptr, const unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
Optimizes 3D object points (having a quite good accuracy already) and optimizes the camera poses and ...
CameraMotion
Definition of individual camera motion types.
Definition: Solver3.h:49
@ CM_INVALID
Invalid camera motion.
Definition: Solver3.h:51
static bool determineInitialObjectPointsFromSparseKeyFrames(const Database &database, const PinholeCamera &pinholeCamera, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame, const Scalar maximalStaticImagePointFilterRatio, Vectors3 &initialObjectPoints, Indices32 &initialObjectPointIds, const RelativeThreshold &pointsThreshold=RelativeThreshold(20u, Scalar(0.5), 100u), const unsigned int minimalKeyFrames=3u, const unsigned int maximalKeyFrames=10u, const Scalar maximalSqrError=Scalar(3.5 *3.5), Indices32 *usedPoseIds=nullptr, Scalar *finalSqrError=nullptr, Scalar *finalImagePointDistance=nullptr, bool *abort=nullptr)
Determines the initial positions of 3D object points in a database if no camera poses or structure in...
static void determineUnknownObjectPointsSubset(const Database *database, const AnyCamera *camera, const CameraMotion cameraMotion, const Index32 *objectPointIds, Vectors3 *newObjectPoints, Indices32 *newObjectPointIds, Indices32 *newObjectPointObservations, RandomGenerator *randomGenerator, const unsigned int minimalObservations, const bool useAllObservations, const Geometry::Estimator::EstimatorType estimator, const Scalar ransacMaximalSqrError, const Scalar averageRobustError, const Scalar maximalSqrError, Lock *look, bool *abort, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints)
Determines the positions of a subset of (currently unknown) object points.
static bool optimizeObjectPointsWithVariablePoses(const Database &database, const PinholeCamera &pinholeCamera, const Indices32 &keyFrameIds, const Indices32 &objectPointIds, Vectors3 &optimizedObjectPoints, Indices32 &optimizedObjectPointIds, HomogenousMatrices4 *optimizedKeyFramePoses=nullptr, const unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
Optimizes 3D object points (having a quite good accuracy already) and optimizes the camera poses conc...
static bool optimizeObjectPointsWithVariablePoses(const Database &database, const PinholeCamera &pinholeCamera, const Indices32 &keyFrameIds, Vectors3 &optimizedObjectPoints, Indices32 &optimizedObjectPointIds, HomogenousMatrices4 *optimizedKeyFramePoses=nullptr, const unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
Optimizes 3D object points (having a quite good accuracy already) and optimizes the camera poses conc...
static void optimizeObjectPointsWithFixedPosesSubset(const Database *database, const PinholeCamera *pinholeCamera, const CameraMotion cameraMotion, const Index32 *objectPointIds, Vectors3 *optimizedObjectPoints, Indices32 *optimizedObjectPointIds, const unsigned int minimalObservations, const Geometry::Estimator::EstimatorType estimator, const Scalar maximalRobustError, Lock *look, bool *abort, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints)
Optimizes a subset of a set of 3D object points which have a quite good accuracy already without opti...
static size_t removeObjectPointsWithSmallBaseline(Database &database, const Scalar minimalBoxDiagonal, Indices32 *removedObjectPointIds=nullptr)
Removes any 3D object point (and it's corresponding 2D image points) from the database if all their c...
static void updatePosesSubset(Database *database, const AnyCamera *camera, RandomGenerator *randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, const Geometry::Estimator::EstimatorType estimator, const Scalar minimalValidCorrespondenceRatio, const Scalar ransacMaximalSqrError, const Scalar maximalRobustError, Scalar *totalError, size_t *validPoses, Lock *lock, bool *abort, const unsigned int numberThreads, const unsigned int threadIndex, const unsigned int numberThreadsOne)
Updates a subset of the camera poses depending on valid 2D/3D points correspondences within a range o...
static void updateOrientationsSubset(Database *database, const AnyCamera *camera, RandomGenerator *randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, const Geometry::Estimator::EstimatorType estimator, const Scalar minimalValidCorrespondenceRatio, const Scalar ransacMaximalSqrError, const Scalar maximalRobustError, Scalar *totalError, size_t *validPoses, Lock *lock, bool *abort, const unsigned int numberThreads, const unsigned int threadIndex, const unsigned int numberThreadsOne)
Updates a subset of the camera orientations (as the camera has rotational motion only) depending on v...
static bool updatePoses(Database &database, const AnyCamera &camera, const CameraMotion cameraMotion, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar minimalValidCorrespondenceRatio=Scalar(1), const Scalar ransacMaximalSqrError=Scalar(3.5 *3.5), const Scalar maximalRobustError=Scalar(3.5 *3.5), Scalar *finalAverageError=nullptr, size_t *validPoses=nullptr, bool *abort=nullptr)
Updates the camera poses of the database depending on valid 2D/3D points correspondences within a ran...
static bool supposeRotationalCameraMotion(const Database &database, const PinholeCamera &pinholeCamera, const unsigned int lowerFrame, const unsigned int upperFrame, const bool findInitialFieldOfView, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, Database &optimizedDatabase, const unsigned int minimalObservations=0u, const unsigned int minimalKeyframes=3u, const unsigned int maximalKeyframes=20u, const Scalar lowerFovX=Numeric::deg2rad(20), const Scalar upperFovX=Numeric::deg2rad(140), const Scalar maximalSqrError=(1.5 *1.5), Worker *worker=nullptr, bool *abort=nullptr, Scalar *finalMeanSqrError=nullptr)
Supposes pure rotational camera motion for a given database with stable camera poses determined by in...
static bool removeSparseObjectPoints(Database &database, const Scalar minimalBoundingBoxDiagonal=Scalar(1e+7), const Scalar medianFactor=Scalar(100), const Scalar maximalSparseObjectPointRatio=Scalar(0.05))
Removes very far object points from the database if the amount of object points does not exceed a spe...
static void determineInitialObjectPointsFromDenseFramesRANSACSubset(const PinholeCamera *pinholeCamera, const ImagePointGroups *imagePointGroups, RandomGenerator *randomGenerator, HomogenousMatrices4 *validPoses, Indices32 *validPoseIds, Vectors3 *objectPoints, Indices32 *validObjectPointIndices, Scalar *totalError, const RelativeThreshold *minimalValidObjectPoints, const Scalar maximalSqrError, unsigned int *remainingIterations, Lock *lock, bool *abort, unsigned int firstIteration, unsigned int numberIterations)
Determines the initial object point positions for a set of frames (image point groups) observing the ...
static void determineOrientationsSubset(const Database *database, const AnyCamera *camera, const IndexSet32 *priorityObjectPointIds, const bool solePriorityPoints, RandomGenerator *randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, ShiftVector< HomogenousMatrix4 > *poses, const Geometry::Estimator::EstimatorType estimator, const Scalar minimalValidCorrespondenceRatio, const Scalar ransacMaximalSqrError, const Scalar maximalRobustError, Scalar *totalError, Lock *lock, bool *abort, const unsigned int numberThreads, const unsigned int threadIndex, const unsigned int numberThreadsOne)
Determines a subset of the camera orientations (as the camera has rotational motion only) depending o...
static size_t determineValidPoses(const AnyCamera &camera, const Vectors3 &objectPoints, const ImagePointGroups &imagePointGroups, RandomGenerator &randomGenerator, const CameraMotion cameraMotion, const unsigned int firstValidPoseIndex, const HomogenousMatrix4 &firstValidPose, const unsigned int secondValidPoseIndex, const HomogenousMatrix4 &secondValidPose, const Scalar minimalValidCorrespondenceRatio=Scalar(1), const Scalar maximalSqrError=Scalar(3.5 *3.5), Indices32 *validObjectPointIndices=nullptr, HomogenousMatrices4 *poses=nullptr, Indices32 *poseIds=nullptr, Scalar *totalSqrError=nullptr)
Determines valid poses for a range of camera frames while for each frame a group of image points is g...
ShiftVector< Vectors2 > ImagePointGroups
Definition of a shift vector holding groups of image points.
Definition: Solver3.h:313
static Indices32 determineRepresentativePoses(const Database &database, const unsigned int lowerFrame, const unsigned int upperFrame, const size_t numberRepresentative)
Determines a set of representative camera poses from a given database within a specified frame range.
static bool optimizeInitialObjectPoints(const Database &database, const AnyCamera &camera, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame, const Vectors3 &initialObjectPoints, const Indices32 &initialObjectPointIds, Vectors3 &optimizedObjectPoints, Indices32 &optimizedObjectPointIds, const unsigned int minimalObjectPoints=5u, const unsigned int minimalKeyFrames=3u, const unsigned int maximalKeyFrames=10u, const Scalar maximalSqrError=Scalar(3.5 *3.5), Indices32 *usedPoseIds=nullptr, Scalar *initialSqrError=nullptr, Scalar *finalSqrError=nullptr, bool *abort=nullptr)
Optimizes the positions of already known initial 3D object points when a given database holds neither...
static bool updatePoses(Database &database, const AnyCamera &camera, const CameraMotion cameraMotion, RandomGenerator &randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar minimalValidCorrespondenceRatio=Scalar(1), const Scalar ransacMaximalSqrError=Scalar(3.5 *3.5), const Scalar maximalRobustError=Scalar(3.5 *3.5), Scalar *finalAverageError=nullptr, size_t *validPoses=nullptr, Worker *worker=nullptr, bool *abort=nullptr)
Updates the camera poses of the database depending on valid 2D/3D points correspondences within a ran...
static SquareMatrix3 determineOrientation(const Database &database, const AnyCamera &camera, RandomGenerator &randomGenerator, const unsigned int frameId, const SquareMatrix3 &roughOrientation=SquareMatrix3(false), const unsigned int minimalCorrespondences=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar minimalValidCorrespondenceRatio=Scalar(1), const Scalar maximalSqrError=Scalar(3.5 *3.5), Scalar *finalRobustError=nullptr, unsigned int *correspondences=nullptr)
Determines the camera 3-DOF orientation (as the camera has rotational motion only) for a specific cam...
Definition: Solver3.h:2209
static bool determineInitialObjectPointsFromDenseFramesRANSAC(const PinholeCamera &pinholeCamera, const ImagePointGroups &imagePointGroups, RandomGenerator &randomGenerator, HomogenousMatrices4 &validPoses, Indices32 &validPoseIds, Vectors3 &objectPoints, Indices32 &validObjectPointIndices, const unsigned int iterations=20u, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(10u, Scalar(0.3), 20u), const Scalar maximalSqrError=Scalar(3.5 *3.5), Worker *worker=nullptr, bool *abort=nullptr)
Determines the initial object point positions for a set of frames (image point groups) observing the ...
static bool determinePlane(const ConstIndexedAccessor< Vector3 > &objectPoints, RandomGenerator &randomGenerator, Plane3 &plane, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(3u, Scalar(0.5), 20u), const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_HUBER, Scalar *finalError=nullptr, Indices32 *validIndices=nullptr)
Determines a 3D plane best fitting to a set of given 3D object points.
Definition: Solver3.h:2422
static bool determineUnknownObjectPoints(const Database &database, const AnyCamera &camera, const unsigned int lowerFrame, const unsigned int upperFrame, Vectors3 &newObjectPoints, Indices32 &newObjectPointIds, const unsigned int minimalKeyFrames=3u, const unsigned int maximalKeyFrames=10u, const Scalar maximalSqrError=Scalar(3.5 *3.5), Worker *worker=nullptr, bool *abort=nullptr)
Determines the positions of new object points from a database within a specified frame range.
AccuracyMethod
Definition of individual methods to determine the accuracy of object points.
Definition: Solver3.h:78
@ AM_INVALID
Invalid method.
Definition: Solver3.h:80
@ AM_MEAN_DIRECTION_MEAN_COSINE
Determination of the mean absolute cosine value between the mean observation direction and each obser...
Definition: Solver3.h:84
@ AM_MEAN_DIRECTION_MIN_COSINE
Determination of the minimal absolute cosine values between the mean observation direction and each o...
Definition: Solver3.h:82
static Scalars determineObjectPointsAccuracy(const Database &database, const PinholeCamera &pinholeCamera, const Indices32 &objectPointIds, const AccuracyMethod accuracyMethhod, const unsigned int lowerFrame=(unsigned int)(-1), const unsigned int upperFrame=(unsigned int)(-1), Worker *worker=nullptr)
Measures the accuracy of several 3D object points.
static bool optimizeCameraWithVariableObjectPointsAndPoses(const Database &database, const PinholeCamera &pinholeCamera, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, Vectors3 *optimizedObjectPoints=nullptr, Indices32 *optimizedObjectPointIds=nullptr, HomogenousMatrices4 *optimizedKeyFramePoses=nullptr, Indices32 *optimizedKeyFramePoseIds=nullptr, const unsigned int minimalKeyFrames=3u, const unsigned int maximalKeyFrames=20u, const unsigned int minimalObservations=10u, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const unsigned int iterations=50u, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr)
Optimizes 3D object points (having a quite good accuracy already) and optimizes the camera poses and ...
static bool determineInitialObjectPointsFromDenseFrames(const PinholeCamera &pinholeCamera, const ImagePointGroups &imagePointGroups, RandomGenerator &randomGenerator, const unsigned int firstGroupIndex, const unsigned int secondGroupIndex, HomogenousMatrices4 &validPoses, Indices32 &validPoseIds, Scalar &totalSqrError, Vectors3 &objectPoints, Indices32 &validObjectPointIndices, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(10u, Scalar(0.3), 20u), const Scalar maximalSqrError=Scalar(3.5 *3.5))
Determines the initial object point positions for a set of image point groups (covering a range of im...
static bool determineInitialObjectPointsFromSparseKeyFrames(const PinholeCamera &pinholeCamera, const Database::ImagePointGroups &imagePointGroups, RandomGenerator &randomGenerator, const unsigned int firstGroupIndex, const unsigned int secondGroupIndex, HomogenousMatrices4 &poses, Indices32 &validPoseIndices, Vectors3 &objectPoints, Indices32 &validObjectPointIndices, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(10u, Scalar(0.3), 20u), const Scalar maximalSqrError=Scalar(3.5 *3.5))
Determines the initial object point positions for a set of key frames (image point groups) observing ...
static bool trackObjectPoints(const Database &database, const Indices32 &priorityObjectPointIds, const Indices32 &remainingObjectPointIds, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame, const unsigned int minimalTrackedPriorityObjectPoints, const Scalar minimalRemainingFramesRatio, const unsigned int maximalTrackedPriorityObjectPoints, const unsigned int maximalTrackedRemainingObjectPoints, Indices32 &trackedObjectPointIds, ImagePointGroups &trackedImagePointGroups, Indices32 *trackedValidPriorityIndices=nullptr, Indices32 *trackedValidRemainingIndices=nullptr, bool *abort=nullptr)
This functions tracks two individual groups (disjoined) image points (defined by their object points)...
static bool determineProjectionError(const Database &database, const PinholeCamera &pinholeCamera, const Index32 poseId, const bool useDistortionParameters, unsigned int *validCorrespondences=nullptr, Scalar *minimalSqrError=nullptr, Scalar *averageSqrError=nullptr, Scalar *maximalSqrError=nullptr)
Determines the accuracy of a camera pose for all valid object points visible in the frame by measurin...
static Scalar averagePointDistance(const Vector2 *points, const size_t size)
Determines the average distance between the center of a set of given points and each of the points.
static void determinePosesSubset(const Database *database, const AnyCamera *camera, const IndexSet32 *priorityObjectPointIds, const bool solePriorityPoints, RandomGenerator *randomGenerator, const unsigned int lowerFrame, const unsigned int upperFrame, const unsigned int minimalCorrespondences, ShiftVector< HomogenousMatrix4 > *poses, const Geometry::Estimator::EstimatorType estimator, const Scalar minimalValidCorrespondenceRatio, const Scalar ransacMaximalSqrError, const Scalar maximalRobustError, Scalar *totalError, Lock *lock, bool *abort, const unsigned int numberThreads, const unsigned int threadIndex, const unsigned int numberThreadsOne)
Determines a subset of the camera poses depending on valid 2D/3D points correspondences within a rang...
static bool determinePlane(const Database &database, const Index32 frameIndex, const CV::SubRegion &subRegion, RandomGenerator &randomGenerator, Plane3 &plane, const RelativeThreshold &minimalValidObjectPoints=RelativeThreshold(3u, Scalar(0.5), 20u), const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_HUBER, Scalar *finalError=nullptr, Indices32 *usedObjectPointIds=nullptr)
Determines a 3D plane best fitting to a set of given 3D object point ids which are specified by a giv...
static bool trackObjectPoints(const Database &database, const Indices32 &objectPointIds, const unsigned int lowerFrame, const unsigned int startFrame, const unsigned int upperFrame, const unsigned int minimalTrackedObjectPoints, const unsigned int minimalTrackedFrames, const unsigned int maximalTrackedObjectPoints, Indices32 &trackedObjectPointIds, ImagePointGroups &trackedImagePointGroups, Indices32 *trackedValidIndices=nullptr, bool *abort=nullptr)
This functions tracks image points (defined by their object points) from one frame to the sibling fra...
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
T minmax(const T &lowerBoundary, const T &value, const T &upperBoundary)
This function fits a given parameter into a specified value range.
Definition: base/Utilities.h:903
static void createIndices(const size_t numberIndices, const T &startIndex, std::vector< T > &indices)
Fills a vector with increasing index values.
Definition: base/Utilities.h:1265
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition: Base.h:114
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
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition: SquareMatrix3.h:35
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition: HomogenousMatrix4.h:73
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
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
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15