#include <stdio.h>
#include <stdlib.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpMath.h>
#include <visp3/core/vpRotationMatrix.h>
#include <visp3/core/vpThetaUVector.h>
#include <visp3/vision/vpHomography.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
bool test(
const std::string &s,
const vpHomography &H,
const std::vector<double> &bench)
{
static unsigned int cpt = 0;
std::cout << "** Test " << ++cpt << std::endl;
std::cout << s <<
"(" << H.
getRows() <<
"," << H.
getCols() <<
") = \n[" << H <<
"]" << std::endl;
if (bench.size() != H.
size()) {
std::cout << "Test fails: bad size wrt bench" << std::endl;
return false;
}
for (
unsigned int i = 0; i < H.
size(); i++) {
if (std::fabs(H.
data[i] - bench[i]) > std::fabs(H.
data[i]) * std::numeric_limits<double>::epsilon()) {
std::cout << "Test fails: bad content" << std::endl;
return false;
}
}
return true;
}
int main()
{
#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
try {
{
std::vector<double> bench(9, 0);
bench[0] = bench[4] = bench[8] = 1.;
int err = 1;
if (test("H", H, bench) == false)
return err;
if (test("H", H / H[2][2], bench) == false)
return err;
}
{
std::cout << "Initialization " << std::endl;
std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl;
std::cout << "M" << std::endl << M << std::endl;
std::cout << "H" << std::endl << H << std::endl;
std::cout << "R" << std::endl << R;
std::cout <<
"T" << std::endl << T.
t() << std::endl;
std::cout <<
"n" << std::endl << n.
t() << std::endl;
}
std::cout << "------------------------------------------------------" << std::endl;
{
std::cout << "Initialization " << std::endl;
std::cout << "From vpThetaUVector to vpRotationMatrix " << std::endl;
M[0][3] = 0.21;
M[1][3] = 0.31;
M[2][3] = 0.5;
std::cout << "M" << std::endl << M << std::endl;
std::cout << "H" << std::endl << H << std::endl;
std::cout << "R" << std::endl << R;
std::cout <<
"T" << std::endl << T.
t() << std::endl;
std::cout <<
"n" << std::endl << n.
t() << std::endl;
}
std::cout << "------------------------------------------------------" << std::endl;
{
M[0][3] = 0.21;
M[1][3] = -0.31;
M[2][3] = 0.5;
std::cout << "M" << std::endl << M << std::endl;
std::cout << "H" << std::endl << H << std::endl;
std::cout << "R" << std::endl << R;
std::cout <<
"T" << std::endl << T.
t() << std::endl;
std::cout <<
"n" << std::endl << n.
t() << std::endl;
std::cout << "H" << std::endl << H << std::endl;
}
std::cout << "All tests succeed" << std::endl;
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
#else
std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
return EXIT_SUCCESS;
#endif
}
unsigned int getCols() const
Type * data
Address of the first element of the data array.
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
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.
void insert(const vpRotationMatrix &R)
Implementation of an homography and operations on homographies.
void computeDisplacement(vpRotationMatrix &aRb, vpTranslationVector &atb, vpColVector &n)
vpHomography & buildFrom(const vpRotationMatrix &aRb, const vpTranslationVector &atb, const vpPlane &bP)
Construction from translation and rotation and a plane.
static double rad(double deg)
This class defines the container for a plane geometrical structure.
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.