Ocean
TestFrameTransposer.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_TEST_FRAME_TRANSPOSER_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_TRANSPOSER_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Test
17 {
18 
19 namespace TestCV
20 {
21 
22 /**
23  * This class implements a test for the frame transposer class.
24  * @ingroup testcv
25  */
26 class OCEAN_TEST_CV_EXPORT TestFrameTransposer
27 {
28  public:
29 
30  /**
31  * Tests the frame transposer functions.
32  * @param testDuration Number of seconds for each test, with range (0, infinity)
33  * @param worker The worker object to distribute the computation
34  * @return True, if this test succeeded
35  */
36  static bool test(const double testDuration, Worker& worker);
37 
38  /**
39  * Tests the frame transposer function.
40  * @param testDuration Number of seconds for each test, with range (0, infinity)
41  * @param worker The worker object to distribute the computation
42  * @return True, if this test succeeded
43  */
44  static bool testTransposer(const double testDuration, Worker& worker);
45 
46  /**
47  * Tests the frame transposer function.
48  * @param width The width of the frame in pixel, with range [1, infinity)
49  * @param height The height of the frame in pixel, with range [1, infinity)
50  * @param testDuration Number of seconds for each test, with range (0, infinity)
51  * @param worker The worker object to distribute the computation
52  * @return True, if this test succeeded
53  * @tparam T The data type of each pixel element, e.g., 'unsigned char', 'float'
54  */
55  template <typename T>
56  static bool testTransposer(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
57 
58  /**
59  * Tests the frame transposer function.
60  * @param width The width of the frame in pixel, with range [1, infinity)
61  * @param height The height of the frame in pixel, with range [1, infinity)
62  * @param testDuration Number of seconds for each test, with range (0, infinity)
63  * @param worker The worker object to distribute the computation
64  * @return True, if this test succeeded
65  * @tparam T The data type of each pixel element, e.g., 'unsigned char', 'float'
66  * @tparam tChannels The number of frame channels, with range [1, infinity)
67  */
68  template <typename T, unsigned int tChannels>
69  static bool testTransposer(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
70 
71  /**
72  * Tests the rotation by 90 degrees function.
73  * @param testDuration Number of seconds for each test, with range (0, infinity)
74  * @param worker The worker object to distribute the computation
75  */
76  static bool testRotate90(const double testDuration, Worker& worker);
77 
78  /**
79  * Tests the rotation by 180 degrees function.
80  * @param testDuration Number of seconds for each test, with range (0, infinity)
81  * @param worker The worker object to distribute the computation
82  */
83  static bool testRotate180(const double testDuration, Worker& worker);
84 
85  /**
86  * Tests the rotation by +/- 90 degree steps function.
87  * @param testDuration Number of seconds for each test, with range (0, infinity)
88  * @param worker The worker object to distribute the computation
89  */
90  static bool testRotate(const double testDuration, Worker& worker);
91 
92  protected:
93 
94  /**
95  * Validates the frame transposer function.
96  * @param frame The frame to be transposed, must be valid
97  * @param transposed The transposed frame, must be valid
98  * @param width The width of the frame in pixel, with range [1, infinity)
99  * @param height The height of the frame in pixel, with range [1, infinity)
100  * @param framePaddingElements The number of padding elements at the end of each row in the frame, with range [0, infinity)
101  * @param transposedPaddingElements The number of padding elements at the end of each row in the transposed frame, with range [0, infinity)
102  * @return True, if this test succeeded
103  * @tparam T The data type of each pixel element, e.g., 'unsigned char', 'float'
104  * @tparam tChannels The number of frame channels, with range [1, infinity)
105  */
106  template <typename T, unsigned int tChannels>
107  static bool validateTransposer(const T* frame, const T* transposed, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int transposedPaddingElements);
108 
109  /**
110  * Validates the 90 degree rotation function.
111  * @param sourceFrame The source frame, must be valid
112  * @param targetFrame The by 90 degree rotated frame, must be valid
113  * @param clockwise True, if the image was rotate clockwise; False, if the image was rotated counter clockwise
114  * @return True, if succeeded
115  */
116  static bool validateRotate90(const Frame& sourceFrame, const Frame& targetFrame, const bool clockwise);
117 
118  /**
119  * Validates the 180 degree rotation function.
120  * @param sourceFrame The source frame, must be valid
121  * @param targetFrame The by 180 degree rotated frame, must be valid
122  * @return True, if succeeded
123  */
124  static bool validateRotate180(const Frame& sourceFrame, const Frame& targetFrame);
125 
126  /**
127  * Validates the rotation function.
128  * @param sourceFrame The source frame, must be valid
129  * @param targetFrame The by 180 degree rotated frame, must be valid
130  * @param angle The clockwise rotation angle, in degrees, with range (-infinity, infinity), must be a multiple of 90
131  * @return True, if succeeded
132  */
133  static bool validateRotate(const Frame& sourceFrame, const Frame& targetFrame, const int angle);
134 
135  /**
136  * Invokes the template-based rotate function.
137  * @param sourceFrame The source frame to rotate, must be valid
138  * @param targetFrame The target frame receiving the rotated image content, must be valid
139  * @param angle The rotation angle to be used, must be multiple of +/- 90
140  * @param worker Optional worker object to distribute the computation
141  * @return True, if succeeded
142  */
143  static bool rotate(const Frame& sourceFrame, Frame& targetFrame, const int angle, Worker* worker);
144 
145  /**
146  * Invokes the template-based rotate function.
147  * @param sourceFrame The source frame to rotate, must be valid
148  * @param targetFrame The target frame receiving the rotated image content, must be valid
149  * @param angle The rotation angle to be used, must be multiple of +/- 90
150  * @param worker Optional worker object to distribute the computation
151  * @return True, if succeeded
152  * @tparam T The data type of each element
153  */
154  template <typename T>
155  static bool rotate(const Frame& sourceFrame, Frame& targetFrame, const int angle, Worker* worker);
156 };
157 
158 }
159 
160 }
161 
162 }
163 
164 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_TRANSPOSER_H
This class implements Ocean's image class.
Definition: Frame.h:1760
This class implements a test for the frame transposer class.
Definition: TestFrameTransposer.h:27
static bool validateRotate180(const Frame &sourceFrame, const Frame &targetFrame)
Validates the 180 degree rotation function.
static bool testRotate90(const double testDuration, Worker &worker)
Tests the rotation by 90 degrees function.
static bool testTransposer(const double testDuration, Worker &worker)
Tests the frame transposer function.
static bool validateTransposer(const T *frame, const T *transposed, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int transposedPaddingElements)
Validates the frame transposer function.
static bool testTransposer(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the frame transposer function.
static bool rotate(const Frame &sourceFrame, Frame &targetFrame, const int angle, Worker *worker)
Invokes the template-based rotate function.
static bool testTransposer(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the frame transposer function.
static bool validateRotate(const Frame &sourceFrame, const Frame &targetFrame, const int angle)
Validates the rotation function.
static bool rotate(const Frame &sourceFrame, Frame &targetFrame, const int angle, Worker *worker)
Invokes the template-based rotate function.
static bool testRotate180(const double testDuration, Worker &worker)
Tests the rotation by 180 degrees function.
static bool test(const double testDuration, Worker &worker)
Tests the frame transposer functions.
static bool testRotate(const double testDuration, Worker &worker)
Tests the rotation by +/- 90 degree steps function.
static bool validateRotate90(const Frame &sourceFrame, const Frame &targetFrame, const bool clockwise)
Validates the 90 degree rotation function.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15