58 #include <visp/vpMath.h>
59 #include <visp/vpRotationMatrix.h>
60 #include <visp/vpHomography.h>
61 #include <visp/vpDebug.h>
62 #include <visp/vpThetaUVector.h>
64 #include <visp/vpPoint.h>
65 #include <visp/vpMath.h>
66 #include <visp/vpHomogeneousMatrix.h>
67 #include <visp/vpDebug.h>
68 #include <visp/vpParseArgv.h>
71 #define GETOPTARGS "h"
76 void usage(
const char *name,
const char *badparam);
77 bool getOptions(
int argc,
const char **argv);
88 void usage(
const char *name,
const char *badparam)
91 Test the HartleyDLT homography estimation algorithm.\n\
102 fprintf(stderr,
"ERROR: \n" );
103 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
117 bool getOptions(
int argc,
const char **argv)
124 case 'h': usage(argv[0], NULL);
return false;
break;
127 usage(argv[0], optarg_);
132 if ((c == 1) || (c == -1)) {
134 usage(argv[0], NULL);
135 std::cerr <<
"ERROR: " << std::endl;
136 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
145 main(
int argc,
const char ** argv)
149 if (getOptions(argc, argv) ==
false) {
154 std::vector<double> xa(nbpt), ya(nbpt), xb(nbpt), yb(nbpt);
171 for(
unsigned int i=0 ; i < nbpt ; i++)
175 xa[i] = P[i].
get_x() ;
176 ya[i] = P[i].
get_y() ;
179 for(
unsigned int i=0 ; i < nbpt ; i++)
183 xb[i] = P[i].
get_x() ;
184 yb[i] = P[i].
get_y() ;
186 std::cout <<
"-------------------------------" <<std::endl ;
187 std::cout <<
"aMb "<<std::endl <<aMb << std::endl ;
188 std::cout <<
"-------------------------------" <<std::endl ;
193 vpTRACE(
"aHb computed using the DLT algorithm") ;
195 std::cout << std::endl << aHb<< std::endl ;
201 std::cout <<
"-------------------------------" <<std::endl ;
202 vpTRACE(
"extract R, T and n ") ;
204 std::cout <<
"Rotation: aRb" <<std::endl ;
205 std::cout << aRb << std::endl ;
206 std::cout <<
"Translation: aTb" <<std::endl;
207 std::cout << (aTb).t() <<std::endl ;
208 std::cout <<
"Normal to the plane: n" <<std::endl;
209 std::cout << (n).t() <<std::endl ;
211 std::cout <<
"-------------------------------" <<std::endl ;
212 vpTRACE(
"Compare with built homoraphy H = R + t/d ") ;
215 vpTRACE(
"aHb built from the displacement ") ;
216 std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ;
218 aHb_built.computeDisplacement(aRb, aTb, n) ;
219 std::cout <<
"Rotation: aRb" <<std::endl ;
220 std::cout << aRb << std::endl ;
221 std::cout <<
"Translation: aTb" <<std::endl;
222 std::cout << (aTb).t() <<std::endl ;
223 std::cout <<
"Normal to the plane: n" <<std::endl;
224 std::cout << (n).t() <<std::endl ;
226 std::cout <<
"-------------------------------" <<std::endl ;
227 vpTRACE(
"test if ap = aHb bp") ;
229 for(
unsigned int i=0 ; i < nbpt ; i++)
231 std::cout <<
"Point "<< i<< std::endl ;
235 std::cout <<
") = (" ;
242 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.
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)
static void DLT(const std::vector< double > &xb, const std::vector< double > &yb, const std::vector< double > &xa, const std::vector< double > &ya, vpHomography &aHb, bool normalization=true)
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...