12 #include <mrpt/otherlibs/do_opencv_includes.h> 35 const cv::Mat& cameraMatrix,
const cv::Mat& opoints,
36 const cv::Mat& ipoints);
50 const double X,
const double Y,
const double Z,
const double u,
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);
80 template <
typename Opo
intType,
typename Ipo
intType>
81 void init_points(
const cv::Mat& opoints,
const cv::Mat& ipoints)
85 pws[3 * i] = opoints.at<OpointType>(i, 0);
86 pws[3 * i + 1] = opoints.at<OpointType>(i, 1);
87 pws[3 * i + 2] = opoints.at<OpointType>(i, 2);
89 us[2 * i] = ipoints.at<IpointType>(i, 0) *
fu +
uc;
90 us[2 * i + 1] = ipoints.at<IpointType>(i, 1) *
fv +
vc;
122 CvMat* M,
const int row,
const double*
alphas,
const double u,
130 void compute_ccs(
const double* betas,
const double* ut);
149 const CvMat* L_6x10,
const CvMat* Rho,
double* betas);
158 const CvMat* L_6x10,
const CvMat* Rho,
double* betas);
167 const CvMat* L_6x10,
const CvMat* Rho,
double* betas);
175 void qr_solve(CvMat* A, CvMat*
b, CvMat* X);
183 double dot(
const double*
v1,
const double*
v2);
191 double dist2(
const double* p1,
const double* p2);
213 const CvMat* L_6x10,
const CvMat* Rho,
double current_betas[4]);
224 const double* l_6x10,
const double* rho,
const double cb[4], CvMat* A,
236 const double* ut,
const double* betas,
double R[3][3],
double t[3]);
253 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.
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.
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 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()
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.