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

Set better default for RRANSAC and RMSAC #6158

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

mvieth
Copy link
Member

@mvieth mvieth commented Oct 27, 2024

RRANSAC is a faster variant of RANSAC. It performs a pretest before counting all inliers of a candidate model (this is the costly part of RANSAC). The pretest consists of choosing a number of random sample points and then testing if all these points are inliers. If just one is an outlier, the candidate model is discarded. The previous default was to choose 10 percent of all points for this pretest, which is far too much, and the probability of a candidate model (even a good one!) not being discarded is near zero. Therefore RRANSAC fails to find a model in many cases. The new default is to use one point for the pretest. This has a good chance of rejecting very bad models, but not reject any good models. This is a good default for many different datasets.

The same is done for RMSAC, which is a faster variant of MSAC. MSAC uses a different way to judge the quality of a candidate model than RANSAC, but works very similarly otherwise.

RRANSAC is a faster variant of RANSAC. It performs a pretest before counting all inliers of a candidate model (this is the costly part of RANSAC). The pretest consists of choosing a number of random sample points and then testing if _all_ these points are inliers. If just one is an outlier, the candidate model is discarded. The previous default was to choose 10 percent of all points for this pretest, which is far too much, and the probability of a candidate model (even a good one!) not being discarded is near zero. Therefore RRANSAC fails to find a model in many cases. The new default is to use one point for the pretest. This has a good chance of rejecting very bad models, but not reject any good models. This is a good default for many different datasets.

The same is done for RMSAC, which is a faster variant of MSAC. MSAC uses a different way to judge the quality of a candidate model than RANSAC, but works very similar otherwise.
@mvieth mvieth added changelog: enhancement Meta-information for changelog generation module: sample_consensus labels Oct 27, 2024
@mvieth
Copy link
Member Author

mvieth commented Oct 30, 2024

Closing and reopening because some checks did not run ...
Edit: all checks ran and have passed now

@mvieth mvieth closed this Oct 30, 2024
@mvieth mvieth reopened this Oct 30, 2024
@mvieth mvieth requested a review from larshg November 3, 2024 18:54
@larshg
Copy link
Contributor

larshg commented Nov 4, 2024

Do you have any numbers for the test sets? Looks fine and seems reasonable.

@mvieth
Copy link
Member Author

mvieth commented Nov 4, 2024

Do you have any numbers for the test sets? Looks fine and seems reasonable.

I did a comparison with the test from https://github.com/PointCloudLibrary/pcl/blob/master/test/sample_consensus/test_sample_consensus_plane_models.cpp#L271 (I deleted lines 281 and 282 for this comparison). With the old default (10 percent=328 samples), RRANSAC was never able to find a valid model (for different random seeds). With the new default (1 sample), RRANSAC found a good model every time, and about three out of four candidate models that were not rejected by the pretest (doSamplesVerifyModel) were good models. So in only about one out of four cases, the inlier counting was wasted time. For comparison, in standard RANSAC inlier counting was wasted time (=few inliers/bad models) in about three out of four cases.
This shows that the old 10-percent default was useless, and that RRANSAC with the new 1-sample default finds good models with high probability but avoids counting inliers for (some) bad models.

@mvieth mvieth merged commit da7f34a into PointCloudLibrary:master Nov 4, 2024
14 checks passed
@mvieth mvieth deleted the rransac_rmsac branch November 4, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: enhancement Meta-information for changelog generation module: sample_consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants