🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Add option to pass initial model to robust solvers. - #136

Merged
pablospe merged 1 commit into
PoseLib:masterfrom
ghanning:initial-model
Apr 14, 2025
Merged

pablospe merged 1 commit into
PoseLib:masterfrom
ghanning:initial-model

Conversation

@ghanning

@ghanning ghanning commented Apr 8, 2025 •

Copy link
Copy Markdown
Contributor

See #134.

In C++ this is controlled by the new score_initial_model flag in RansacOptions.

When using the Python bindings the user should pass the initial model as an optional argument.

Comment thread PoseLib/robust/ransac_impl.h Resolved
Comment thread PoseLib/types.h Resolved
@ghanning
ghanning force-pushed the initial-model branch 4 times, most recently from 26c4b44 to eba8315 Compare April 11, 2025 13:24
@ghanning
ghanning marked this pull request as ready for review April 11, 2025 13:25
Comment thread PoseLib/robust.cc
BundleOptions bundle_opt_scaled = bundle_opt;
bundle_opt_scaled.loss_scale /= scale;
if (ransac_opt.score_initial_model) {
*F = T2.transpose().inverse() * (*F) * T1.inverse();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please check that this normalization is correct (and for H below).

Are there other estimators that I missed for which the input model has to be normalized?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably estimate_shared_focal_relative_pose (the focal length)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes I think this should probably be normalized as well. Perhaps re-initializing the cameras similar to

image_pair->camera1 = Camera("SIMPLE_PINHOLE", std::vector<double>{image_pair->camera1.focal() / scale, 0.0, 0.0}, -1, -1);
image_pair->camera2 = Camera("SIMPLE_PINHOLE", std::vector<double>{image_pair->camera2.focal() / scale, 0.0, 0.0}, -1, -1);

or something similar.

@ghanning

Copy link
Copy Markdown
Contributor Author

Some results from posebench where I first ran the estimators as usual and the re-ran with the estimated model as the initial one:

                          AUC0   AUC1   AUC5   med_rot   med_pos   avg_rt   med_rt
PnP (poselib)            50.51  89.72  96.95   3.3E-01       0.1   14.7ms   13.3ms
PnP (poselib) (initial)  50.54  89.72  96.94   3.3E-01       0.1    7.3ms    6.8ms

                        AUC5   AUC10   AUC20   avg_rt   med_rt
E (poselib)            49.14   63.49   74.70   40.1ms   36.1ms
E (poselib) (initial)  49.15   63.50   74.71   27.8ms   24.9ms
F (poselib)            34.04   47.86   60.51   40.3ms   34.8ms
F (poselib) (initial)  34.09   47.91   60.54   19.9ms   16.7ms

                        AUC5   AUC10   AUC20   avg_rt   med_rt
H (poselib)             0.86    2.54    7.15  762.3us  545.2us
H (poselib) (initial)   0.86    2.58    7.21  654.5us  517.5us

The AUC values are very similar and the runtime goes down a bit when using the initial model. I did not change the min_iterations parameter (it was set to the default value 100). Note that not all estimators are included in the benchmark.

@vlarsson

Copy link
Copy Markdown
Collaborator

@ghanning this looks good to me. Are there any changes planned or is it ready to merge?

@ghanning

Copy link
Copy Markdown
Contributor Author

@vlarsson Ready to merge.

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