Ocean
TestFrameVariance.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_VARIANCE_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_VARIANCE_H
10 
12 
13 #include "ocean/base/Worker.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Test
19 {
20 
21 namespace TestCV
22 {
23 
24 /**
25  * This class implements tests for the frame variance functions.
26  * @ingroup testcv
27  */
28 class OCEAN_TEST_CV_EXPORT TestFrameVariance
29 {
30  public:
31 
32  /**
33  * Tests the frame variance functions
34  * @param width The width of the test frame in pixel, with range [5, infinity)
35  * @param height The height of the test frame in pixel, with range [5, infinity)
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 unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
41 
42  /**
43  * Tests the frame deviation function for a 1 channel 8 bit frame.<br>
44  * @param width The width of the source frame in pixel
45  * @param height The height of the source frame in pixel
46  * @param window The window of the sampling area
47  * @param testDuration Number of seconds for each test
48  * @return True, if succeeded
49  * @tparam T The data type of the frame elements, either 'int8_t' or 'uint8_t'
50  */
51  template <typename T>
52  static bool testDeviation1Channel8Bit(const unsigned int width, const unsigned int height, const unsigned int window, const double testDuration);
53 
54  /**
55  * Tests the computation of per-channel mean, variance, and standard deviation of images
56  * This test will measure the performance for the specified width and
57  * height with and without padding.
58  * @param width The width of the source frame in pixel, range: [1, infinity)
59  * @param height The height of the source frame in pixel, range: [1, infinity)
60  * @param testDuration Number of seconds for each test, range: (0, infinity)
61  * @return True, if succeeded
62  */
63  static bool testFrameStatistics(const unsigned width, const unsigned int height, const double testDuration);
64 
65  /**
66  * Tests the computation of per-channel mean, variance, and standard deviation of images
67  * This test will measure the performance for the specified width and
68  * height with and without padding.
69  * @param width Maximum width of the source frame in pixel, range: [1, infinity)
70  * @param height Maximum height of the source frame in pixel, range: [1, infinity)
71  * @param testDuration Number of seconds for each test, range: (0, infinity)
72  * @tparam TElementType Type of the source pixel elements
73  * @tparam TElementType Type of the elements of the pixels of the input image
74  * @tparam TSummationType Type used for the internal computation of the pixel sums (should be at least as large as `TElementType`), cf. function description for details
75  * @tparam tChannels Number of channels of the source image, range: [1, infinity)
76  * @return True, if succeeded
77  */
78  template <typename TElementType, typename TSummationType, typename TMultiplicationType, unsigned int tChannels>
79  static bool testFrameStatistics(const unsigned width, const unsigned int height, const double testDuration);
80 
81  /**
82  * Validates the frame deviation function for a 1 channel 8 bit frame.<br>
83  * @param frame The frame for which the variance was determined, must be valid
84  * @param variance The variance to verify, must be valid
85  * @param window The window of the sampling area, with range [1, infinity), must be odd
86  * @return True, if succeeded
87  * @tparam T The data type of the frame's elements
88  * @tparam TVariance The data type of the variance's elements
89  */
90  template <typename T, typename TVariance>
91  static bool validateDeviation1Channel(const Frame& frame, const Frame& variance, const unsigned int window);
92 
93  /**
94  * Validation computation of per-channel mean, variance, and standard deviation of images.
95  * @param frame The frame for which the validation will be applied, must be valid
96  * @param width The width of the source frame in pixel, range: [1, infinity)
97  * @param height the height of the source frame in pixel, range: [1, infinity)
98  * @param paddingElements Number of padding elements, range: [0, infinity)
99  * @param testMean Mean results to be validated, must have @c tChannels elements, can be nullptr if not tested
100  * @param testVariance Variance results to be validated, must have @c tChannels elements, can be nullptr if not tested
101  * @param testStandardDeviation Standard deviation results to be validated, must have @c tChannels elements, can be nullptr if not tested
102  * @param maxErrorMean Resulting maximum error for mean over all channels
103  * @param maxErrorVariance Return the maximum error for variance over all channels
104  * @param maxErrorStandardDeviation Return the maximum error for standard deviation over all channels
105  * @return True, if succeeded
106  * @tparam TElementType Type of the elements of the source pixels
107  * @tparam tChannels Number of channels of the source image, range: [1, infinity)
108  */
109  template <typename TElementType, unsigned int tChannels>
110  static bool validateFrameStatistics(const TElementType* frame, const unsigned int width, const unsigned int height, const unsigned paddingElements, const double* testMean, const double* testVariance, const double* testStandardDeviation, double& maxErrorMean, double& maxErrorVariance, double& maxErrorStandardDeviation);
111 };
112 
113 } // namespace TestCV
114 
115 } // namespace Test
116 
117 } // namespace Ocean
118 
119 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_VARIANCE_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements tests for the frame variance functions.
Definition: TestFrameVariance.h:29
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the frame variance functions.
static bool validateFrameStatistics(const TElementType *frame, const unsigned int width, const unsigned int height, const unsigned paddingElements, const double *testMean, const double *testVariance, const double *testStandardDeviation, double &maxErrorMean, double &maxErrorVariance, double &maxErrorStandardDeviation)
Validation computation of per-channel mean, variance, and standard deviation of images.
static bool validateDeviation1Channel(const Frame &frame, const Frame &variance, const unsigned int window)
Validates the frame deviation function for a 1 channel 8 bit frame.
static bool testDeviation1Channel8Bit(const unsigned int width, const unsigned int height, const unsigned int window, const double testDuration)
Tests the frame deviation function for a 1 channel 8 bit frame.
static bool testFrameStatistics(const unsigned width, const unsigned int height, const double testDuration)
Tests the computation of per-channel mean, variance, and standard deviation of images This test will ...
static bool testFrameStatistics(const unsigned width, const unsigned int height, const double testDuration)
Tests the computation of per-channel mean, variance, and standard deviation of images This test will ...
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