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