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
58 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
60 std::cout <<
"Pose computation with matched points" << std::endl;
61 std::vector<vpPoint> P;
63 P.push_back(
vpPoint(-L, -L, 0));
69 P.push_back(
vpPoint(0, -L2, 0));
72 P.push_back(
vpPoint(-L2, 0, 0));
75 for (
size_t i = 0; i < P.size(); i++) {
76 P[i].project(cMo_ref);
78 std::cout << std::endl;
83 P[3].set_y(P[3].get_y() + 2 * error);
84 P[6].set_x(P[6].get_x() + error);
87 for (
size_t i = 0; i < P.size(); i++)
90 unsigned int nbInlierToReachConsensus = (
unsigned int)(75.0 * (
double)(P.size()) / 100.0);
91 double threshold = 0.001;
102 std::cout <<
"Inliers: " << std::endl;
103 for (
unsigned int i = 0; i < inliers.size(); i++) {
105 std::cout << std::endl;
111 std::cout << std::endl;
112 std::cout <<
"reference cMo :\n" << pose_ref.
t() << std::endl << std::endl;
113 std::cout <<
"estimated cMo :\n" << pose_est.
t() << std::endl << std::endl;
116 for (
unsigned int i = 0; i < 6; i++) {
117 if (std::fabs(pose_ref[i] - pose_est[i]) > 0.001)
121 std::cout <<
"Pose is " << (test_fail ?
"badly" :
"well") <<
" estimated" << std::endl;
122 return (test_fail ? EXIT_FAILURE : EXIT_SUCCESS);
125 std::cout <<
"Catch an exception: " << e << std::endl;
129 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.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Implementation of a pose vector and operations on poses.
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
void addPoint(const vpPoint &P)
void setRansacNbInliersToReachConsensus(const unsigned int &nbC)
bool computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, FuncCheckValidityPose func=nullptr)
std::vector< vpPoint > getRansacInliers() const
void setRansacThreshold(const double &t)