pglira / simpleICP

Implementations of a rather simple version of the Iterative Closest Point algorithm in various languages.
MIT License
299 stars 60 forks source link

Does this implementation not work for 2d points? #38

Open raacampbell opened 8 months ago

raacampbell commented 8 months ago

I did some testing with the Python implementation and it seems that it fails with 2D point clouds. Is this expected? If so, it would be good if that was spelt out more clearly in the docs. If it was there I didn't see it. It might be a helpful feature to have.

A PointCloud must have three columns

In [35]: pc_zfix = PointCloud(x_f[:,0:2], columns=["x", "y"])
---------------------------------------------------------------------------
PointCloudException                       Traceback (most recent call last)
Cell In[35], line 1
----> 1 pc_zfix = PointCloud(x_f[:,0:2], columns=["x", "y"])

File ~/mambaforge/envs/icp/lib/python3.10/site-packages/simpleicp/pointcloud.py:42, in PointCloud.__init__(self, remapping, *args, **kwargs)
     40 for coordinate in ("x", "y", "z"):
     41     if coordinate not in self:
---> 42         raise PointCloudException(
     43             f'Column "{coordinate}" is missing in DataFrame.'
     44         )
     46 self._num_points = len(self)
     48 if "selected" not in self:

PointCloudException: Column "z" is missing in DataFrame.

Setting Z to zero causes errors when running ICP

I can just make a dummy Z column and set all the numbers in it to zero, but when I do that I see a lot of invalid value encountered in scalar divide messages and it not produce a meaningful answer. I tried this with both my own dataset and also the bunny dataset.