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