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 <<
"Pose computation with matched points" << std::endl;
63 std::vector<vpPoint> P;
65 P.push_back(
vpPoint(-L, -L, 0));
71 P.push_back(
vpPoint(0, -L2, 0));
74 P.push_back(
vpPoint(-L2, 0, 0));
77 for (
size_t i = 0; i < P.size(); i++) {
78 P[i].project(cMo_ref);
80 std::cout << std::endl;
85 P[3].set_y(P[3].get_y() + 2 * error);
86 P[6].set_x(P[6].get_x() + error);
89 for (
size_t i = 0; i < P.size(); i++)
92 unsigned int nbInlierToReachConsensus = (
unsigned int)(75.0 * (
double)(P.size()) / 100.0);
93 double threshold = 0.001;
104 std::cout <<
"Inliers: " << std::endl;
105 for (
unsigned int i = 0; i < inliers.size(); i++) {
107 std::cout << std::endl;
113 std::cout << std::endl;
114 std::cout <<
"reference cMo :\n" << pose_ref.
t() << std::endl << std::endl;
115 std::cout <<
"estimated cMo :\n" << pose_est.
t() << std::endl << std::endl;
118 for (
unsigned int i = 0; i < 6; i++) {
119 if (std::fabs(pose_ref[i] - pose_est[i]) > 0.001)
123 std::cout <<
"Pose is " << (test_fail ?
"badly" :
"well") <<
" estimated" << std::endl;
124 return (test_fail ? EXIT_FAILURE : EXIT_SUCCESS);
126 std::cout <<
"Catch an exception: " << e << std::endl;
130 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, 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.
void setRansacThreshold(const double &t)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
void setRansacNbInliersToReachConsensus(const unsigned int &nbC)
Implementation of a pose vector and operations on poses.
void addPoint(const vpPoint &P)
std::vector< vpPoint > getRansacInliers() const