From 3b24aa2441694733bb755489cc1284e4dab07f92 Mon Sep 17 00:00:00 2001 From: edgarriba Date: Wed, 30 Jul 2014 12:53:14 +0200 Subject: [PATCH] Code tutorial --- .../include/PnPProblem.h | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/include/PnPProblem.h diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/include/PnPProblem.h b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/include/PnPProblem.h new file mode 100644 index 000000000..da189d0a0 --- /dev/null +++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/include/PnPProblem.h @@ -0,0 +1,53 @@ +/* + * PnPProblem.h + * + * Created on: Mar 28, 2014 + * Author: Edgar Riba + */ + +#ifndef PNPPROBLEM_H_ +#define PNPPROBLEM_H_ + +#include + +#include +#include + +#include "Mesh.h" +#include "ModelRegistration.h" + +class PnPProblem +{ + +public: + explicit PnPProblem(const double param[]); // custom constructor + virtual ~PnPProblem(); + + bool backproject2DPoint(const Mesh *mesh, const cv::Point2f &point2d, cv::Point3f &point3d); + bool intersect_MollerTrumbore(Ray &R, Triangle &T, double *out); + std::vector verify_points(Mesh *mesh); + cv::Point2f backproject3DPoint(const cv::Point3f &point3d); + bool estimatePose(const std::vector &list_points3d, const std::vector &list_points2d, int flags); + void estimatePoseRANSAC( const std::vector &list_points3d, const std::vector &list_points2d, + int flags, cv::Mat &inliers, + int iterationsCount, float reprojectionError, float confidence ); + + cv::Mat get_A_matrix() const { return _A_matrix; } + cv::Mat get_R_matrix() const { return _R_matrix; } + cv::Mat get_t_matrix() const { return _t_matrix; } + cv::Mat get_P_matrix() const { return _P_matrix; } + + void set_P_matrix( const cv::Mat &R_matrix, const cv::Mat &t_matrix); + +private: + /** The calibration matrix */ + cv::Mat _A_matrix; + /** The computed rotation matrix */ + cv::Mat _R_matrix; + /** The computed translation matrix */ + cv::Mat _t_matrix; + /** The computed projection matrix */ + cv::Mat _P_matrix; +}; + +#endif /* PNPPROBLEM_H_ */