From b68eae1616de77529654d038482a34bb8ecb7190 Mon Sep 17 00:00:00 2001 From: Nicola Loi <79461707+nicolaloi@users.noreply.github.com> Date: Thu, 23 May 2024 16:27:10 +0200 Subject: [PATCH] Fix ransac update of the iteration number (#6789) The update of the iteration number is forced to be non-negative (was negative if corres_inlier_ratio = 0.0) --- CHANGELOG.md | 1 + cpp/open3d/pipelines/registration/Registration.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3b964d6d0..3d9d4bbb575 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Fix log error message for `probability` argument validation in `PointCloud::SegmentPlane` (PR #6622) - Fix macOS arm64 builds, add CI runner for macOS arm64 (PR #6695) - Fix KDTreeFlann possibly using a dangling pointer instead of internal storage and simplified its members (PR #6734) +- Fix RANSAC early stop if no inliers in a specific iteration (PR #6789) - Fix segmentation fault (infinite recursion) of DetectPlanarPatches if multiple points have same coordinates (PR #6794) ## 0.13 diff --git a/cpp/open3d/pipelines/registration/Registration.cpp b/cpp/open3d/pipelines/registration/Registration.cpp index 8527d620bf0..6820d2f7c33 100644 --- a/cpp/open3d/pipelines/registration/Registration.cpp +++ b/cpp/open3d/pipelines/registration/Registration.cpp @@ -235,13 +235,15 @@ RegistrationResult RegistrationRANSACBasedOnCorrespondence( max_correspondence_distance, transformation); - // Update exit condition if necessary. - // If confidence is 1.0, then it is safely inf, we always - // consume all the iterations. + // Update exit condition if necessary double est_k_local_d = std::log(1.0 - criteria.confidence_) / std::log(1.0 - std::pow(corres_inlier_ratio, ransac_n)); + // This prevents having a negative number of iterations: + // est_k_local_d = -inf if corres_inlier_ratio = 0.0 + est_k_local_d = + est_k_local_d < 0 ? est_k_local : est_k_local_d; est_k_local = est_k_local_d < est_k_global ? static_cast(std::ceil(est_k_local_d))