Fix BCPD convergence issues and align with the original C implementation#122
Merged
neka-nat merged 3 commits intoneka-nat:masterfrom Mar 31, 2026
Merged
Fix BCPD convergence issues and align with the original C implementation#122neka-nat merged 3 commits intoneka-nat:masterfrom
neka-nat merged 3 commits intoneka-nat:masterfrom
Conversation
Removed comment about outlier term calculation.
abd3d2a to
150b3de
Compare
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes significant convergence issues in the BCPD (Bayesian Coherent Point Drift) implementation. By comparing the logic with the original C implementation (ohirose/bcpd), several mathematical and implementation-level discrepancies were identified and corrected. These fixes enable BCPD to achieve the same level of accuracy and stability as the original implementation, especially when using extreme regularization parameters (e.g., "rigid-hack" settings).
Key Bug Fixes and Improvements
1. Corrected Frobenius Inner Product for Scale Update
np.sum(rot * s_xu)), matching exactly with the index-summation in the C code L365-367.2. Updated Transformation Usage in Variance Calculation
y_hatusing the latestR, s, tbefore updating3. Outlier Probability Normalization
w / Ntow / volume(where volume is the bounding box of the target). This aligns with the probability density of a uniform distribution over the target space, preventing bias across different data scales. L265.4. Initialization and Scaling Fixes
sigma2was squared again in thes2s2ratio calculation, which severely decoupled5. Optionalized Debias Terms
-aflag (aliased asdbin the source). They are now disabled by default to match the standard behavior, significantly improving initial convergence speed. L179, L331, L364, L377.Verification
Tested using the Stanford Bunny dataset (
bunny.pcd) with 500 outliers and a 30-degree rotation.The results show that the Python implementation now matches the original C implementation's performance within 0.1% accuracy.