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

[SfM] Major bug fix on BlockOrder in BACeres #849

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

0xfaded
Copy link

@0xfaded 0xfaded commented Jul 30, 2020

Ceres accepts a ParameterBlockOrdering hint which must assign
every parameter block to exactly one group.

BundleAdjustmentCeres can be called multiple times, and on each
call resetProblem() is called internally to clear the parameter blocks.

However, resetProblem() did not clear the ParameterBlockOrdering.
If the BundleAdjustmentCeres object was used more than once,
Ceres would fail with an error.

In practice, the BundleAdjustmentCeres object is used in a loop that
repeatedly calls adjust() while removing outliers on each iteration.

If the first iteration succeeded with no outliers, the loop would
correctly exit. However, if any outliers are present, the entire
bundle adjustment routine fails leading to the warning:

"Bundle Adjustment failed, the solution is not usable."

This incorrect Ceres usage seems to have been the main cause
of bundle adjustment failures. The error given by Ceres was:

FAILURE (The program has 3855 parameter blocks, but the parameter block
ordering has 7621 parameter blocks.)

Includes fix for rig error functor which was previously unreachable due
to bug. Without fix, rigs cause SfM to crash.

Description

Features list

Implementation remarks

Ceres accepts a ParameterBlockOrdering hint which must assign
every parameter block to exactly one group.

BundleAdjustmentCeres can be called multiple times, and on each
call resetProblem() is called internally to clear the parameter blocks.

However, resetProblem() did not clear the ParameterBlockOrdering.
If the BundleAdjustmentCeres object was used more than once,
Ceres would fail with an error.

In practice, the BundleAdjustmentCeres object is used in a loop that
repeatedly calls adjust() while removing outliers on each iteration.

If the first iteration succeeded with no outliers, the loop would
correctly exit. However, if any outliers are present, the entire
bundle adjustment routine fails leading to the warning:

  "Bundle Adjustment failed, the solution is not usable."

This incorrect Ceres usage seems to have been the main cause
of bundle adjustment failures. The error given by Ceres was:

FAILURE (The program has 3855 parameter blocks, but the parameter block
  ordering has 7621 parameter blocks.)

Includes fix for rig error functor which was previously unreachable due
to bug. Without fix, rigs cause SfM to crash.
@fabiencastan
Copy link
Member

As pointed:
// AngleAxisRotatePoint: Inplace rotation is not supported. pt and result must point to different memory locations, otherwise the result will be undefined.
https://github.com/ceres-solver/ceres-solver/blob/5cb5b35a930c1702278083c75769dbb4e5801045/include/ceres/rotation.h#L217

@fabiencastan fabiencastan added this to the 2020.1.0 milestone Aug 19, 2020
Copy link
Member

@fabiencastan fabiencastan left a comment

Choose a reason for hiding this comment

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

Thanks for this fix. This is a very nice contribution!

@fabiencastan fabiencastan changed the title SfM: Major BugFix - Reset BlockOrder in BACeres [SfM] Major bug fix on BlockOrder in BACeres Aug 19, 2020
@fabiencastan fabiencastan merged commit a324d12 into alicevision:develop Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants