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