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