48#include <visp3/core/vpConfig.h>
49#include <visp3/core/vpDebug.h>
50#include <visp3/core/vpMath.h>
51#include <visp3/core/vpRotationMatrix.h>
52#include <visp3/core/vpThetaUVector.h>
53#include <visp3/vision/vpHomography.h>
56#include <visp3/core/vpDebug.h>
57#include <visp3/core/vpHomogeneousMatrix.h>
58#include <visp3/core/vpMath.h>
59#include <visp3/core/vpPoint.h>
60#include <visp3/io/vpParseArgv.h>
67#ifdef ENABLE_VISP_NAMESPACE
71void usage(
const char *name,
const char *badparam);
72bool getOptions(
int argc,
const char **argv);
83void usage(
const char *name,
const char *badparam)
86Test the HartleyDLT homography estimation algorithm.\n\
98 fprintf(stderr,
"ERROR: \n");
99 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
113bool getOptions(
int argc,
const char **argv)
121 usage(argv[0],
nullptr);
125 usage(argv[0], optarg_);
130 if ((c == 1) || (c == -1)) {
132 usage(argv[0],
nullptr);
133 std::cerr <<
"ERROR: " << std::endl;
134 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
141int main(
int argc,
const char **argv)
143#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
146 if (getOptions(argc, argv) ==
false) {
151 std::vector<double> xa(nbpt), ya(nbpt), xb(nbpt), yb(nbpt);
168 for (
unsigned int i = 0;
i < nbpt;
i++) {
175 for (
unsigned int i = 0;
i < nbpt;
i++) {
181 std::cout <<
"-------------------------------" << std::endl;
182 std::cout <<
"aMb " << std::endl << aMb << std::endl;
183 std::cout <<
"-------------------------------" << std::endl;
188 vpTRACE(
"aHb computed using the DLT algorithm");
190 std::cout << std::endl << aHb << std::endl;
196 std::cout <<
"-------------------------------" << std::endl;
197 vpTRACE(
"extract R, T and 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 vpTRACE(
"Compare with built homoraphy H = R + t/d ");
210 vpTRACE(
"aHb built from the displacement ");
211 std::cout << std::endl << aHb_built / aHb_built[2][2] << std::endl;
213 aHb_built.computeDisplacement(aRb, aTb, n);
214 std::cout <<
"Rotation: aRb" << std::endl;
215 std::cout << aRb << std::endl;
216 std::cout <<
"Translation: aTb" << std::endl;
217 std::cout << (aTb).
t() << std::endl;
218 std::cout <<
"Normal to the plane: n" << std::endl;
219 std::cout << (n).
t() << std::endl;
221 std::cout <<
"-------------------------------" << std::endl;
222 vpTRACE(
"test if ap = aHb bp");
224 for (
unsigned int i = 0;
i < nbpt;
i++) {
225 std::cout <<
"Point " <<
i << std::endl;
229 std::cout <<
") = (";
231 std::cout <<
p.get_x() /
p.get_w() <<
", " <<
p.get_y() /
p.get_w() <<
")" << std::endl;
236 std::cout <<
"Catch an exception: " <<
e << std::endl;
242 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of an homography and operations on homographies.
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)
void computeDisplacement(vpRotationMatrix &aRb, vpTranslationVector &atb, vpColVector &n)
static double rad(double deg)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
This class defines the container for a plane geometrical structure.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
double get_w() const
Get the point w coordinate in the image plane.
double get_y() const
Get the point y coordinate in the image plane.
double get_x() const
Get the point x coordinate in the image plane.
void setWorldCoordinates(double oX, double oY, double oZ)
Implementation of a rotation matrix and operations on such kind of matrices.
Class that consider the case of a translation vector.