42 #include <visp3/core/vpDebug.h>
43 #include <visp3/core/vpMath.h>
44 #include <visp3/core/vpRotationMatrix.h>
45 #include <visp3/core/vpThetaUVector.h>
46 #include <visp3/vision/vpHomography.h>
48 #ifdef ENABLE_VISP_NAMESPACE
52 bool test(
const std::string &s,
const vpHomography &H,
const std::vector<double> &bench)
54 static unsigned int cpt = 0;
55 std::cout <<
"** Test " << ++cpt << std::endl;
56 std::cout << s <<
"(" << H.
getRows() <<
"," << H.
getCols() <<
") = \n[" << H <<
"]" << std::endl;
57 if (bench.size() != H.
size()) {
58 std::cout <<
"Test fails: bad size wrt bench" << std::endl;
61 for (
unsigned int i = 0; i < H.
size(); i++) {
62 if (std::fabs(H.
data[i] - bench[i]) > std::fabs(H.
data[i]) * std::numeric_limits<double>::epsilon()) {
63 std::cout <<
"Test fails: bad content" << std::endl;
73 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
78 std::vector<double> bench(9, 0);
79 bench[0] = bench[4] = bench[8] = 1.;
81 if (test(
"H", H, bench) ==
false)
83 if (test(
"H", H / H[2][2], bench) ==
false)
89 std::cout <<
"Initialization " << std::endl;
92 std::cout <<
"From vpThetaUVector to vpRotationMatrix " << std::endl;
99 std::cout <<
"M" << std::endl << M << std::endl;
104 std::cout <<
"H" << std::endl << H << std::endl;
111 std::cout <<
"R" << std::endl << R;
112 std::cout <<
"T" << std::endl << T.
t() << std::endl;
113 std::cout <<
"n" << std::endl << n.
t() << std::endl;
115 std::cout <<
"------------------------------------------------------" << std::endl;
120 std::cout <<
"Initialization " << std::endl;
123 std::cout <<
"From vpThetaUVector to vpRotationMatrix " << std::endl;
134 std::cout <<
"M" << std::endl << M << std::endl;
139 std::cout <<
"H" << std::endl << H << std::endl;
146 std::cout <<
"R" << std::endl << R;
147 std::cout <<
"T" << std::endl << T.
t() << std::endl;
148 std::cout <<
"n" << std::endl << n.
t() << std::endl;
151 std::cout <<
"------------------------------------------------------" << std::endl;
165 std::cout <<
"M" << std::endl << M << std::endl;
170 std::cout <<
"H" << std::endl << H << std::endl;
176 std::cout <<
"R" << std::endl << R;
177 std::cout <<
"T" << std::endl << T.
t() << std::endl;
178 std::cout <<
"n" << std::endl << n.
t() << std::endl;
180 vpPlane p1(n[0], n[1], n[2], 1.0);
182 std::cout <<
"H" << std::endl << H << std::endl;
184 std::cout <<
"All tests succeed" << std::endl;
188 std::cout <<
"Catch an exception: " << e << std::endl;
192 std::cout <<
"Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
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.