Ocean
TestFrameMinMax.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 OCEAN_TEST_TESTCV_TEST_FRAME_MIN_MAX_H
9 #define OCEAN_TEST_TESTCV_TEST_FRAME_MIN_MAX_H
10 
12 
13 namespace Ocean
14 {
15 
16 /// Forward declaration
17 class RandomGenerator;
18 
19 namespace Test
20 {
21 
22 namespace TestCV
23 {
24 
25 /**
26  * This class implements tests for the FrameMinMax class.
27  * @ingroup testcv
28  */
29 class OCEAN_TEST_CV_EXPORT TestFrameMinMax
30 {
31  public:
32 
33  /**
34  * Starts all test of the FrameMinMax class.
35  * @param width The width of the test image in pixel, with range [1, infinity)
36  * @param height The height of the test image in pixel, with range [1, infinity)
37  * @param testDuration Number of seconds for each test, with range (0, infinity)
38  * @param worker The worker object to distribute the computation
39  * @return True, if succeeded
40  */
41  static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
42 
43  /**
44  * Tests the function determining the minimum value and location.
45  * @param testDuration Number of seconds for each test, with range (0, infinity)
46  * @return True, if succeeded
47  */
48  static bool testDetermineMinValue(const double testDuration);
49 
50  /**
51  * Tests the function determining the maximum value and location.
52  * @param testDuration Number of seconds for each test, with range (0, infinity)
53  * @return True, if succeeded
54  */
55  static bool testDetermineMaxValue(const double testDuration);
56 
57  /**
58  * Tests the function determining the minimal and maximum pixel value.
59  * @param width The width of the test image in pixel, with range [1, infinity)
60  * @param height The height of the test image in pixel, with range [1, infinity)
61  * @param testDuration Number of seconds for each test, with range (0, infinity)
62  * @param worker The worker object to distribute the computation
63  * @return True, if succeeded
64  */
65  static bool testDetermineMinMaxValues(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
66 
67  /**
68  * Tests the function determining the minimal and maximum pixel value.
69  * @param width The width of the test image in pixel, with range [1, infinity)
70  * @param height The height of the test image in pixel, with range [1, infinity)
71  * @param testDuration Number of seconds for each test, with range (0, infinity)
72  * @param worker The worker object to distribute the computation
73  * @return True, if succeeded
74  * @tparam T The data type of each pixel element
75  */
76  template <typename T>
77  static bool testDetermineMinMaxValues(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
78 
79  /**
80  * Tests the function to count frame elements that are outside of a specified range of values
81  * @param testDuration Number of seconds for each test, with range (0, infinity)
82  * @return True, if succeeded
83  */
84  static bool testCountElementsOutsideRange(const double testDuration);
85 
86  /**
87  * Tests the function determining the minimum value and location.
88  * @param width The width of the test frame in pixel, with range [1, infinity)
89  * @param height The height of the test frame in pixel, with range [1, infinity)
90  * @param paddingElements The number of padding elements at the end of each row, with range [0, infinity)
91  * @return True, if succeeded
92  * @tparam T The data type of each pixel value
93  */
94  template <typename T>
95  static bool testDetermineMinValue(const unsigned int width, const unsigned int height, const unsigned int paddingElements);
96 
97  /**
98  * Tests the function determining the minimal and maximum value.
99  * @param width The width of the test frame in pixel, with range [1, infinity)
100  * @param height The height of the test frame in pixel, with range [1, infinity)
101  * @param paddingElements The number of padding elements at the end of each row, with range [0, infinity)
102  * @return True, if succeeded
103  * @tparam T The data type of each pixel value
104  */
105  template <typename T>
106  static bool testDetermineMaxValue(const unsigned int width, const unsigned int height, const unsigned int paddingElements);
107 
108  /**
109  * Tests the function counting the elements outside of a specified range of values
110  * @param randomGenerator The random generator to be used
111  * @param width The width of the test frame in pixel, with range [1, infinity)
112  * @param height The height of the test frame in pixel, with range [1, infinity)
113  * @param paddingElements The number of padding elements at the end of each row, with range [0, infinity)
114  * @return True, if succeeded
115  * @tparam T The data type of each pixel value
116  */
117  template <typename T>
118  static bool testCountElementsOutsideRange(RandomGenerator& randomGenerator, const uint32_t width, const uint32_t height, const uint32_t paddingElements);
119 
120  protected:
121 
122  /**
123  * Validates the minimal and maximal value which has been determined in a given image.
124  * @param frame The frame in which the minimal and maximal values have been determined, must be valid
125  * @param minValues The minimal values to validate, one for each channel, must be valid
126  * @param maxValues The maximal values to validate, one for each channel, must be valid
127  * @return True, if succeeded
128  * @tparam T The data type of each pixel value
129  */
130  template <typename T>
131  static bool validateDetermineMinMaxValues(const Frame& frame, const T* const minValues, const T* const maxValues);
132 };
133 
134 }
135 
136 }
137 
138 }
139 
140 #endif // OCEAN_TEST_TESTCV_TEST_FRAME_MIN_MAX_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements tests for the FrameMinMax class.
Definition: TestFrameMinMax.h:30
static bool testCountElementsOutsideRange(const double testDuration)
Tests the function to count frame elements that are outside of a specified range of values.
static bool validateDetermineMinMaxValues(const Frame &frame, const T *const minValues, const T *const maxValues)
Validates the minimal and maximal value which has been determined in a given image.
static bool testDetermineMinValue(const unsigned int width, const unsigned int height, const unsigned int paddingElements)
Tests the function determining the minimum value and location.
static bool testDetermineMaxValue(const unsigned int width, const unsigned int height, const unsigned int paddingElements)
Tests the function determining the minimal and maximum value.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Starts all test of the FrameMinMax class.
static bool testDetermineMaxValue(const double testDuration)
Tests the function determining the maximum value and location.
static bool testDetermineMinMaxValues(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the function determining the minimal and maximum pixel value.
static bool testCountElementsOutsideRange(RandomGenerator &randomGenerator, const uint32_t width, const uint32_t height, const uint32_t paddingElements)
Tests the function counting the elements outside of a specified range of values.
static bool testDetermineMinMaxValues(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the function determining the minimal and maximum pixel value.
static bool testDetermineMinValue(const double testDuration)
Tests the function determining the minimum value and location.
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