Go to the documentation of this file.
62 #ifndef OPENCV_CALIB3D_UPNP_H_
63 #define OPENCV_CALIB3D_UPNP_H_
65 #include <mrpt/config.h>
66 #include <mrpt/otherlibs/do_opencv_includes.h>
95 const cv::Mat& cameraMatrix,
const cv::Mat& opoints,
96 const cv::Mat& ipoints);
114 template <
typename T>
117 uc = cameraMatrix.at<T>(0, 2);
118 vc = cameraMatrix.at<T>(1, 2);
128 template <
typename Opo
intType,
typename Ipo
intType>
133 pws[3 * i] = opoints.at<OpointType>(i).
x;
134 pws[3 * i + 1] = opoints.at<OpointType>(i).
y;
135 pws[3 * i + 2] = opoints.at<OpointType>(i).
z;
137 us[2 * i] = ipoints.at<IpointType>(i).
x;
138 us[2 * i + 1] = ipoints.at<IpointType>(i).
y;
170 cv::Mat* M,
const int row,
const double*
alphas,
const double u,
178 void compute_ccs(
const double* betas,
const double* ut);
198 cv::Mat* Ut, cv::Mat* Rho,
double* betas,
double* efs);
208 cv::Mat* Ut, cv::Mat* Rho,
double* betas,
double* efs);
216 void qr_solve(cv::Mat* A, cv::Mat*
b, cv::Mat* X);
233 const cv::Mat& M1,
const cv::Mat& M2);
241 const double betas[5],
double solutions[18][3]);
248 double sign(
const double v);
256 double dot(
const double*
v1,
const double*
v2);
264 double dotXY(
const double*
v1,
const double*
v2);
272 double dotZ(
const double*
v1,
const double*
v2);
280 double dist2(
const double* p1,
const double* p2);
303 const cv::Mat* L_6x12,
const cv::Mat* Rho,
double current_betas[4],
316 const double* l_6x12,
const double* rho,
const double cb[4], cv::Mat* A,
317 cv::Mat*
b,
double const f);
328 const double* ut,
const double* betas,
double R[3][3],
double t[3]);
345 const double R_dst[3][3],
const double t_dst[3],
double R_src[3][3],
354 std::vector<double>
us;
367 #endif // Check for OPENCV_LIB
368 #endif // OPENCV_CALIB3D_UPNP_H_
void estimate_R_and_t(double R[3][3], double t[3])
Helper function to function compute_R_and_t()
double fu
Image center in y-direction.
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])
Function to copy the pose.
void compute_rho(double *rho)
Internal fucntion.
double dotXY(const double *v1, const double *v2)
Compute dot product in 2D with only x and y components.
double compute_pose(cv::Mat &R, cv::Mat &t)
Function to compute pose.
std::vector< double > pws
Focal length in y-direction.
void compute_ccs(const double *betas, const double *ut)
Compute the control points.
void choose_control_points()
Function to select 4 control points.
double dot(const double *v1, const double *v2)
Compute the dot product between two vectors.
void compute_alphas()
Function to comput @alphas.
void fill_M(cv::Mat *M, const int row, const double *alphas, const double u, const double v)
Function to compute Maucaulay matrix M.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void init_camera_parameters(const cv::Mat &cameraMatrix)
Initialize camera variables using camera intrinsic matrix.
upnp(const cv::Mat &cameraMatrix, const cv::Mat &opoints, const cv::Mat &ipoints)
Constructor for UPnP class.
double dotZ(const double *v1, const double *v2)
Compute the dot product using only z component.
void find_betas_and_focal_approx_1(cv::Mat *Ut, cv::Mat *Rho, double *betas, double *efs)
Function to approximately calculate betas and focal length.
void compute_pcs(void)
Compute object points based on control points.
double * A1
Internal variable.
int number_of_correspondences
Internal variable.
std::vector< double > pcs
double compute_R_and_t(const double *ut, const double *betas, double R[3][3], double t[3])
Function to compute the pose.
void qr_solve(cv::Mat *A, cv::Mat *b, cv::Mat *X)
Function to do a QR decomposition.
void generate_all_possible_solutions_for_f_unk(const double betas[5], double solutions[18][3])
Get all possible solutions.
double vc
Image center in x-direction.
std::vector< double > us
Object points.
cv::Mat compute_constraint_distance_3param_6eq_6unk_f_unk(const cv::Mat &M1, const cv::Mat &M2)
Internal function.
void compute_L_6x12(const double *ut, double *l_6x12)
Internal function.
GLfloat GLfloat GLfloat v2
void gauss_newton(const cv::Mat *L_6x12, const cv::Mat *Rho, double current_betas[4], double *efs)
Gauss Newton Iterative optimization.
void init_points(const cv::Mat &opoints, const cv::Mat &ipoints)
Iniialize Object points and image points from OpenCV Matrix.
void compute_A_and_b_gauss_newton(const double *l_6x12, const double *rho, const double cb[4], cv::Mat *A, cv::Mat *b, double const f)
Compute matrix A and vector b.
double sign(const double v)
Return the sign of the scalar.
GLenum GLenum GLvoid * row
~upnp()
Destructor for UPnP class.
int max_nr
Control point variables.
std::vector< double > alphas
Image points.
double dist2(const double *p1, const double *p2)
Compute the euclidean distance squared between two points in 3D.
void find_betas_and_focal_approx_2(cv::Mat *Ut, cv::Mat *Rho, double *betas, double *efs)
Function to calculate betas and focal length (more accurate)
double fv
Focal length in x-direction.
void solve_for_sign(void)
Internal member function.
double reprojection_error(const double R[3][3], const double t[3])
Compute the reprojection error using the estimated Rotation matrix and Translation Vector.
double cws[4][3]
Number of 2d/3d correspondences.
cv::Mat compute_constraint_distance_2param_6eq_2unk_f_unk(const cv::Mat &M1)
Internal function.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |