Ocean
TestFrameEnlarger.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_ENLARGER_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_ENLARGER_H
10 
12 
13 #include "ocean/base/Frame.h"
14 #include "ocean/base/Worker.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Test
20 {
21 
22 namespace TestCV
23 {
24 
25 /**
26  * This class implements frame enlarger test functions.
27  * @ingroup testcv
28  */
29 class OCEAN_TEST_CV_EXPORT TestFrameEnlarger
30 {
31  public:
32 
33  /**
34  * Tests the entire frame enlarger functions.
35  * @param testDuration Number of seconds for each test, with range (0, infinity)
36  * @param worker The worker object to distribute the computation
37  * @return True, if succeeded
38  */
39  static bool test(const double testDuration, Worker& worker);
40 
41  /**
42  * Tests the add border function using a defined border color.
43  * @param testDuration Number of seconds for each test, with range (0, infinity)
44  * @return True, if succeeded
45  * @tparam T The data type of each pixel element
46  */
47  template <typename T>
48  static bool testAddBorder(const double testDuration);
49 
50  /**
51  * Tests the add border function using the nearest pixel as color value.
52  * @param testDuration Number of seconds for each test, with range (0, infinity)
53  * @return True, if succeeded
54  * @tparam T The data type of each pixel element
55  */
56  template <typename T>
57  static bool testAddBorderNearestPixel(const double testDuration);
58 
59  /**
60  * Tests the frame enlarger mirroring the frame's content.
61  * @param testDuration Number of seconds for each test, with range (0, infinity)
62  * @return True, if succeeded
63  * @tparam T The data type of each pixel element
64  */
65  template <typename T>
66  static bool testAddBorderMirrored(const double testDuration);
67 
68  /**
69  * Tests upscaling of frames by a factor of two.
70  * @param testDuration Number of seconds for each test, with range (0, infinity)
71  * @param worker The worker object to distribute the computational load
72  * @return True, if succeeded
73  */
74  static bool testFrameMultiplyByTwo(const double testDuration, Worker& worker);
75 
76  /**
77  * Tests upscaling of frames by a factor of two for specific image sizes and number of channels
78  * @param width The width of the test frame in pixels used for performance measurements, with range [1, infinity)
79  * @param height The height of the test frame in pixels used for performance measurements, with range [1, infinity)
80  * @param channels The number of channels of the test frame, range: [1, 4]
81  * @param testDuration Number of seconds for each test, with range (0, infinity)
82  * @param worker The worker object to distribute the computational load
83  * @return True, if succeeded
84  */
85  static bool testFrameMultiplyByTwo(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
86 
87  /**
88  * Tests the add border function using the nearest pixel as color and alpha set to full transparency
89  * @param testDuration Number of seconds for each test, with range (0, infinity)
90  * @return True, if succeeded
91  */
92  static bool testAddTransparentBorder(const double testDuration);
93 
94  private:
95 
96  /**
97  * Validates the function adding a border with static color.
98  * @param original The original frame, must be valid
99  * @param enlarged The enlarged frame to validate, must be valid
100  * @param borderSizeLeft The size of the border at the left image boundary, in pixel, with range [0, infinity)
101  * @param borderSizeTop The size of the border at the top image boundary, in pixel, with range [0, infinity)
102  * @param borderSizeRight The size of the border at the right image boundary, in pixel, with range [0, infinity)
103  * @param borderSizeBottom The size of the border at the bottom image boundary, in pixel, with range [0, infinity)
104  * @param color The color to be used, one value for each channel
105  * @return True, if succeeded
106  * @tparam T The data type of each pixel element
107  */
108  template <typename T>
109  static bool validateAddBorder(const Frame& original, const Frame& enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom, const T* color);
110 
111  /**
112  * Validates the add border function using the nearest pixel as color value.
113  * @param original The original frame, must be valid
114  * @param enlarged The enlarged frame to validate, must be valid
115  * @param borderSizeLeft The size of the border at the left image boundary, in pixel, with range [0, infinity)
116  * @param borderSizeTop The size of the border at the top image boundary, in pixel, with range [0, infinity)
117  * @param borderSizeRight The size of the border at the right image boundary, in pixel, with range [0, infinity)
118  * @param borderSizeBottom The size of the border at the bottom image boundary, in pixel, with range [0, infinity)
119  * @return True, if succeeded
120  * @tparam T The data type of each pixel element
121  */
122  template <typename T>
123  static bool validateAddBorderNearestPixel(const Frame& original, const Frame& enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom);
124 
125  /**
126  * Validates the add border function mirroring the frame's content.
127  * @param original The original frame, must be valid
128  * @param enlarged The enlarged frame to validate, must be valid
129  * @param borderSizeLeft The size of the border at the left image boundary, in pixel, with range [0, infinity)
130  * @param borderSizeTop The size of the border at the top image boundary, in pixel, with range [0, infinity)
131  * @param borderSizeRight The size of the border at the right image boundary, in pixel, with range [0, infinity)
132  * @param borderSizeBottom The size of the border at the bottom image boundary, in pixel, with range [0, infinity)
133  * @return True, if succeeded
134  * @tparam T The data type of each pixel element
135  */
136  template <typename T>
137  static bool validateAddBorderMirrored(const Frame& original, const Frame& enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom);
138 
139  /**
140  * Validates the upscaling of frames by factor two.
141  * @param original The original source frame, must be valid
142  * @param enlarged The enlarged target frame that will be validated, must be valid
143  * @return True, if succeeded
144  */
145  static bool validationMultiplyByTwo(const Frame& original, const Frame& enlarged);
146 
147  /**
148  * Validates the function adding a border with static color.
149  * @param original The original frame, must be valid
150  * @param enlarged The enlarged frame to validate, must be valid
151  * @param borderSizeLeft The size of the border at the left image boundary, in pixel, with range [0, infinity)
152  * @param borderSizeTop The size of the border at the top image boundary, in pixel, with range [0, infinity)
153  * @param borderSizeRight The size of the border at the right image boundary, in pixel, with range [0, infinity)
154  * @param borderSizeBottom The size of the border at the bottom image boundary, in pixel, with range [0, infinity)
155  * @param transparentIs0xFF If true transparency will be defined as 0xFF, otherwise 0x00
156  * @return True, if succeeded
157  */
158  static bool validateAddTransparentBorder(const Frame& original, const Frame& enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom, const bool transparentIs0xFF);
159 };
160 
161 }
162 
163 }
164 
165 }
166 
167 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_ENLARGER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements frame enlarger test functions.
Definition: TestFrameEnlarger.h:30
static bool testFrameMultiplyByTwo(const double testDuration, Worker &worker)
Tests upscaling of frames by a factor of two.
static bool testAddBorder(const double testDuration)
Tests the add border function using a defined border color.
static bool testAddBorderNearestPixel(const double testDuration)
Tests the add border function using the nearest pixel as color value.
static bool validateAddBorderNearestPixel(const Frame &original, const Frame &enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom)
Validates the add border function using the nearest pixel as color value.
static bool testFrameMultiplyByTwo(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests upscaling of frames by a factor of two for specific image sizes and number of channels.
static bool validateAddBorderMirrored(const Frame &original, const Frame &enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom)
Validates the add border function mirroring the frame's content.
static bool testAddTransparentBorder(const double testDuration)
Tests the add border function using the nearest pixel as color and alpha set to full transparency.
static bool testAddBorderMirrored(const double testDuration)
Tests the frame enlarger mirroring the frame's content.
static bool validateAddBorder(const Frame &original, const Frame &enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom, const T *color)
Validates the function adding a border with static color.
static bool validationMultiplyByTwo(const Frame &original, const Frame &enlarged)
Validates the upscaling of frames by factor two.
static bool test(const double testDuration, Worker &worker)
Tests the entire frame enlarger functions.
static bool validateAddTransparentBorder(const Frame &original, const Frame &enlarged, const unsigned int borderSizeLeft, const unsigned int borderSizeTop, const unsigned int borderSizeRight, const unsigned int borderSizeBottom, const bool transparentIs0xFF)
Validates the function adding a border with static color.
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