45 #include <visp3/core/vpDebug.h>
46 #include <visp3/core/vpMath.h>
47 #include <visp3/core/vpRotationMatrix.h>
48 #include <visp3/core/vpThetaUVector.h>
49 #include <visp3/vision/vpHomography.h>
51 bool test(
const std::string &s,
const vpHomography &H,
const std::vector<double> &bench)
53 static unsigned int cpt = 0;
54 std::cout <<
"** Test " << ++cpt << std::endl;
55 std::cout << s <<
"(" << H.
getRows() <<
"," << H.
getCols() <<
") = \n[" << H <<
"]" << std::endl;
56 if (bench.size() != H.
size()) {
57 std::cout <<
"Test fails: bad size wrt bench" << std::endl;
60 for (
unsigned int i = 0; i < H.
size(); i++) {
61 if (std::fabs(H.
data[i] - bench[i]) > std::fabs(H.
data[i]) * std::numeric_limits<double>::epsilon()) {
62 std::cout <<
"Test fails: bad content" << std::endl;
72 #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
77 std::vector<double> bench(9, 0);
78 bench[0] = bench[4] = bench[8] = 1.;
80 if (test(
"H", H, bench) ==
false)
82 if (test(
"H", H / H[2][2], bench) ==
false)
88 std::cout <<
"Initialization " << std::endl;
91 std::cout <<
"From vpThetaUVector to vpRotationMatrix " << std::endl;
98 std::cout <<
"M" << std::endl << M << std::endl;
103 std::cout <<
"H" << std::endl << H << std::endl;
110 std::cout <<
"R" << std::endl << R;
111 std::cout <<
"T" << std::endl << T.
t() << std::endl;
112 std::cout <<
"n" << std::endl << n.
t() << std::endl;
114 std::cout <<
"------------------------------------------------------" << std::endl;
119 std::cout <<
"Initialization " << std::endl;
122 std::cout <<
"From vpThetaUVector to vpRotationMatrix " << std::endl;
133 std::cout <<
"M" << std::endl << M << std::endl;
138 std::cout <<
"H" << std::endl << H << std::endl;
145 std::cout <<
"R" << std::endl << R;
146 std::cout <<
"T" << std::endl << T.
t() << std::endl;
147 std::cout <<
"n" << std::endl << n.
t() << std::endl;
150 std::cout <<
"------------------------------------------------------" << std::endl;
164 std::cout <<
"M" << std::endl << M << std::endl;
169 std::cout <<
"H" << std::endl << H << std::endl;
175 std::cout <<
"R" << std::endl << R;
176 std::cout <<
"T" << std::endl << T.
t() << std::endl;
177 std::cout <<
"n" << std::endl << n.
t() << std::endl;
179 vpPlane p1(n[0], n[1], n[2], 1.0);
181 std::cout <<
"H" << std::endl << H << std::endl;
183 std::cout <<
"All tests succeed" << std::endl;
186 std::cout <<
"Catch an exception: " << e << std::endl;
190 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 buildFrom(const vpRotationMatrix &aRb, const vpTranslationVector &atb, const vpPlane &bP)
Construction from translation and rotation and a plane.
void computeDisplacement(vpRotationMatrix &aRb, vpTranslationVector &atb, vpColVector &n)
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.