Open3D
Open3D copied to clipboard
fix visualization/draw ICP example and add warnings
Type
- [x] Bug fix (non-breaking change which fixes an issue): Fixes #6887
- [ ] New feature (non-breaking change which adds functionality). Resolves #
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #
Motivation and Context
A minor issue, but the ICP example in examples/python/visualization/draw.py requires the user to select point correspondences for a preliminary rough transformation before ICP registration, but users may not be aware of this. Currently, if no point correspondences are selected, the application crashes with an IndexError.
Checklist:
- [x] I have run
python util/check_style.py --applyto apply Open3D code style to my code. - [ ] This PR changes Open3D behavior or adds new functionality.
- [ ] Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is updated accordingly.
- [ ] I have added or updated C++ and / or Python unit tests OR included test results (e.g. screenshots or numbers) here.
- [x] I will follow up and update the code if CI fails.
- [x] For fork PRs, I have selected Allow edits from maintainers.
Description
Here are the changes I've made:
- prevented the IndexError when running the ICP example without point correspondences and added a RuntimeWarning for the user to hightlight the need to select point correspondences.
- additionally prevented a KeyError when the "Source (yellow)" cloud is not contained in the first selection set and added a RuntimeWarning for this.
- refactored the existing
do_ICP_one_setanddo_ICP_two_setwith new functions_prep_correspondencesand_do_ICPto reduce duplicate code.
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.
Thank you for the feedback! I've added your suggested check, and also found two more things that needed checking to avoid a crash, which I also added:
- add check if only one set provided to two_set ICP
- add check if no Target (blue) points are provided to single set ICP
- add check if overall number of corresponding points is mismatching and report the mismatch so that the user can add to the existing sets