This project provides a clean and fast implementation of the ICP method by Besl and McKay in C++ with minimal dependencies (Eigen for matrix manipulation and SVD computation, and Nanoflann for KDTree-based correspondences search). The algorithm is one of the baseline methods on rigid alignment of point clouds, and this implementation attempts to provide an entry point for learning it with no practical hassles. At the same time, it works fast and robustly enough to be used out-of-the box on any of your projects.
Given two point sets:
find a rotation R and translation T that minimizes the error:
Given a matrix W made by a set of correspondent N points, centered to its mean
obtain the Singular Value Decomposition of W = U * S * Vt.
Theorem without proof says that if rank( W ) = 3, the optimal solution of E( R, t ) is unique and given by:
This process can be run iteratively, selecting correspondent points by different criteria (neighbourhood, random search...), until convergence.
Eigen is the only external dependency required on your system. Nanoflann is included in the project.
A real test executable is provided, allowing to register any desired pair of point clouds (only .obj format supported at the moment). The PointCloud class uses TinyObjLoader (header included) for parsing OBJ files, and the PlainICP executable requires Boost for parsing external arguments.
Just include the ICP class header on your project.
Check the provided cmake project for compiling an executable which shows how to use the class:
mkdir ./build
cd ./build
cmake ..
make
Sample call with provided sample OBJ files:
./PlainICP --source-obj-file ../samples/bunny_head.obj --target-obj-file ../samples/bunny.obj --transformed-obj-file ../samples/aligned_bunny_head.obj --tolerance 0.0005 --verbose 1
Unit testing using googletest is provided (Google Test dependency is automatically installed and self-contained within the project). Run the following target in the build directory:
make build_and_test
This software release is primarily MIT licensed. Some files contain third-party code under other licens