Ocean
TestFrameShrinker.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_SHRINKER_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_SHRINKER_H
10 
12 
13 #include "ocean/base/Worker.h"
14 
15 #include "ocean/cv/FrameShrinker.h"
16 
17 namespace Ocean
18 {
19 
20 namespace Test
21 {
22 
23 namespace TestCV
24 {
25 
26 /**
27  * This class implements tests for the frame downsizing functions.
28  * @ingroup testcv
29  */
30 class OCEAN_TEST_CV_EXPORT TestFrameShrinker : protected CV::FrameShrinker
31 {
32  public:
33 
34  /**
35  * Tests the frame downsize.
36  * @param testDuration Number of seconds for each test, with range (0, infinity)
37  * @param worker The worker object to distribute the computational load
38  * @return True, if succeeded
39  */
40  static bool test(const double testDuration, Worker& worker);
41 
42  /**
43  * Tests the downsampling of three rows to one row.
44  * @param testDuration Number of seconds for each test, with range (0, infinity)
45  * @return True, if succeeded
46  */
47  static bool testRowDownsamplingByTwoThreeRows8Bit121(const double testDuration);
48 
49  /**
50  * Tests the 8 bit frame downsampling using 11 filtering.
51  * @param testDuration Number of seconds for each test, with range (0, infinity)
52  * @param worker The worker object to distribute the computational load
53  * @return True, if succeeded
54  */
55  static bool testFrameDownsamplingByTwo8Bit11(const double testDuration, Worker& worker);
56 
57  /**
58  * Tests the 8 bit frame downsampling using 11 filtering for extreme (small) frame resolutions.
59  * @param worker The worker object to distribute the computational load
60  * @return True, if succeeded
61  */
63 
64  /**
65  * Tests the 8 bit frame downsampling using 14641 filtering.
66  * @param testDuration Number of seconds for each test, with range (0, infinity)
67  * @param worker The worker object to distribute the computational load
68  * @return True, if succeeded
69  */
70  static bool testFrameDownsamplingByTwo8Bit14641(const double testDuration, Worker& worker);
71 
72  /**
73  * Tests the 8 bit frame downsampling using 14641 filtering for extreme (small) frame resolutions.
74  * @param worker The worker object to distribute the computational load
75  * @return True, if succeeded
76  */
78 
79  /**
80  * Tests the binary frame downsampling using 11 filtering.
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 testDownsampleBinayMaskByTwo11(const double testDuration, Worker& worker);
86 
87  /**
88  * Tests the binary frame downsampling using 11 filtering for extreme (small) frame resolutions.
89  * @param worker The worker object to distribute the computational load
90  * @return True, if succeeded
91  */
93 
94  /**
95  * Tests the 8 bit pyramid downsampling using 11 filtering.
96  * @param testDuration Number of seconds for each test, with range (0, infinity)
97  * @param worker The worker object to distribute the computational load
98  * @return True, if succeeded
99  */
100  static bool testPyramidByTwo11(const double testDuration, Worker& worker);
101 
102  /**
103  * Tests the 8 bit frame downsampling using 11 filtering.
104  * @param sourceWidth Width of the source frame in pixel, with range [2, infinity)
105  * @param sourceHeight Height of the source frame in pixel, with range [2, infinity)
106  * @param channels The number of frame channels, with range [1, infinity)
107  * @param testDuration Number of seconds for each test, with range (0, infinity)
108  * @param worker The worker object to distribute the computational load
109  * @return True, if succeeded
110  */
111  static bool testFrameDownsamplingByTwo8Bit11(const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const double testDuration, Worker& worker);
112 
113  /**
114  * Tests the binary frame downsampling using 11 filtering.
115  * @param sourceWidth Width of the source frame in pixel, with range [2, infinity)
116  * @param sourceHeight Height of the source frame in pixel, with range [2, infinity)
117  * @param testDuration Number of seconds for each test, with range (0, infinity)
118  * @param worker The worker object to distribute the computational load
119  * @return True, if succeeded
120  */
121  static bool testDownsampleBinayMaskByTwo11(const unsigned int sourceWidth, const unsigned int sourceHeight, const double testDuration, Worker& worker);
122 
123  /**
124  * Tests the 8 bit frame downsampling using 14641 filtering.
125  * @param sourceWidth Width of the source frame in pixel, with range [2, infinity)
126  * @param sourceHeight Height of the source frame in pixel, with range [2, infinity)
127  * @param targetWidth Width of the target frame in pixel, with range [sourceWidth / 2, (sourceWidth + 1) / 2]
128  * @param targetHeight Height of the target frame in pixel, with range [sourceHeight / 2, (sourceHeight + 1) / 2]
129  * @param channels The number of frame channels, with range [1, infinity)
130  * @param testDuration Number of seconds for each test, with range (0, infinity)
131  * @param worker The worker object to distribute the computational load
132  * @return True, if succeeded
133  */
134  static bool testFrameDownsamplingByTwo8Bit14641(const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const double testDuration, Worker& worker);
135 
136  protected:
137 
138  /**
139  * Validates the downsampling of a frame using a 11 filtering.
140  * @param source The source frame which has been downsampled, must be valid
141  * @param target The target frame holding the downsampled frame, must be valid
142  * @param averageAbsError Optional resulting average absolute error between the converted result and the ground truth result, with range (-infinity, infinity)
143  * @param maximalAbsError Optional resulting maximal absolute error between the converted result and the ground truth result, with range (-infinity, infinity)
144  * @param groundTruth Optional resulting ground truth data, with buffer size (sourceWidth / 2) * (sourceHeight / 2) * channels, otherwise nullptr
145  * @param groundTruthPaddingElements Optional number of padding elements at the end of each ground truth row, in elements, with range [0, infinity)
146  * @return True, if succeeded
147  */
148  static bool validateDownsamplingByTwo8Bit11(const Frame& source, const Frame& target, double* averageAbsError, double* maximalAbsError, uint8_t* groundTruth = nullptr, const unsigned int groundTruthPaddingElements = 0u);
149 
150  /**
151  * Validates the binary downsampling of a frame using a 11 filtering.
152  * @param source The source frame holding an binary image, must be valid
153  * @param target The target frame holding the halved binary image, must be valid
154  * @param sourceWidth Width of the source frame in pixel, with range [2, infinity)
155  * @param sourceHeight Height of the source frame in pixel, with range [2, infinity)
156  * @param sourcePaddingElements The number of padding elements at the end of each source row, in elements, with range [0, infinity)
157  * @param targetPaddingElements The number of padding elements at the end of each target row, in elements, with range [0, infinity)
158  * @param threshold Minimal sum threshold of four pixels to result in a pixel with value 255, with range [1, 255 * 4]
159  * @return True, if succeeded
160  */
161  static bool validateDownsampleBinayMaskByTwo11(const uint8_t* source, const uint8_t* target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int threshold);
162 
163  /**
164  * Validates the downsampling of a frame using a 14641 filtering.
165  * @param source The source frame holding an 8 bit image per channel, must be valid
166  * @param target The target frame holding the downsampled frame, also 8 bit per channel, must be valid
167  * @param sourceWidth Width of the source frame in pixel, with range [2, infinity)
168  * @param sourceHeight Height of the source frame in pixel, with range [2, infinity)
169  * @param targetWidth Width of the target frame in pixel, with range [sourceWidth / 2, (sourceWidth + 1) / 2]
170  * @param targetHeight Height of the target frame in pixel, with range [sourceHeight / 2, (sourceHeight + 1) / 2]
171  * @param channels The number of frame channels, with range [1, infinity)
172  * @param sourcePaddingElements Optional number of padding elements at the end of each source row, in elements, with range [0, infinity)
173  * @param targetPaddingElements Optional number of padding elements at the end of each target row, in elements, with range [0, infinity)
174  * @param averageAbsError Optional resulting average absolute error between the converted result and the ground truth result, with range (-infinity, infinity)
175  * @param maximalAbsError Optional resulting maximal absolute error between the converted result and the ground truth result, with range (-infinity, infinity)
176  * @param groundTruth Optional resulting ground truth data, with buffer size (sourceWidth / 2) * (sourceHeight / 2) * channels, otherwise nullptr
177  * @param groundTruthPaddingElements Optional number of padding elements at the end of each ground truth row, in elements, with range [0, infinity)
178  */
179  static void validateDownsamplingByTwo8Bit14641(const uint8_t* source, const uint8_t* target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, double* averageAbsError, double* maximalAbsError, uint8_t* groundTruth = nullptr, const unsigned int groundTruthPaddingElements = 0u);
180 };
181 
182 }
183 
184 }
185 
186 }
187 
188 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_SHRINKER_H
This class implements function to downsize a frame.
Definition: FrameShrinker.h:31
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements tests for the frame downsizing functions.
Definition: TestFrameShrinker.h:31
static bool testFrameDownsamplingByTwo8Bit14641ExtremeResolutions(Worker &worker)
Tests the 8 bit frame downsampling using 14641 filtering for extreme (small) frame resolutions.
static bool testDownsampleBinayMaskByTwo11(const unsigned int sourceWidth, const unsigned int sourceHeight, const double testDuration, Worker &worker)
Tests the binary frame downsampling using 11 filtering.
static bool testFrameDownsamplingByTwo8Bit11ExtremeResolutions(Worker &worker)
Tests the 8 bit frame downsampling using 11 filtering for extreme (small) frame resolutions.
static bool testDownsampleBinayMaskByTwo11ExtremeResolutions(Worker &worker)
Tests the binary frame downsampling using 11 filtering for extreme (small) frame resolutions.
static void validateDownsamplingByTwo8Bit14641(const uint8_t *source, const uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, double *averageAbsError, double *maximalAbsError, uint8_t *groundTruth=nullptr, const unsigned int groundTruthPaddingElements=0u)
Validates the downsampling of a frame using a 14641 filtering.
static bool testPyramidByTwo11(const double testDuration, Worker &worker)
Tests the 8 bit pyramid downsampling using 11 filtering.
static bool testRowDownsamplingByTwoThreeRows8Bit121(const double testDuration)
Tests the downsampling of three rows to one row.
static bool testDownsampleBinayMaskByTwo11(const double testDuration, Worker &worker)
Tests the binary frame downsampling using 11 filtering.
static bool validateDownsamplingByTwo8Bit11(const Frame &source, const Frame &target, double *averageAbsError, double *maximalAbsError, uint8_t *groundTruth=nullptr, const unsigned int groundTruthPaddingElements=0u)
Validates the downsampling of a frame using a 11 filtering.
static bool testFrameDownsamplingByTwo8Bit14641(const double testDuration, Worker &worker)
Tests the 8 bit frame downsampling using 14641 filtering.
static bool testFrameDownsamplingByTwo8Bit11(const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 8 bit frame downsampling using 11 filtering.
static bool testFrameDownsamplingByTwo8Bit14641(const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 8 bit frame downsampling using 14641 filtering.
static bool validateDownsampleBinayMaskByTwo11(const uint8_t *source, const uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int threshold)
Validates the binary downsampling of a frame using a 11 filtering.
static bool testFrameDownsamplingByTwo8Bit11(const double testDuration, Worker &worker)
Tests the 8 bit frame downsampling using 11 filtering.
static bool test(const double testDuration, Worker &worker)
Tests the frame downsize.
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