Compute the pose of a 3D object using the Ransac method.
#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 << "Pose computation with matched points" << std::endl;
int size = 8;
double L2 = L*3.0;
for(int i=0 ; i < size ; i++)
{
std::cout << std::endl;
}
double error = 0.01;
P[3].
set_y(P[3].get_y() + 2*error);
P[6].
set_x(P[6].get_x() + error);
for(int i=0 ; i < size ; i++)
unsigned int nbInlierToReachConsensus = (unsigned int)(75.0 * (double)size / 100.0);
double threshold = 0.001;
std::cout << "Inliers: " << std::endl;
for (unsigned int i = 0; i < inliers.size() ; i++)
{
inliers[i].print() ;
std::cout << 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 << "Pose is " << (test_fail ? "badly" : "well") << " estimated" << std::endl;
delete [] P;
return test_fail;
}
std::cout << "Catch an exception: " << e << std::endl;
return 1;
}
}