The repository is hosted on https://github.com/xuchi7/RPnP.git
RPnP Ciation
Shiqi Li, Chi Xu*, Ming Xie, "A Robust O(n) Solution to the Perspective-n-Point Problem," IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 34, no. 7, pp. 1444-1450, July 2012, doi:10.1109/TPAMI.2012.41
Bibtex
@article{li2012robust,
title={A Robust O (n) Solution to the Perspective-n-Point Problem},
author={Li, S. and Xu, C. and Xie, M.},
journal={Pattern Analysis and Machine Intelligence, IEEE Transactions on},
volume={34},
number={7},
pages={1444--1450},
year={2012}
}
Bibtex
@article{li2012robust,
title={A Robust O (n) Solution to the Perspective-n-Point Problem},
author={Li, S. and Xu, C. and Xie, M.},
journal={Pattern Analysis and Machine Intelligence, IEEE Transactions on},
volume={34},
number={7},
pages={1444--1450},
year={2012}
}
The MATLAB code of RPnP
rpnp1.0.zip | |
File Size: | 74 kb |
File Type: | zip |
How To Use RPnP Algorithm
The RPnP algorithm is implemented in "RPnP.m" file, its full path is "code3/func/RPnP.m"
% function [R t]= RPnP(XX,xx)
% XX is the 3D coordinate of the point set.
% xx is the ***normalized*** 2D coordinate of the projected point set.
% R is the estimated rotation matrix.
% t is the estimated translation vector.
For more details about the code, please refer to "readme.txt".
Converting from image coordinate to normalized coordinate
The algorithm uses the normalized coordinate as input, because the normalized coordinate is independent from the camera model used. The conversion from the image coordinate to the normalized coordinate is described as follows:
(1) For a simple camera model considering only focal length and center point
As can be seen in the figure below, OXYZ is a camera coordinate frame, and its Z-axis is defined along the camera optical axis. UV is the image plane, and xnyn is the normalized image plane parallel to UV. The distance form O to the center of the image plane equals the focal length, and the distance form O to the center of the normalized image plane equals 1, that's why the plane is called "normalized".
Let the image coordinate be (u,v), the image center be (cu,cv), and the focal length = f, the normalized coordinates (xn,yn) are calculated as follow:
xn = (u - cu)/f
yn = (v - cv)/f
Usually, cu = w/2 and cv = h/2, in which w and h are the width and height of the image respectively.
(2) For more complex camera model considering distortion and so on, please refer to:
J Heikkila, O Silven. A four-step camera calibration procedure with implicit image correction, Computer Vision and Pattern Recognition. 1997
The RPnP algorithm is implemented in "RPnP.m" file, its full path is "code3/func/RPnP.m"
% function [R t]= RPnP(XX,xx)
% XX is the 3D coordinate of the point set.
% xx is the ***normalized*** 2D coordinate of the projected point set.
% R is the estimated rotation matrix.
% t is the estimated translation vector.
For more details about the code, please refer to "readme.txt".
Converting from image coordinate to normalized coordinate
The algorithm uses the normalized coordinate as input, because the normalized coordinate is independent from the camera model used. The conversion from the image coordinate to the normalized coordinate is described as follows:
(1) For a simple camera model considering only focal length and center point
As can be seen in the figure below, OXYZ is a camera coordinate frame, and its Z-axis is defined along the camera optical axis. UV is the image plane, and xnyn is the normalized image plane parallel to UV. The distance form O to the center of the image plane equals the focal length, and the distance form O to the center of the normalized image plane equals 1, that's why the plane is called "normalized".
Let the image coordinate be (u,v), the image center be (cu,cv), and the focal length = f, the normalized coordinates (xn,yn) are calculated as follow:
xn = (u - cu)/f
yn = (v - cv)/f
Usually, cu = w/2 and cv = h/2, in which w and h are the width and height of the image respectively.
(2) For more complex camera model considering distortion and so on, please refer to:
J Heikkila, O Silven. A four-step camera calibration procedure with implicit image correction, Computer Vision and Pattern Recognition. 1997
Related Papers
[1] Shiqi Li, Chi Xu*. A Stable Direct Solution of Perspective-Three-Point Problem [J]. International Journal of Pattern Recognition and Artificial Intelligence, 2011, 25(5): 643-673
[2] Shiqi Li, Chi Xu*. Efficient Lookup Table Based Camera Pose Estimation for Augmented Reality [J]. Computer Animation and Virtual Worlds, 2011, 22(1): 47-58