|
|
|
@ -14,24 +14,24 @@ class epnp { |
|
|
|
|
void compute_pose(cv::Mat& R, cv::Mat& t); |
|
|
|
|
private: |
|
|
|
|
template <typename T> |
|
|
|
|
void init_camera_parameters(const cv::Mat& cameraMatrix) |
|
|
|
|
{
|
|
|
|
|
uc = cameraMatrix.at<T> (0, 2); |
|
|
|
|
vc = cameraMatrix.at<T> (1, 2); |
|
|
|
|
fu = cameraMatrix.at<T> (0, 0); |
|
|
|
|
fv = cameraMatrix.at<T> (1, 1); |
|
|
|
|
void init_camera_parameters(const cv::Mat& cameraMatrix) |
|
|
|
|
{
|
|
|
|
|
uc = cameraMatrix.at<T> (0, 2); |
|
|
|
|
vc = cameraMatrix.at<T> (1, 2); |
|
|
|
|
fu = cameraMatrix.at<T> (0, 0); |
|
|
|
|
fv = cameraMatrix.at<T> (1, 1); |
|
|
|
|
} |
|
|
|
|
template <typename OpointType, typename IpointType> |
|
|
|
|
void init_points(const cv::Mat& opoints, const cv::Mat& ipoints) |
|
|
|
|
{ |
|
|
|
|
for(int i = 0; i < number_of_correspondences; i++) |
|
|
|
|
{ |
|
|
|
|
for(int i = 0; i < number_of_correspondences; i++) |
|
|
|
|
{ |
|
|
|
|
pws[3 * i ] = opoints.at<OpointType>(0,i).x; |
|
|
|
|
pws[3 * i + 1] = opoints.at<OpointType>(0,i).y; |
|
|
|
|
pws[3 * i + 2] = opoints.at<OpointType>(0,i).z; |
|
|
|
|
|
|
|
|
|
us[2 * i ] = ipoints.at<IpointType>(0,i).x*fu + uc; |
|
|
|
|
us[2 * i + 1] = ipoints.at<IpointType>(0,i).y*fv + vc; |
|
|
|
|
us[2 * i + 1] = ipoints.at<IpointType>(0,i).y*fv + vc; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
double reprojection_error(const double R[3][3], const double t[3]); |
|
|
|
@ -74,6 +74,8 @@ class epnp { |
|
|
|
|
|
|
|
|
|
double cws[4][3], ccs[4][3]; |
|
|
|
|
double cws_determinant; |
|
|
|
|
int max_nr; |
|
|
|
|
double * A1, * A2; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|