STORM-IRIT / OpenGR

OpenGR: A C++ library for 3D Global Registration
https://storm-irit.github.io/OpenGR/
Other
334 stars 73 forks source link

[Question] Sub-sampling method #86

Open maximecharriere opened 3 years ago

maximecharriere commented 3 years ago

Hello, I was wondering what was the method behind the sub-sampling parameterized with Number of samples (-n).

I have a 3D scan with 50k points and a reference with 500pts. If I sub-sample the scan with CGAL::Polygon_mesh_processing::isotropic_remeshing() to get 1k points and use : (Note the large N to avoid subsampling by OpenGr)

./Super4PCS -i input1 input2 -o 1.0 -d 2.50 -n 10000 -x

The result is perfect.

But if I don't sub-sample and directly use: (Note the N of 1k samples)

./Super4PCS -i input1 input2 -o 1.0 -d 2.50 -n 1000 -x

I'm getting a bad result.

So I was wondering what sub-sampling method OpenGr uses. Does it takes N points at random or the first N points?

nmellado commented 3 years ago

Hello @maximecharriere ,

This is very interesting question and experiment that you made. I am suspecting our sampling algorithm to be the cause of many of the wrong results we get with the library. Unfortunately I couldn't find time to investigate on this question.

@sgiraudot shall we update the documentation of the cgal wrapper to encourage users to subsample using cgal instead of OpenGR ?

Sampling is performed by hashing the coordinates of the input point cloud in a 3d grid, and keep only one representative sample per voxel. The resolution of the grid is computed according to the parameter (source code: https://github.com/STORM-IRIT/OpenGR/blob/master/src/gr/utils/sampling.h#L100)

I see a simple way to improve the performances of the sampling algorithm, which is to pre-rotate the input point cloud so it is aligned with the xyz coordinates of the grid (see call to the sampler here: https://github.com/STORM-IRIT/OpenGR/blob/master/src/gr/algorithms/matchBase.hpp#L275). Getting something like poisson sampling will or equivalent would be of course even better.

sgiraudot commented 3 years ago

CGAL offers 3 subsampling algorithms for point clouds : grid (pretty much the same as you describe for OpenGR), random (self-explanatory) and hierarchical (which uses recursive subdivisions along PCA and thus is supposed to simplify more on planar regions). This last one might be interesting for registration but I wouldn't recommend it before being sure of this.

The algorithm cited in this issue is a remeshing algorithm which means that users need meshes as input (not raw point clouds). I'm glad it does bring good results with registration, but it seems quite specialized (and unusable for point clouds in general).