Find Matches using Ransac.
#include <visp/vpPose.h>
#include <visp/vpPoint.h>
#include <visp/vpMath.h>
#include <visp/vpHomogeneousMatrix.h>
#include <stdlib.h>
#include <stdio.h>
#define L 0.1
int
main()
{
try {
std::cout << "Find Matches using Ransac" << std::endl;
unsigned int nb3D = 5;
unsigned int nb2D = 5;
std::vector<vpPoint> P(nb3D);
std::vector<vpPoint> p(nb2D);
P[0].setWorldCoordinates(-L,-L, 0 ) ;
P[1].setWorldCoordinates(L,-L, 0 ) ;
P[2].setWorldCoordinates(L,L, 0 ) ;
P[3].setWorldCoordinates(-L,L, 0 ) ;
P[4].setWorldCoordinates(-0,L/2., L ) ;
for(unsigned int i=0 ; i < nb3D ; i++)
{
}
unsigned int ninliers ;
std::vector<vpPoint> inliers;
double threshold = 1e-6;
unsigned int nbInlierToReachConsensus = nb3D;
std::cout << "Inliers: " << std::endl;
for (unsigned int i = 0; i < inliers.size() ; i++)
{
inliers[i].print() ;
std::cout << std::endl;
}
std::cout <<
"cMo :\n" <<
vpPoseVector(cMo).
t() << std::endl << std::endl;
std::cout << std::endl;
std::cout <<
"reference cMo :\n" << pose_ref.
t() << std::endl << std::endl;
std::cout <<
"estimated cMo :\n" << pose_est.
t() << std::endl << std::endl;
int test_fail = 0;
for(unsigned int i=0; i<6; i++) {
if (std::fabs(pose_ref[i]-pose_est[i]) > 0.001)
test_fail = 1;
}
std::cout << "Matching is " << (test_fail ? "badly" : "well") << " performed" << std::endl;
return test_fail;
}
std::cout << "Catch an exception: " << e << std::endl;
return 1;
}
}