Skip to content

Weight observations by temporal position and landmark frequency - #2159

Open
CedricThebault wants to merge 1 commit into
developfrom
dev/trackDependentObsWeighting
Open

Weight observations by temporal position and landmark frequency#2159
CedricThebault wants to merge 1 commit into
developfrom
dev/trackDependentObsWeighting

Conversation

@CedricThebault

Copy link
Copy Markdown
Member

This pull request introduces advanced observation weighting strategies to the Structure-from-Motion (SfM) expanding pipeline, allowing for more robust and configurable handling of feature tracks and observation density. The main changes add options for density-based and track-based observation weighting, new parameters for fine-tuning these behaviors, and supporting implementations and tests.

Observation weighting enhancements

  • Added support for observation density weighting and track-based weighting in the SfM expanding pipeline, with new parameters to control fading size, track length thresholds, and maximum weights. This enables more nuanced control over how observations contribute to bundle adjustment and outlier rejection. (meshroom/aliceVision/SfmExpanding.py, src/software/pipeline/main_sfmExpanding.cpp, src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp, src/aliceVision/sfm/pipeline/expanding/SfmBundle.hpp) [1] [2] [3] [4] [5]

  • Implemented new functions for weighting observations along tracks and by track length, as well as resetting observation weights, with documentation and logic for fade-in/out and thresholding. (src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp, src/aliceVision/sfm/pipeline/expanding/TrackWeighting.hpp) [1] [2]

Integration and testing

  • Integrated the new weighting logic into the bundle initialization, ensuring weights are reset and applied according to the new parameters, and updated CMake files to include the new source and test files. (src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp, src/aliceVision/sfm/CMakeLists.txt) [1] [2] [3]

Residual and error computation updates

  • Updated residual and reprojection error computations to optionally use observation weights, making error statistics more representative of the actual optimization. (src/aliceVision/sfm/sfmStatistics.cpp, src/aliceVision/sfm/sfmStatistics.hpp, src/aliceVision/sfm/utils/poseFilter.cpp) [1] [2] [3] [4]

Minor code improvements

  • Improved the logic in distance-based weighting to correctly compose weights multiplicatively, and removed redundant code for consistency. (src/aliceVision/sfm/pipeline/expanding/DistanceWeighting.cpp) [1] [2]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds new observation-weighting strategies to the SfM expanding pipeline (density-based and track-based), integrates them into bundle initialization, and updates residual/error statistics to optionally reflect per-observation weights.

Changes:

  • Introduces track-position and track-length weighting utilities (TrackWeighting.*) plus a dedicated unit test.
  • Wires observation-weight resets and optional weighting passes into SfmBundle::initializeIteration, and makes distance weighting multiplicative.
  • Exposes new CLI/Meshroom parameters and updates residual/error computations to optionally apply observation weights.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/software/pipeline/main_sfmExpanding.cpp Adds CLI options for the new weighting modes and attempts to pass them into the SfM bundle pipeline.
src/aliceVision/sfm/utils/poseFilter.cpp Weights the accumulated reprojection error contributions by observation weight.
src/aliceVision/sfm/sfmStatistics.hpp Extends residual mean/median API with an optional “weightedResiduals” mode.
src/aliceVision/sfm/sfmStatistics.cpp Implements optional weighted residual collection for mean/median computation.
src/aliceVision/sfm/pipeline/expanding/TrackWeighting.hpp Declares new track-based weighting utilities and documents their intended behavior.
src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp Implements temporal-position and track-length weighting plus a weight reset helper.
src/aliceVision/sfm/pipeline/expanding/TrackWeighting_test.cpp Adds unit coverage for the new track-based weighting behavior.
src/aliceVision/sfm/pipeline/expanding/SfmBundle.hpp Adds new configuration knobs for density/track weighting and their parameters.
src/aliceVision/sfm/pipeline/expanding/SfmBundle.cpp Resets weights each iteration and conditionally applies density and/or track weighting.
src/aliceVision/sfm/pipeline/expanding/DistanceWeighting.cpp Switches distance weighting to multiply into existing weights (to compose with other strategies).
src/aliceVision/sfm/CMakeLists.txt Registers new source and test files in the build.
meshroom/aliceVision/SfmExpanding.py Exposes the new weighting options in the Meshroom node UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/software/pipeline/main_sfmExpanding.cpp Outdated
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.hpp Outdated
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.hpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 11 comments.

Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp Outdated
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp Outdated
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp Outdated
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting_test.cpp
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting_test.cpp Outdated
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting_test.cpp Dismissed
Comment thread src/software/pipeline/main_sfmExpanding.cpp Dismissed
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting_test.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/aliceVision/sfm/pipeline/expanding/TrackWeighting.cpp:14

  • TrackWeighting.cpp throws std::out_of_range later in the file but does not include . This can fail to compile on toolchains that don't include it transitively.
#include <vector>
#include <stack>
#include <cmath>
#include <aliceVision/stl/mapUtils.hpp>
#include <aliceVision/system/Logger.hpp>

}

if (_enableObservationsWeighting)
resetObservationWeights(sfmData);
Comment thread src/aliceVision/sfm/sfmStatistics.cpp
Comment thread src/aliceVision/sfm/pipeline/expanding/TrackWeighting_test.cpp
…, and/or on the number of observations of the landmark
@CedricThebault
CedricThebault force-pushed the dev/trackDependentObsWeighting branch from aadc2de to 6feabd3 Compare July 20, 2026 16:10
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants