59 #include <visp/vpMath.h>
60 #include <visp/vpRotationMatrix.h>
61 #include <visp/vpHomography.h>
62 #include <visp/vpDebug.h>
63 #include <visp/vpThetaUVector.h>
65 #include <visp/vpPoint.h>
66 #include <visp/vpMath.h>
67 #include <visp/vpHomogeneousMatrix.h>
68 #include <visp/vpDebug.h>
69 #include <visp/vpParseArgv.h>
72 #define GETOPTARGS "h"
85 void usage(
const char *name,
const char *badparam)
88 Test the HLM (Malis) homography estimation algorithm with a planar object.\n\
99 fprintf(stderr,
"ERROR: \n" );
100 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
113 bool getOptions(
int argc,
const char **argv)
120 case 'h': usage(argv[0], NULL);
return false;
break;
123 usage(argv[0], optarg);
128 if ((c == 1) || (c == -1)) {
130 usage(argv[0], NULL);
131 std::cerr <<
"ERROR: " << std::endl;
132 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
141 main(
int argc,
const char ** argv)
144 if (getOptions(argc, argv) ==
false) {
151 double xa[nbpt], ya[nbpt] ;
152 double xb[nbpt], yb[nbpt] ;
169 for(i=0 ; i < nbpt ; i++)
173 xa[i] = P[i].
get_x() ;
174 ya[i] = P[i].
get_y() ;
177 for(i=0 ; i < nbpt ; i++)
181 xb[i] = P[i].
get_x() ;
182 yb[i] = P[i].
get_y() ;
184 std::cout <<
"-------------------------------" <<std::endl ;
185 std::cout <<
"aMb "<<std::endl <<aMb << std::endl ;
186 std::cout <<
"-------------------------------" <<std::endl ;
191 vpTRACE(
"aHb computed using the Malis paralax algorithm") ;
193 std::cout << std::endl << aHb<< std::endl ;
199 std::cout <<
"-------------------------------" <<std::endl ;
200 vpTRACE(
"extract R, T and n ") ;
202 std::cout <<
"Rotation: aRb" <<std::endl ;
203 std::cout << aRb << std::endl ;
204 std::cout <<
"Translation: aTb" <<std::endl;
205 std::cout << (aTb).t() <<std::endl ;
206 std::cout <<
"Normal to the plane: n" <<std::endl;
207 std::cout << (n).t() <<std::endl ;
210 std::cout <<
"-------------------------------" <<std::endl ;
211 vpTRACE(
"Compare with built homography H = R + t/d ") ;
214 vpTRACE(
"aHb built from the displacement ") ;
215 std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ;
217 aHb_built.computeDisplacement(aRb, aTb, n) ;
218 std::cout <<
"Rotation: aRb" <<std::endl ;
219 std::cout << aRb << std::endl ;
220 std::cout <<
"Translation: aTb" <<std::endl;
221 std::cout << (aTb).t() <<std::endl ;
222 std::cout <<
"Normal to the plane: n" <<std::endl;
223 std::cout << (n).t() <<std::endl ;
225 std::cout <<
"-------------------------------" <<std::endl ;
226 vpTRACE(
"test if ap = aHb bp") ;
228 for(i=0 ; i < nbpt ; i++)
230 std::cout <<
"Point "<< i<< std::endl ;
234 std::cout <<
") = (" ;
239 std::cout <<
"-------------------------------" <<std::endl ;
242 std::list<vpRotationMatrix> laRb ;
243 std::list<vpTranslationVector> laTb ;
244 std::list<vpColVector> lnb ;
249 std::list<vpRotationMatrix>::const_iterator it_laRb = laRb.begin();
250 std::list<vpTranslationVector>::const_iterator it_laTb = laTb.begin();
251 std::list<vpColVector>::const_iterator it_lnb = lnb.begin();
254 while (it_lnb != lnb.end())
256 std::cout <<
"Solution " << k++ << std::endl ;
261 std::cout <<
"Rotation: aRb" <<std::endl ;
262 std::cout << aRb << std::endl ;
263 std::cout <<
"Translation: aTb" <<std::endl;
264 std::cout << (aTb).t() <<std::endl ;
265 std::cout <<
"Normal to the plane: n" <<std::endl;
266 std::cout << (n).t() <<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.
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.
The vpRotationMatrix considers the particular case of a rotation matrix.
This class aims to compute the homography wrt.two images.
static void HLM(unsigned int n, double *xb, double *yb, double *xa, double *ya, bool isplan, vpHomography &aHb)
Computes the homography matrix from planar or non planar points using Ezio Malis linear method (HLM)...
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...