12 #include <mrpt/otherlibs/do_opencv_includes.h> 38 epnp(
const cv::Mat& cameraMatrix,
const cv::Mat& opoints,
const cv::Mat& ipoints);
52 const double u,
const double v);
68 uc = cameraMatrix.at<T> (0, 2);
69 vc = cameraMatrix.at<T> (1, 2);
70 fu = cameraMatrix.at<T> (0, 0);
71 fv = cameraMatrix.at<T> (1, 1);
79 template <
typename Opo
intType,
typename Ipo
intType>
80 void init_points(
const cv::Mat& opoints,
const cv::Mat& ipoints)
84 pws[3 * i ] = opoints.at<OpointType>(0,i).
x;
85 pws[3 * i + 1] = opoints.at<OpointType>(0,i).
y;
86 pws[3 * i + 2] = opoints.at<OpointType>(0,i).
z;
88 us[2 * i ] = ipoints.at<IpointType>(0,i).
x*
fu +
uc;
89 us[2 * i + 1] = ipoints.at<IpointType>(0,i).
y*
fv +
vc;
119 void fill_M(CvMat * M,
const int row,
const double *
alphas,
const double u,
const double v);
126 void compute_ccs(
const double * betas,
const double * ut);
169 void qr_solve(CvMat * A, CvMat *
b, CvMat * X);
177 double dot(
const double *
v1,
const double *
v2);
185 double dist2(
const double * p1,
const double * p2);
206 void gauss_newton(
const CvMat * L_6x10,
const CvMat * Rho,
double current_betas[4]);
217 const double cb[4], CvMat * A, CvMat *
b);
228 double R[3][3],
double t[3]);
244 void copy_R_and_t(
const double R_dst[3][3],
const double t_dst[3],
245 double R_src[3][3],
double t_src[3]);
void compute_A_and_b_gauss_newton(const double *l_6x10, const double *rho, const double cb[4], CvMat *A, CvMat *b)
Internal function.
void compute_barycentric_coordinates(void)
Convert from object space to relative object space (Barycentric coordinates)
void choose_control_points(void)
Function to select 4 control points from n points.
double cws_determinant
Internal member variables.
std::vector< double > pws
Focal length in y-direction.
void find_betas_approx_3(const CvMat *L_6x10, const CvMat *Rho, double *betas)
Internal function.
void compute_pose(cv::Mat &R, cv::Mat &t)
OpenCV wrapper to compute pose.
void compute_rho(double *rho)
Get distances between all object points taken 2 at a time(nC2)
~epnp()
Destructor for EPnP class.
double reprojection_error(const double R[3][3], const double t[3])
Function to compute reprojection error.
double dist2(const double *p1, const double *p2)
Squared distance between two vectors.
int number_of_correspondences
Internal member variables.
void gauss_newton(const CvMat *L_6x10, const CvMat *Rho, double current_betas[4])
Gauss Newton iterative algorithm.
void copy_R_and_t(const double R_dst[3][3], const double t_dst[3], double R_src[3][3], double t_src[3])
Copy function of output result.
void solve_for_sign(void)
Internal function.
std::vector< double > pcs
void fill_M(CvMat *M, const int row, const double *alphas, const double u, const double v)
Generate the Matrix M.
void init_camera_parameters(const cv::Mat &cameraMatrix)
Initialize Camera Matrix.
double * A1
Internal member variable.
double dot(const double *v1, const double *v2)
Dot product of two OpenCV vectors.
double cws[4][3]
Number of 2d/3d correspondences.
void init_points(const cv::Mat &opoints, const cv::Mat &ipoints)
Convert object points and image points from OpenCV format to STL matrices.
void qr_solve(CvMat *A, CvMat *b, CvMat *X)
QR optimization algorithm.
double fu
Image center in y-direction.
std::vector< double > alphas
void estimate_R_and_t(double R[3][3], double t[3])
Helper function to compute_R_and_t()
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void add_correspondence(const double X, const double Y, const double Z, const double u, const double v)
Add a 2d/3d correspondence.
void find_betas_approx_2(const CvMat *L_6x10, const CvMat *Rho, double *betas)
Internal function.
GLenum GLenum GLvoid * row
double compute_R_and_t(const double *ut, const double *betas, double R[3][3], double t[3])
Function to compute pose.
int max_nr
Internal member variable.
void compute_ccs(const double *betas, const double *ut)
Internal function.
void compute_pcs(void)
Internal function.
GLfloat GLfloat GLfloat v2
double fv
Focal length in x-direction.
epnp(const cv::Mat &cameraMatrix, const cv::Mat &opoints, const cv::Mat &ipoints)
Constructor for EPnP class.
double vc
Image center in x-direction.
void compute_L_6x10(const double *ut, double *l_6x10)
Internal function.
void find_betas_approx_1(const CvMat *L_6x10, const CvMat *Rho, double *betas)
Internal function.