36 #include <visp3/core/vpHomogeneousMatrix.h>
37 #include <visp3/core/vpMath.h>
38 #include <visp3/core/vpPoint.h>
39 #include <visp3/vision/vpPose.h>
55 #ifdef ENABLE_VISP_NAMESPACE
59 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
61 std::cout <<
"Find Matches using Ransac" << std::endl;
62 std::vector<vpPoint> P;
64 P.push_back(
vpPoint(-L, -L, 0));
68 P.push_back(
vpPoint(-0, L / 2., L));
72 std::vector<vpPoint> p(P.size());
73 for (
unsigned int i = 0; i < P.size(); i++) {
76 p[i].set_x(pt.
get_x());
77 p[i].set_y(pt.
get_y());
80 unsigned int ninliers;
81 std::vector<vpPoint> inliers;
82 double threshold = 1e-6;
83 unsigned int nbInlierToReachConsensus = (
unsigned int)(P.size());
87 vpPose::findMatch(p, P, nbInlierToReachConsensus, threshold, ninliers, inliers, cMo);
89 std::cout <<
"Inliers: " << std::endl;
90 for (
unsigned int i = 0; i < inliers.size(); i++) {
92 std::cout << std::endl;
95 std::cout <<
"cMo :\n" <<
vpPoseVector(cMo).
t() << std::endl << std::endl;
100 std::cout << std::endl;
101 std::cout <<
"reference cMo :\n" << pose_ref.
t() << std::endl << std::endl;
102 std::cout <<
"estimated cMo :\n" << pose_est.
t() << std::endl << std::endl;
105 for (
unsigned int i = 0; i < 6; i++) {
106 if (std::fabs(pose_ref[i] - pose_est[i]) > 0.001)
110 std::cout <<
"Matching is " << (test_fail ?
"badly" :
"well") <<
" performed" << std::endl;
112 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;
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
static double rad(double deg)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
double get_y() const
Get the point y coordinate in the image plane.
double get_x() const
Get the point x coordinate in the image plane.
Implementation of a pose vector and operations on poses.
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, FuncCheckValidityPose func=nullptr)