Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

fix visualization/draw ICP example and add warnings

Open rxba opened this issue 1 year ago • 1 comments

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 --apply to 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_set and do_ICP_two_set with new functions _prep_correspondences and _do_ICP to reduce duplicate code.

rxba avatar Aug 26 '24 13:08 rxba

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

update-docs[bot] avatar Aug 26 '24 13:08 update-docs[bot]

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

rxba avatar Sep 05 '24 10:09 rxba