8 #include <mrpt/otherlibs/do_opencv_includes.h> 35 p3p(Eigen::MatrixXd cam_intrinsic);
39 p3p(cv::Mat cameraMatrix);
49 bool solve(cv::Mat&
R, cv::Mat& tvec,
const cv::Mat& opoints,
const cv::Mat& ipoints);
51 bool solve(Eigen::Ref<Eigen::Matrix3d>
R, Eigen::Ref<Eigen::Vector3d>
t, Eigen::MatrixXd obj_pts, Eigen::MatrixXd img_pts);
74 int solve(
double R[4][3][3],
double t[4][3],
75 double mu0,
double mv0,
double X0,
double Y0,
double Z0,
76 double mu1,
double mv1,
double X1,
double Y1,
double Z1,
77 double mu2,
double mv2,
double X2,
double Y2,
double Z2);
105 bool solve(
double R[3][3],
double t[3],
106 double mu0,
double mv0,
double X0,
double Y0,
double Z0,
107 double mu1,
double mv1,
double X1,
double Y1,
double Z1,
108 double mu2,
double mv2,
double X2,
double Y2,
double Z2,
109 double mu3,
double mv3,
double X3,
double Y3,
double Z3);
117 template <
typename T>
118 void init_camera_parameters(
const cv::Mat& cameraMatrix)
120 cx = cameraMatrix.at<T> (0, 2);
121 cy = cameraMatrix.at<T> (1, 2);
122 fx = cameraMatrix.at<T> (0, 0);
123 fy = cameraMatrix.at<T> (1, 1);
132 template <
typename Opo
intType,
typename Ipo
intType>
133 void extract_points(
const cv::Mat& opoints,
const cv::Mat& ipoints, std::vector<double>&
points)
137 for(
int i = 0; i < 4; i++)
140 points[i*5+1] = ipoints.at<IpointType>(i).
y*
fy +
cy;
141 points[i*5+2] = opoints.at<OpointType>(i).
x;
142 points[i*5+3] = opoints.at<OpointType>(i).
y;
143 points[i*5+4] = opoints.at<OpointType>(i).
z;
158 for(
int i=0; i<4; i++)
162 points[i*5+2]=obj_pts(i,0);
163 points[i*5+3]=obj_pts(i,1);
164 points[i*5+4]=obj_pts(i,2);
179 int solve_for_lengths(
double lengths[4][3],
double distances[3],
double cosines[3]);
180 bool align(
double M_start[3][3],
181 double X0,
double Y0,
double Z0,
182 double X1,
double Y1,
double Z1,
183 double X2,
double Y2,
double Z2,
184 double R[3][3],
double T[3]);
192 bool jacobi_4x4(
double * A,
double * D,
double * U);
void extract_points(Eigen::MatrixXd obj_pts, Eigen::MatrixXd img_pts, std::vector< double > &points)
Eigen wrapper for extracting object and image points.
bool jacobi_4x4(double *A, double *D, double *U)
Function used to compute the SVD.
GLsizei const GLfloat * points
double inv_fy
Inverse of focal length x.
bool align(double M_start[3][3], double X0, double Y0, double Z0, double X1, double Y1, double Z1, double X2, double Y2, double Z2, double R[3][3], double T[3])
int solve_for_lengths(double lengths[4][3], double distances[3], double cosines[3])
Helper function to solve()
double cy_fy
Inverse of image center point x.
void init_inverse_parameters()
Function to compute inverse parameters of camera intrinsic matrix.
bool solve(Eigen::Ref< Eigen::Matrix3d > R, Eigen::Ref< Eigen::Vector3d > t, Eigen::MatrixXd obj_pts, Eigen::MatrixXd img_pts)
p3p(double fx, double fy, double cx, double cy)
Constructor for p3p class using C.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double cx_fx
Inverse of focal length y.
double inv_fx
Image center y.