The cpp implementation of the CPnP solver is available at https://github.com/bereze/CPnP-cpp-version.
This is the description of the use of the CPnP solver. Paper information:
@inproceedings{zeng2023cpnp, title={CPnP: Consistent Pose Estimator for Perspective-n-Point Problem with Bias Elimination}, author={Zeng, Guangyang and Chen, Shiyu and Mu, Biqiang and Shi, Guodong and Wu, Junfeng}, booktitle={IEEE International Conference on Robotics and Automation (ICRA)}, pages={1940--1946}, year={2023}, organization={IEEE} }
One can directly run main.m to test the CPnP solver. The main.m mainly includes three parts:
The inputs and outputs of the CPnP function are as follows:
s - a 3Ć—n matrix whose i-th column is the coordinates (in the world frame) of the i-th 3D point
Psens_2D - a 2Ć—n matrix whose i-th column is the coordinates of the 2D projection of the i-th 3D point
fx, fy, u0, v0 - intrinsics of the camera, corresponding to the intrinsic matrix K=[fx 0 u0;0 fy v0;0 0 1]
Remark: the units of Psens_2D, fx, fy, u0, and v0 should be consistent, e.g., all in m, all in pixels, or all in normalized values.
R - the estimate of the rotation matrix in the first step
t - the estimate of the translation vector in the first step
R_GN - the refined estimate of the rotation matrix with Gauss-Newton iterations
t_GN - the refined estimate of the translation vector with Gauss-Newton iterations