41 #include <visp3/core/vpHomogeneousMatrix.h> 42 #include <visp3/core/vpMath.h> 43 #include <visp3/core/vpPoint.h> 44 #include <visp3/vision/vpPose.h> 60 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) 62 std::cout <<
"Find Matches using Ransac" << std::endl;
63 std::vector<vpPoint> P;
65 P.push_back(
vpPoint(-L, -L, 0));
69 P.push_back(
vpPoint(-0, L / 2., L));
73 std::vector<vpPoint> p(P.size());
74 for (
unsigned int i = 0; i < P.size(); i++) {
77 p[i].set_x(pt.
get_x());
78 p[i].set_y(pt.
get_y());
81 unsigned int ninliers;
82 std::vector<vpPoint> inliers;
83 double threshold = 1e-6;
84 unsigned int nbInlierToReachConsensus = (
unsigned int)(P.size());
88 vpPose::findMatch(p, P, nbInlierToReachConsensus, threshold, ninliers, inliers, cMo);
90 std::cout <<
"Inliers: " << std::endl;
91 for (
unsigned int i = 0; i < inliers.size(); i++) {
93 std::cout << std::endl;
96 std::cout <<
"cMo :\n" <<
vpPoseVector(cMo).
t() << std::endl << std::endl;
101 std::cout << std::endl;
102 std::cout <<
"reference cMo :\n" << pose_ref.
t() << std::endl << std::endl;
103 std::cout <<
"estimated cMo :\n" << pose_est.
t() << std::endl << std::endl;
106 for (
unsigned int i = 0; i < 6; i++) {
107 if (std::fabs(pose_ref[i] - pose_est[i]) > 0.001)
111 std::cout <<
"Matching is " << (test_fail ?
"badly" :
"well") <<
" performed" << std::endl;
113 return (test_fail ? EXIT_FAILURE : EXIT_SUCCESS);
115 std::cout <<
"Catch an exception: " << e << std::endl;
119 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
static void findMatch(std::vector< vpPoint > &p2D, std::vector< vpPoint > &p3D, const unsigned int &numberOfInlierToReachAConsensus, const double &threshold, unsigned int &ninliers, std::vector< vpPoint > &listInliers, vpHomogeneousMatrix &cMo, const int &maxNbTrials=10000, bool useParallelRansac=true, unsigned int nthreads=0, bool(*func)(const vpHomogeneousMatrix &)=NULL)
Implementation of an homogeneous matrix and operations on such kind of matrices.
error that can be emited by ViSP classes.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
static double rad(double deg)
double get_x() const
Get the point x coordinate in the image plane.
Implementation of a pose vector and operations on poses.
double get_y() const
Get the point y coordinate in the image plane.