11 #include <mrpt/3rdparty/do_opencv_includes.h> 34 const cv::Mat& cameraMatrix,
const cv::Mat& opoints,
35 const cv::Mat& ipoints);
49 const double X,
const double Y,
const double Z,
const double u,
67 uc = cameraMatrix.at<T>(0, 2);
68 vc = cameraMatrix.at<T>(1, 2);
69 fu = cameraMatrix.at<T>(0, 0);
70 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>(i, 0);
85 pws[3 * i + 1] = opoints.at<OpointType>(i, 1);
86 pws[3 * i + 2] = opoints.at<OpointType>(i, 2);
88 us[2 * i] = ipoints.at<IpointType>(i, 0) *
fu +
uc;
89 us[2 * i + 1] = ipoints.at<IpointType>(i, 1) *
fv +
vc;
121 CvMat* M,
const int row,
const double*
alphas,
const double u,
129 void compute_ccs(
const double* betas,
const double* ut);
148 const CvMat* L_6x10,
const CvMat* Rho,
double* betas);
157 const CvMat* L_6x10,
const CvMat* Rho,
double* betas);
166 const CvMat* L_6x10,
const CvMat* Rho,
double* betas);
174 void qr_solve(CvMat*
A, CvMat* b, CvMat* X);
182 double dot(
const double* v1,
const double* v2);
190 double dist2(
const double* p1,
const double* p2);
212 const CvMat* L_6x10,
const CvMat* Rho,
double current_betas[4]);
223 const double* l_6x10,
const double* rho,
const double cb[4], CvMat*
A,
235 const double* ut,
const double* betas,
double R[3][3],
double t[3]);
252 const double R_dst[3][3],
const double t_dst[3],
double R_src[3][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.
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.
Perspective n Point (PnP) Algorithms toolkit for MRPT mrpt_vision_grp.
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 compute_barycentric_coordinates()
Convert from object space to relative object space (Barycentric coordinates)
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.
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.
void compute_pcs()
Internal function.
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 choose_control_points()
Function to select 4 control points from n points.
void estimate_R_and_t(double R[3][3], double t[3])
Helper function to compute_R_and_t()
void solve_for_sign()
Internal function.
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.
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.
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.