32 #define BOOST_TEST_MAIN
33 #define BOOST_TEST_MODULE "retrieval/geometry"
34 #include <boost/test/unit_test.hpp>
36 #include <Eigen/Dense>
44 for (
float x = 0;
x < 3; ++
x) {
45 for (
float y = 0;
y < 3; ++
y) {
46 for (
float scale = 1; scale < 5; ++scale) {
47 for (
float orientation = 0; orientation < 3; ++orientation) {
51 feature1.
scale = scale;
56 feature2.
scale = scale;
58 const auto tform_matrix =
61 tform_matrix.isApprox(Eigen::Matrix<float, 2, 3>::Identity()));
64 BOOST_CHECK_CLOSE(tform.scale, 1, 1
e-6);
65 BOOST_CHECK_CLOSE(tform.angle, 0, 1
e-6);
66 BOOST_CHECK_CLOSE(tform.tx, 0, 1
e-6);
67 BOOST_CHECK_CLOSE(tform.ty, 0, 1
e-6);
75 for (
float x = 0;
x < 3; ++
x) {
76 for (
float y = 0;
y < 3; ++
y) {
84 const auto tform_matrix =
87 tform_matrix.leftCols<2>().isApprox(Eigen::Matrix2f::Identity()));
88 BOOST_CHECK(tform_matrix.rightCols<1>().isApprox(Eigen::Vector2f(
x,
y)));
91 BOOST_CHECK_CLOSE(tform.scale, 1, 1
e-6);
92 BOOST_CHECK_CLOSE(tform.angle, 0, 1
e-6);
93 BOOST_CHECK_CLOSE(tform.tx,
x, 1
e-6);
94 BOOST_CHECK_CLOSE(tform.ty,
y, 1
e-6);
100 for (
float scale = 1; scale < 5; ++scale) {
104 feature2.
scale = scale;
106 const auto tform_matrix =
108 BOOST_CHECK(tform_matrix.leftCols<2>().isApprox(
109 scale * Eigen::Matrix2f::Identity()));
110 BOOST_CHECK(tform_matrix.rightCols<1>().isApprox(Eigen::Vector2f(0, 0)));
112 BOOST_CHECK_CLOSE(tform.scale, scale, 1
e-6);
113 BOOST_CHECK_CLOSE(tform.angle, 0, 1
e-6);
114 BOOST_CHECK_CLOSE(tform.tx, 0, 1
e-6);
115 BOOST_CHECK_CLOSE(tform.ty, 0, 1
e-6);
120 for (
float orientation = 0; orientation < 3; ++orientation) {
127 const auto tform_matrix =
129 BOOST_CHECK_CLOSE(tform_matrix.leftCols<2>().determinant(), 1, 1
e-5);
130 BOOST_CHECK(tform_matrix.rightCols<1>().isApprox(Eigen::Vector2f(0, 0)));
132 BOOST_CHECK_CLOSE(tform.scale, 1, 1
e-6);
133 BOOST_CHECK_CLOSE(tform.angle, orientation, 1
e-6);
134 BOOST_CHECK_CLOSE(tform.tx, 0, 1
e-6);
135 BOOST_CHECK_CLOSE(tform.ty, 0, 1
e-6);
BOOST_AUTO_TEST_CASE(TestIdentity)
static FeatureGeometryTransform TransformFromMatch(const FeatureGeometry &feature1, const FeatureGeometry &feature2)
static Eigen::Matrix< float, 2, 3 > TransformMatrixFromMatch(const FeatureGeometry &feature1, const FeatureGeometry &feature2)