60 #include <visp/vpMath.h>
61 #include <visp/vpRotationMatrix.h>
62 #include <visp/vpHomography.h>
63 #include <visp/vpDebug.h>
64 #include <visp/vpThetaUVector.h>
66 #include <visp/vpPoint.h>
67 #include <visp/vpMath.h>
68 #include <visp/vpHomogeneousMatrix.h>
69 #include <visp/vpDebug.h>
71 #include <visp/vpRansac.h>
72 #include <visp/vpParseArgv.h>
75 #define GETOPTARGS "h"
88 void usage(
const char *name,
const char *badparam)
91 Test the Ransac homography estimation algorithm.\n\
102 fprintf(stderr,
"ERROR: \n" );
103 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
116 bool getOptions(
int argc,
const char **argv)
123 case 'h': usage(argv[0], NULL);
return false;
break;
126 usage(argv[0], optarg);
131 if ((c == 1) || (c == -1)) {
133 usage(argv[0], NULL);
134 std::cerr <<
"ERROR: " << std::endl;
135 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
144 main(
int argc,
const char ** argv)
147 if (getOptions(argc, argv) ==
false) {
154 double xa[nbpt], ya[nbpt] ;
155 double xb[nbpt], yb[nbpt] ;
178 for(i=0 ; i < nbpt ; i++)
182 xa[i] = P[i].
get_x() ;
183 ya[i] = P[i].
get_y() ;
186 for(i=0 ; i < nbpt ; i++)
190 xb[i] = P[i].
get_x() ;
191 yb[i] = P[i].
get_y() ;
193 std::cout <<
"-------------------------------" <<std::endl ;
198 vpTRACE(
"Compare with built homography H = R + t/d n ") ;
201 vpTRACE(
"aHb built from the displacement ") ;
202 std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ;
204 aHb_built.computeDisplacement(aRb, aTb, n) ;
205 std::cout <<
"Rotation aRb: " <<std::endl ;
206 std::cout << aRb << std::endl ;
207 std::cout <<
"Translation: aTb" <<std::endl;
208 std::cout << (aTb).t() <<std::endl ;
209 std::cout <<
"Normal to the plane: n" <<std::endl;
210 std::cout << (n).t() <<std::endl ;
212 std::cout <<
"-------------------------------" <<std::endl ;
217 std::cout << aHb << std::endl ;
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
double get_y() const
Get the point y coordinate in the image plane.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that defines what is a point.
The vpRotationMatrix considers the particular case of a rotation matrix.
This class aims to compute the homography wrt.two images.
double get_x() const
Get the point x coordinate in the image plane.
static double rad(double deg)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
static bool ransac(unsigned int n, double *xb, double *yb, double *xa, double *ya, vpHomography &aHb, int consensus=1000, double threshold=1e-6)
This class defines the container for a plane geometrical structure.
Class that consider the case of a translation vector.
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...