50#include <visp3/core/vpConfig.h>
51#include <visp3/core/vpDebug.h>
52#include <visp3/core/vpMath.h>
53#include <visp3/core/vpRotationMatrix.h>
54#include <visp3/core/vpThetaUVector.h>
55#include <visp3/vision/vpHomography.h>
58#include <visp3/core/vpDebug.h>
59#include <visp3/core/vpHomogeneousMatrix.h>
60#include <visp3/core/vpMath.h>
61#include <visp3/core/vpPoint.h>
62#include <visp3/io/vpParseArgv.h>
69#ifdef ENABLE_VISP_NAMESPACE
73void usage(
const char *name,
const char *badparam);
74bool getOptions(
int argc,
const char **argv);
85void usage(
const char *name,
const char *badparam)
88Test the HLM (Malis) homography estimation algorithm with a 3D object.\n\
100 fprintf(stderr,
"ERROR: \n");
101 fprintf(stderr,
"\nBad parameter [%s]\n", badparam);
114bool getOptions(
int argc,
const char **argv)
122 usage(argv[0],
nullptr);
126 usage(argv[0], optarg_);
131 if ((c == 1) || (c == -1)) {
133 usage(argv[0],
nullptr);
134 std::cerr <<
"ERROR: " << std::endl;
135 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
142int main(
int argc,
const char **argv)
144#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
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++) {
180 for (
unsigned int i = 0;
i < nbpt;
i++) {
190 std::cout <<
"-------------------------------" << std::endl;
191 std::cout <<
"Compare with built homography H = R + t/d n " << std::endl;
194 std::cout <<
"aHb built from the displacement: \n" << aHb_built / aHb_built[2][2] << std::endl;
196 aHb_built.computeDisplacement(aRb, aTb, n);
197 std::cout <<
"Rotation: aRb" << std::endl;
198 std::cout << aRb << std::endl;
199 std::cout <<
"Translation: aTb" << std::endl;
200 std::cout << (aTb).
t() << std::endl;
201 std::cout <<
"Normal to the plane: n" << std::endl;
202 std::cout << (n).
t() << std::endl;
204 std::cout <<
"-------------------------------" << std::endl;
205 std::cout <<
"aMb " << std::endl << aMb << std::endl;
206 std::cout <<
"-------------------------------" << std::endl;
211 std::cout <<
"aHb computed using the Malis paralax algorithm" << std::endl;
213 std::cout << std::endl << aHb << std::endl;
215 std::cout <<
"-------------------------------" << std::endl;
216 std::cout <<
"extract R, T and n " << std::endl;
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 std::cout <<
"test if ap = aHb bp" << std::endl;
228 for (
unsigned int i = 0;
i < nbpt;
i++) {
229 std::cout <<
"Point " <<
i << std::endl;
233 std::cout <<
") = (";
235 std::cout <<
p.get_x() /
p.get_w() <<
", " <<
p.get_y() /
p.get_w() <<
")" << std::endl;
240 std::cout <<
"Catch an exception: " <<
e << std::endl;
246 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.
void computeDisplacement(vpRotationMatrix &aRb, vpTranslationVector &atb, vpColVector &n)
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)
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.