#include <visp3/core/vpMath.h>
#include <visp3/core/vpRotationMatrix.h>
#include <visp3/vision/vpHomography.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpThetaUVector.h>
#include <visp3/core/vpPoint.h>
#include <visp3/core/vpMath.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpDebug.h>
#include <visp3/io/vpParseArgv.h>
#include <stdlib.h>
#define GETOPTARGS "h"
#define L 0.1
#define nbpt 5
void usage(const char *name, const char *badparam);
bool getOptions(int argc, const char **argv);
void usage(const char *name, const char *badparam)
{
fprintf(stdout, "\n\
Test the HartleyDLT homography estimation algorithm.\n\
\n\
SYNOPSIS\n\
%s [-h]\n", name);
fprintf(stdout, "\n\
OPTIONS: Default\n\
-h\n\
Print the help.\n");
if (badparam) {
fprintf(stderr, "ERROR: \n" );
fprintf(stderr, "\nBad parameter [%s]\n", badparam);
}
}
bool getOptions(int argc, const char **argv)
{
const char *optarg_;
int c;
switch (c) {
case 'h': usage(argv[0], NULL); return false; break;
default:
usage(argv[0], optarg_);
return false; break;
}
}
if ((c == 1) || (c == -1)) {
usage(argv[0], NULL);
std::cerr << "ERROR: " << std::endl;
std::cerr << " Bad argument " << optarg_ << std::endl << std::endl;
return false;
}
return true;
}
int
main(int argc, const char ** argv)
{
try {
if (getOptions(argc, argv) == false) {
exit (-1);
}
std::vector<double> xa(nbpt), ya(nbpt), xb(nbpt), yb(nbpt);
for(unsigned int i=0 ; i < nbpt ; i++)
{
aP[i] = P[i] ;
}
for(unsigned int i=0 ; i < nbpt ; i++)
{
bP[i] = P[i] ;
}
std::cout << "-------------------------------" <<std::endl ;
std::cout << "aMb "<<std::endl <<aMb << std::endl ;
std::cout << "-------------------------------" <<std::endl ;
vpTRACE(
"aHb computed using the DLT algorithm") ;
aHb /= aHb[2][2] ;
std::cout << std::endl << aHb<< std::endl ;
std::cout << "-------------------------------" <<std::endl ;
std::cout << "Rotation: aRb" <<std::endl ;
std::cout << aRb << std::endl ;
std::cout << "Translation: aTb" <<std::endl;
std::cout << (aTb).t() <<std::endl ;
std::cout << "Normal to the plane: n" <<std::endl;
std::cout << (n).t() <<std::endl ;
std::cout << "-------------------------------" <<std::endl ;
vpTRACE(
"Compare with built homoraphy H = R + t/d ") ;
vpTRACE(
"aHb built from the displacement ") ;
std::cout << std::endl <<aHb_built/aHb_built[2][2] << std::endl ;
aHb_built.computeDisplacement(aRb, aTb, n) ;
std::cout << "Rotation: aRb" <<std::endl ;
std::cout << aRb << std::endl ;
std::cout << "Translation: aTb" <<std::endl;
std::cout << (aTb).t() <<std::endl ;
std::cout << "Normal to the plane: n" <<std::endl;
std::cout << (n).t() <<std::endl ;
std::cout << "-------------------------------" <<std::endl ;
for(unsigned int i=0 ; i < nbpt ; i++)
{
std::cout << "Point "<< i<< std::endl ;
std::cout << "(" ;
std::cout <<") = (" ;
p = aHb*bP[i] ;
}
return 0;
}
std::cout << "Catch an exception: " << e << std::endl;
return 1;
}
}