57 #include <visp/vpMath.h>
58 #include <visp/vpRotationMatrix.h>
59 #include <visp/vpHomography.h>
60 #include <visp/vpDebug.h>
61 #include <visp/vpThetaUVector.h>
63 #include <visp/vpPoint.h>
64 #include <visp/vpMath.h>
65 #include <visp/vpHomogeneousMatrix.h>
66 #include <visp/vpDebug.h>
67 #include <visp/vpParseArgv.h>
70 #define GETOPTARGS "h"
75 void usage(
const char *name,
const char *badparam);
76 bool getOptions(
int argc,
const char **argv);
87 void usage(
const char *name,
const char *badparam)
90 Test the HLM (Malis) homography estimation algorithm with a 3D object.\n\
101 fprintf(stderr,
"ERROR: \n" );
102 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
115 bool getOptions(
int argc,
const char **argv)
122 case 'h': usage(argv[0], NULL);
return false;
break;
125 usage(argv[0], optarg_);
130 if ((c == 1) || (c == -1)) {
132 usage(argv[0], NULL);
133 std::cerr <<
"ERROR: " << std::endl;
134 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
143 main(
int argc,
const char ** argv)
147 if (getOptions(argc, argv) ==
false) {
152 std::vector<double> xa(nbpt), ya(nbpt) ;
153 std::vector<double> xb(nbpt), yb(nbpt) ;
173 for(
unsigned int i=0 ; i < nbpt ; i++)
177 xa[i] = P[i].
get_x() ;
178 ya[i] = P[i].
get_y() ;
181 for(
unsigned int i=0 ; i < nbpt ; i++)
185 xb[i] = P[i].
get_x() ;
186 yb[i] = P[i].
get_y() ;
192 std::cout <<
"-------------------------------" << std::endl ;
193 std::cout <<
"Compare with built homography H = R + t/d n " << std::endl ;
196 std::cout <<
"aHb built from the displacement: \n" << aHb_built/aHb_built[2][2] << std::endl ;
198 aHb_built.computeDisplacement(aRb, aTb, n) ;
199 std::cout <<
"Rotation: aRb" <<std::endl ;
200 std::cout << aRb << std::endl ;
201 std::cout <<
"Translation: aTb" <<std::endl;
202 std::cout << (aTb).t() <<std::endl ;
203 std::cout <<
"Normal to the plane: n" <<std::endl;
204 std::cout << (n).t() <<std::endl ;
206 std::cout <<
"-------------------------------" <<std::endl ;
207 std::cout <<
"aMb "<<std::endl <<aMb << std::endl ;
208 std::cout <<
"-------------------------------" <<std::endl ;
213 std::cout <<
"aHb computed using the Malis paralax algorithm" << std::endl ;
215 std::cout << std::endl << aHb<< std::endl ;
217 std::cout <<
"-------------------------------" <<std::endl ;
218 std::cout <<
"extract R, T and n " << std::endl ;
220 std::cout <<
"Rotation: aRb" <<std::endl ;
221 std::cout << aRb << std::endl ;
222 std::cout <<
"Translation: aTb" <<std::endl;
223 std::cout << (aTb).t() <<std::endl ;
224 std::cout <<
"Normal to the plane: n" <<std::endl;
225 std::cout << (n).t() <<std::endl ;
227 std::cout <<
"-------------------------------" <<std::endl ;
228 std::cout <<
"test if ap = aHb bp" << std::endl ;
230 for(
unsigned int i=0 ; i < nbpt ; i++)
232 std::cout <<
"Point "<< i<< std::endl ;
236 std::cout <<
") = (" ;
243 std::cout <<
"Catch an exception: " << e << std::endl;
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
error that can be emited by ViSP classes.
double get_y() const
Get the point y coordinate in the image plane.
double get_w() const
Get the point w coordinate in the image plane.
void computeDisplacement(vpRotationMatrix &aRb, vpTranslationVector &atb, vpColVector &n)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that defines what is a point.
static void HLM(const std::vector< double > &xb, const std::vector< double > &yb, const std::vector< double > &xa, const std::vector< double > &ya, bool isplanar, vpHomography &aHb)
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...
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...