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