Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IncrementalSfM: expose nbOutliersThreshold param #1436

Merged
merged 4 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,8 @@ bool ReconstructionEngine_sequentialSfM::bundleAdjustment(std::set<IndexT>& newR
if(!isInitialPair && !_params.lockAllIntrinsics)
refineOptions |= BundleAdjustment::REFINE_INTRINSICS_ALL;

const std::size_t nbOutliersThreshold = (isInitialPair) ? 0 : 50;
const int nbOutliersThreshold =
(isInitialPair) ? 0 : _params.bundleAdjustmentMaxOutliers;
std::size_t iteration = 0;
std::size_t nbOutliers = 0;
bool enableLocalStrategy = false;
Expand Down Expand Up @@ -794,7 +795,7 @@ bool ReconstructionEngine_sequentialSfM::bundleAdjustment(std::set<IndexT>& newR
ALICEVISION_LOG_INFO("Bundle adjustment iteration: " << iteration << " took " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - chronoItStart).count() << " msec.");
++iteration;
}
while(nbOutliers > nbOutliersThreshold);
while(nbOutliersThreshold >= 0 && nbOutliers > nbOutliersThreshold);

ALICEVISION_LOG_INFO("Bundle adjustment with " << iteration << " iterations took " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - chronoStart).count() << " msec.");
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class ReconstructionEngine_sequentialSfM : public ReconstructionEngine
/// we don't add too much data in one step without bundle adjustment.
std::size_t maxImagesPerGroup = 30;

/// Threshold for the maximum number of outliers allowed at the end of a BA iteration.
/// If the limit is not met, another BA iteration is performed.
/// Using a negative value for this threshold will disable BA iterations.
int bundleAdjustmentMaxOutliers = 50;

// Local Bundle Adjustment data

/// The minimum number of shared matches to create an edge between two views (nodes)
Expand Down
5 changes: 4 additions & 1 deletion src/software/pipeline/main_incrementalSfM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// These constants define the current software version.
// They must be updated when the command line is changed.
#define ALICEVISION_SOFTWARE_VERSION_MAJOR 2
#define ALICEVISION_SOFTWARE_VERSION_MINOR 2
#define ALICEVISION_SOFTWARE_VERSION_MINOR 3

using namespace aliceVision;

Expand Down Expand Up @@ -160,6 +160,9 @@ int aliceVision_main(int argc, char **argv)
("maxImagesPerGroup", po::value<std::size_t>(&sfmParams.maxImagesPerGroup)->default_value(sfmParams.maxImagesPerGroup),
"Maximum number of cameras that can be added before the bundle adjustment is performed. This prevents adding too much data "
"at once without performing the bundle adjustment.")
("bundleAdjustmentMaxOutliers", po::value<int>(&sfmParams.bundleAdjustmentMaxOutliers)->default_value(sfmParams.bundleAdjustmentMaxOutliers),
"Threshold for the maximum number of outliers allowed at the end of a bundle adjustment iteration."
"Using a negative value for this threshold will disable BA iterations.")
("localizerEstimator", po::value<robustEstimation::ERobustEstimator>(&sfmParams.localizerEstimator)->default_value(sfmParams.localizerEstimator),
"Estimator type used to localize cameras (acransac (default), ransac, lsmeds, loransac, maxconsensus)")
("localizerEstimatorError", po::value<double>(&sfmParams.localizerEstimatorError)->default_value(0.0),
Expand Down