Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/pymagsac/src/magsac_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ int findRigidTransformation_(
magsac = new MAGSAC<cv::Mat, magsac::utils::DefaultRigidTransformationEstimator>(
MAGSAC<cv::Mat, magsac::utils::DefaultRigidTransformationEstimator>::MAGSAC_ORIGINAL);
magsac->setMaximumThreshold(sigma_max); // The maximum noise scale sigma allowed
// Reference threshold for the adaptive iteration count, derived from the noise
// scale (k*sigma_max = the statistical inlier threshold) instead of the
// pixel-unit default of 1.0, so the iteration budget is unit-independent.
magsac->setReferenceThreshold(magsac::utils::DefaultRigidTransformationEstimator::getSigmaQuantile() * sigma_max);
magsac->setCoreNumber(1); // The number of cores used to speed up sigma-consensus
magsac->setPartitionNumber(partition_num); // The number partitions used for speeding up sigma consensus. As the value grows, the algorithm become slower and, usually, more accurate.
magsac->setIterationLimit(max_iters);
Expand Down Expand Up @@ -180,6 +184,10 @@ int findFundamentalMatrix_(
magsac = new MAGSAC<cv::Mat, magsac::utils::DefaultFundamentalMatrixEstimator>(
MAGSAC<cv::Mat, magsac::utils::DefaultFundamentalMatrixEstimator>::MAGSAC_ORIGINAL);
magsac->setMaximumThreshold(sigma_max); // The maximum noise scale sigma allowed
// Reference threshold for the adaptive iteration count, derived from the noise
// scale (k*sigma_max = the statistical inlier threshold) instead of the
// pixel-unit default of 1.0, so the iteration budget is unit-independent.
magsac->setReferenceThreshold(magsac::utils::DefaultFundamentalMatrixEstimator::getSigmaQuantile() * sigma_max);
magsac->setCoreNumber(1); // The number of cores used to speed up sigma-consensus
magsac->setPartitionNumber(partition_num); // The number partitions used for speeding up sigma consensus. As the value grows, the algorithm become slower and, usually, more accurate.
magsac->setIterationLimit(max_iters);
Expand Down Expand Up @@ -354,7 +362,11 @@ int findEssentialMatrix_(std::vector<double>& correspondences,
magsac.setPartitionNumber(partition_num); // The number partitions used for speeding up sigma consensus. As the value grows, the algorithm become slower and, usually, more accurate.
magsac.setIterationLimit(max_iters);
magsac.setMinimumIterationNumber(min_iters);
magsac.setReferenceThreshold(magsac.getReferenceThreshold() / threshold_normalizer); // The reference threshold inside MAGSAC++ should also be normalized.
// Reference threshold for the adaptive iteration count, derived from the
// (normalized) noise scale rather than rescaling the arbitrary 1.0 default:
// k*sigma_max = the statistical inlier threshold, so the iteration budget is
// unit-independent.
magsac.setReferenceThreshold(magsac::utils::DefaultEssentialMatrixEstimator::getSigmaQuantile() * normalized_sigma_max);

// Initialize the samplers
// The main sampler is used for sampling in the main RANSAC loop
Expand Down Expand Up @@ -499,6 +511,10 @@ int findLine2D_(std::vector<double>& pointsArr,
MAGSAC<cv::Mat, magsac::utils::Default2DLineEstimator>::MAGSAC_ORIGINAL);

magsac->setMaximumThreshold(sigma_max); // The maximum noise scale sigma allowed
// Reference threshold for the adaptive iteration count, derived from the noise
// scale (k*sigma_max = the statistical inlier threshold) instead of the
// pixel-unit default of 1.0, so the iteration budget is unit-independent.
magsac->setReferenceThreshold(magsac::utils::Default2DLineEstimator::getSigmaQuantile() * sigma_max);
magsac->setCoreNumber(1); // The number of cores used to speed up sigma-consensus
magsac->setPartitionNumber(partition_num); // The number partitions used for speeding up sigma consensus. As the value grows, the algorithm become slower and, usually, more accurate.
magsac->setIterationLimit(max_iters);
Expand Down Expand Up @@ -619,6 +635,10 @@ int findHomography_(std::vector<double>& correspondences,
MAGSAC<cv::Mat, magsac::utils::DefaultHomographyEstimator>::MAGSAC_ORIGINAL);

magsac->setMaximumThreshold(sigma_max); // The maximum noise scale sigma allowed
// Reference threshold for the adaptive iteration count, derived from the noise
// scale (k*sigma_max = the statistical inlier threshold) instead of the
// pixel-unit default of 1.0, so the iteration budget is unit-independent.
magsac->setReferenceThreshold(magsac::utils::DefaultHomographyEstimator::getSigmaQuantile() * sigma_max);
magsac->setCoreNumber(1); // The number of cores used to speed up sigma-consensus
magsac->setPartitionNumber(partition_num); // The number partitions used for speeding up sigma consensus. As the value grows, the algorithm become slower and, usually, more accurate.
magsac->setIterationLimit(max_iters);
Expand Down