Ocean
TestTransformation.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_TEST_TESTCV_TESTOPENCV_TEST_TRANSFORMATION_H
9 #define META_OCEAN_TEST_TESTCV_TESTOPENCV_TEST_TRANSFORMATION_H
10 
12 
14 #include "ocean/math/Vector2.h"
15 
16 #include <opencv2/core.hpp>
17 
18 namespace Ocean
19 {
20 
21 namespace Test
22 {
23 
24 namespace TestCV
25 {
26 
27 namespace TestOpenCV
28 {
29 
30 /**
31  * This class tests transformation determination functions of OpenCV.
32  * @ingroup testcvopencv
33  */
34 class OCEAN_TEST_CV_OPENCV_EXPORT TestTransformation
35 {
36  public:
37 
38  /**
39  * Tests all transformation functions.
40  * @param testDuration Number of seconds for each test, with range (0, infinity)
41  * @return True, if succeeded
42  */
43  static bool testTransformation(const double testDuration);
44 
45  private:
46 
47  /**
48  * Tests the function determining the similarity matrix.
49  * @param testDuration Number of seconds for each test, with range (0, infinity)
50  * @return True, if succeeded
51  */
52  template <typename T>
53  static bool testSimilarityMatrix(const double testDuration);
54 
55  /**
56  * Tests the function determining the similarity matrix with a specified number of point correspondences
57  * @param testDuration Number of seconds for each test, with range (0, infinity)
58  * @param points The number of point correspondences to be used, with range [3, infinity)
59  * @return True, if succeeded
60  * @tparam T The data type of a scalar used for the test
61  */
62  template <typename T>
63  static bool testSimilarityMatrix(const double testDuration, const size_t points);
64 
65  /**
66  * Tests the function determining the affine matrix.
67  * @param testDuration Number of seconds for each test, with range (0, infinity)
68  * @return True, if succeeded
69  */
70  template <typename T>
71  static bool testAffineMatrix(const double testDuration);
72 
73  /**
74  * Tests the function determining the affine matrix with a specified number of point correspondences
75  * @param testDuration Number of seconds for each test, with range (0, infinity)
76  * @param points The number of point correspondences to be used, with range [3, infinity)
77  * @return True, if succeeded
78  * @tparam T The data type of a scalar used for the test
79  */
80  template <typename T>
81  static bool testAffineMatrix(const double testDuration, const size_t points);
82 
83  /**
84  * Tests the function determining the similarity matrix.
85  * @param testDuration Number of seconds for each test, with range (0, infinity)
86  * @return True, if succeeded
87  */
88  template <typename T>
89  static bool testHomographyMatrix(const double testDuration);
90 
91  /**
92  * Tests the function determining the similarity matrix with a specified number of point correspondences
93  * @param testDuration Number of seconds for each test, with range (0, infinity)
94  * @param points The number of point correspondences to be used, with range [3, infinity)
95  * @return True, if succeeded
96  * @tparam T The data type of a scalar used for the test
97  */
98  template <typename T>
99  static bool testHomographyMatrix(const double testDuration, const size_t points);
100 
101  /**
102  * Converts 2D vectors defined by the Ocean framework to 2D vectors defined by OpenCV.
103  * @param vectors The vectors to convert
104  * @return The resulting 2D vectors
105  * @tparam T The data type of each element the resulting 2D vectors
106  */
107  template <typename T>
108  static std::vector<cv::Point_<T>> ocean2opencv(const Vectors2& vectors);
109 
110  /**
111  * Converts a 3x3 square matrix defined by OpenCV to a 3x3 square matrix defined by Ocean.
112  * @param matrix The matrix to convert
113  * @return The resulting matrix
114  * @tparam T The data type of each element the resulting matrix
115  */
116  template <typename T>
117  static SquareMatrix3 opencv2ocean(const cv::Mat& matrix);
118 
119  /**
120  * Converts a 3x3 square matrix defined by OpenCV to a 3x3 square matrix defined by Ocean in homography.
121  * @param matrix The matrix to convert
122  * @return The resulting matrix
123  * @tparam T The data type of each element the resulting matrix
124  */
125  template <typename T>
126  static SquareMatrix3 opencv2ocean_homography(const cv::Mat& matrix);
127 
128  /**
129  * Converts a 3x3 square matrix defined by OpenCV to a 3x3 square matrix defined by Ocean in affine transform.
130  * @param matrix The matrix to convert
131  * @return The resulting matrix
132  * @tparam T The data type of each element the resulting matrix
133  */
134  template <typename T>
135  static SquareMatrix3 opencv2ocean_affine(const cv::Mat& matrix);
136 };
137 
138 }
139 
140 }
141 
142 }
143 
144 }
145 
146 #endif // META_OCEAN_TEST_TESTCV_TESTOPENCV_TEST_TRANSFORMATION_H
This class tests transformation determination functions of OpenCV.
Definition: TestTransformation.h:35
static bool testSimilarityMatrix(const double testDuration, const size_t points)
Tests the function determining the similarity matrix with a specified number of point correspondences...
static bool testSimilarityMatrix(const double testDuration)
Tests the function determining the similarity matrix.
static bool testTransformation(const double testDuration)
Tests all transformation functions.
static SquareMatrix3 opencv2ocean(const cv::Mat &matrix)
Converts a 3x3 square matrix defined by OpenCV to a 3x3 square matrix defined by Ocean.
static bool testAffineMatrix(const double testDuration, const size_t points)
Tests the function determining the affine matrix with a specified number of point correspondences.
static bool testHomographyMatrix(const double testDuration, const size_t points)
Tests the function determining the similarity matrix with a specified number of point correspondences...
static SquareMatrix3 opencv2ocean_affine(const cv::Mat &matrix)
Converts a 3x3 square matrix defined by OpenCV to a 3x3 square matrix defined by Ocean in affine tran...
static SquareMatrix3 opencv2ocean_homography(const cv::Mat &matrix)
Converts a 3x3 square matrix defined by OpenCV to a 3x3 square matrix defined by Ocean in homography.
static bool testHomographyMatrix(const double testDuration)
Tests the function determining the similarity matrix.
static std::vector< cv::Point_< T > > ocean2opencv(const Vectors2 &vectors)
Converts 2D vectors defined by the Ocean framework to 2D vectors defined by OpenCV.
static bool testAffineMatrix(const double testDuration)
Tests the function determining the affine matrix.
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15