C++ Implementation of the SQPnP algorithm.
The algorithm is the generic PnP solver described in the paper "A Consistently Fast and Globally Optimal Solution to the Perspective-n-Point Problem" by G. Terzakis and M. Lourakis. For more intuition, refer to the supplementary material here.
SQPnP requires the Eigen library to build. Besides eigendecomposition, the use of Eigen is confined to matrix addition, transposition and multiplication. Choosing Eigen was motivated by its increasing popularity and lightweight character. There are also three examples of using the solver in this repository:
- ) one that uses OpenCV, just for the sake of demonstrating the initialization of SQPnP with
cv::Point_<>
andcv::Point3_<>
structures, - ) another in which data points are copied from plain 2D arrays, and
- ) a third which demonstrates SQPnP within RANSAC.
Build will proceed with either one of 1) or 2), depending on whether OpenCV is found or not. Example 3) uses the RansacLib template-based library, (part of) which is included in this repository.
Create a build
directory in the root of the cloned repository and run cmake
:
mkdir build
cd build
cmake ..
or, for a release build,
cmake .. -DCMAKE_BUILD_TYPE=Release
The latter will allow for more accurate timing of average execution time. Finally build everything:
make
To run the PnP example, once in the build
directory,
./examples/sqpnp_example
To run the robust estimation example, from the build
directory,
./examples/robust_sqpnp_example data/K.txt data/32D.txt
If you use this code in your published work, please cite the following paper:
@inproceedings{terzakis2020SQPnP,
title={A Consistently Fast and Globally Optimal Solution to the Perspective-n-Point Problem},
author={George Terzakis and Manolis Lourakis},
booktitle={European Conference on Computer Vision},
pages={478--494},
year={2020},
publisher={Springer International Publishing}
}