Ocean
Loading...
Searching...
No Matches
TestFrameNormalizer.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_NORMALIZER_H
9#define OCEAN_TEST_TESTCV_TEST_FRAME_NORMALIZER_H
10
12
14
15#include "ocean/base/Worker.h"
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestCV
24{
25
26/**
27 * This class implements tests for the FrameNormalizer class.
28 * @ingroup testcv
29 */
30class OCEAN_TEST_CV_EXPORT TestFrameNormalizer
31{
32 public:
33
34 /**
35 * Starts all tests of the FrameNormalizer class.
36 * @param testDuration Number of seconds for each test, with range (0, infinity)
37 * @param worker The worker object to distribute the computation
38 * @param selector Test selector for filtering sub-tests; default runs all tests
39 * @return True, if succeeded
40 */
41 static bool test(const double testDuration, Worker& worker, const TestSelector& selector = TestSelector());
42
43 /**
44 * Tests the 1-channel normalizer to 8-bit function.
45 * @param testDuration Number of seconds for each test, with range (0, infinity)
46 * @param worker The worker object to distribute the computation
47 * @return True, if succeeded
48 * @tparam T The data type to be used for testing
49 */
50 static bool testNormalizerToUint8(const double testDuration, Worker& worker);
51
52 /**
53 * Tests the 1-channel normalizer to 8-bit function.
54 * @param testDuration Number of seconds for each test, with range (0, infinity)
55 * @param worker The worker object to distribute the computation
56 * @return True, if succeeded
57 * @tparam T The data type to be used for testing
58 * @tparam tExtremeValueRange True, to use an extreme value range for floating point frames
59 */
60 template <typename T, bool tExtremeValueRange = false>
61 static bool testNormalizerToUint8(const double testDuration, Worker& worker);
62
63 /**
64 * Tests the normalization function to float images.
65 * @param testDuration Number of seconds for each test, with range (0, infinity)
66 * @param worker The worker object to distribute the computation
67 * @return True, if succeeded
68 */
69 static bool testNormalizeToFloat(const double testDuration, Worker& worker);
70
71 /**
72 * Tests the normalization function to float images.
73 * @param testDuration Number of seconds for each test, with range (0, infinity)
74 * @param worker The worker object to distribute the computation
75 * @return True, if succeeded
76 * @tparam TSource The data type of the source frame
77 * @tparam TTarget The data type of the normalized frame
78 * @tparam tChannels The number of channels of the source and normalized frames, range: [1, infinity)
79 */
80 template <typename TSource, typename TTarget, unsigned int tChannels>
81 static bool testNormalizeToFloat(const double testDuration, Worker& worker);
82
83 /**
84 * Test the value range of the float normalizer.
85 * @param testDuration Number of seconds for each test, with range (0, infinity)
86 * @param worker The worker object to distribute the computation
87 * @return True, if succeeded
88 */
89 static bool testValueRangeNormalizerToUint8(const double testDuration, Worker& worker);
90
91 /**
92 * Test the value range of the float normalizer.
93 * @param testDuration Number of seconds for each test, with range (0, infinity)
94 * @param worker The worker object to distribute the computation
95 * @return True, if succeeded
96 * @tparam TFloat The float data type of the source frame, either 'float' or 'double'
97 */
98 template <typename TFloat>
99 static bool testValueRangeNormalizerToUint8(const double testDuration, Worker& worker);
100
101 protected:
102
103 /**
104 * Verifies the linear normalizer of arbitrary images to an 8 bit image.
105 * @param frame The input frame which will be normalized, must be valid
106 * @param normalized The normalized image to verify, must be valid
107 * @param width The width of the frame in pixel, with range [1, infinity)
108 * @param height The height of the frame in pixel, with range [1, infinity)
109 * @param framePaddingElements The number of padding elements of the input frame, in elements, with range [0, infinity)
110 * @param normalizedPaddingElements The number of padding elements of the normalized frame, in elements, with range [0, infinity)
111 * @return True, if succeeded
112 * @tparam T The data type of the source frame
113 */
114 template <typename T>
115 static bool verifyLinearNormalizedUint8(const T* const frame, const uint8_t* const normalized, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int normalizedPaddingElements);
116
117 /**
118 * Verifies the linear normalizer arbitrary images to a float image
119 * @param frame The input frame which will be normalized, must be valid
120 * @param normalized The normalized image to verify, must be valid
121 * @param width The width of the frame in pixel, with range [1, infinity)
122 * @param height The height of the frame in pixel, with range [1, infinity)
123 * @param bias The bias values, must be valid if `scale` is valid and `nullptr` is `scale` is `nullptr`
124 * @param scale the scale values, must be valid if `bias` is valid and `nullptr` is `bias` is `nullptr`
125 * @param framePaddingElements The number of padding elements of the input frame, in elements, with range [0, infinity)
126 * @param normalizedPaddingElements The number of padding elements of the normalized frame, in elements, with range [0, infinity)
127 * @param maxAbsoluteError Returns the maximum absolute error that has been measured
128 * @return True, if succeeded
129 * @tparam TSource The data type of the source frame
130 * @tparam TTarget The data type of the normalized frame
131 * @tparam tChannels The number of channels of the source and normalized frames, range: [1, infinity)
132 */
133 template <typename TSource, typename TTarget, unsigned int tChannels>
134 static bool verifyNormalizeToFloat(const TSource* frame, const TTarget* normalized, const unsigned int width, const unsigned height, const TTarget* bias, const TTarget* scale, const unsigned int framePaddingElements, const unsigned int normalizedPaddingElements, double& maxAbsoluteError);
135};
136
137}
138
139}
140
141}
142
143#endif // OCEAN_TEST_TESTCV_TEST_FRAME_NORMALIZER_H
This class implements tests for the FrameNormalizer class.
Definition TestFrameNormalizer.h:31
static bool testNormalizeToFloat(const double testDuration, Worker &worker)
Tests the normalization function to float images.
static bool testNormalizeToFloat(const double testDuration, Worker &worker)
Tests the normalization function to float images.
static bool testNormalizerToUint8(const double testDuration, Worker &worker)
Tests the 1-channel normalizer to 8-bit function.
static bool verifyNormalizeToFloat(const TSource *frame, const TTarget *normalized, const unsigned int width, const unsigned height, const TTarget *bias, const TTarget *scale, const unsigned int framePaddingElements, const unsigned int normalizedPaddingElements, double &maxAbsoluteError)
Verifies the linear normalizer arbitrary images to a float image.
static bool verifyLinearNormalizedUint8(const T *const frame, const uint8_t *const normalized, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const unsigned int normalizedPaddingElements)
Verifies the linear normalizer of arbitrary images to an 8 bit image.
static bool testNormalizerToUint8(const double testDuration, Worker &worker)
Tests the 1-channel normalizer to 8-bit function.
static bool testValueRangeNormalizerToUint8(const double testDuration, Worker &worker)
Test the value range of the float normalizer.
static bool test(const double testDuration, Worker &worker, const TestSelector &selector=TestSelector())
Starts all tests of the FrameNormalizer class.
static bool testValueRangeNormalizerToUint8(const double testDuration, Worker &worker)
Test the value range of the float normalizer.
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