Ocean
Loading...
Searching...
No Matches
TestSumAbsoluteDifferences.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_SUM_ABSOLUTE_DIFFERENCES_H
9#define META_OCEAN_TEST_TESTCV_SUM_ABSOLUTE_DIFFERENCES_H
10
12
14
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestCV
24{
25
26/**
27 * This class implements sum absolute differences (SAD) tests.
28 * @ingroup testcv
29 */
30class OCEAN_TEST_CV_EXPORT TestSumAbsoluteDifferences
31{
32 protected:
33
34 /**
35 * Definition of individual types of implementation.
36 */
37 enum ImplementationType : uint32_t
38 {
39 /// The naive implementation.
41 /// The template-based implementation.
43 /// The SSE-based implementation.
45 /// The NEON-based implementation.
47 /// The default implementation (which is actually used by default).
48 IT_DEFAULT
49 };
50
51 public:
52
53 /**
54 * Invokes all tests testing absolute differences functionalities.
55 * @param testDuration Number of seconds for each test, with range (0, infinity)
56 * @param selector The test selector to control which tests to run
57 * @return True, if succeeded
58 */
59 static bool test(const double testDuration, const TestSelector& selector = TestSelector());
60
61 /**
62 * Tests the absolute differences function between entire frames with one plane.
63 * @param testDuration Number of seconds for each test, with range (0, infinity)
64 * @return True, if succeeded
65 */
66 static bool testDifferenceBetweenFramesWithOnePlane(const double testDuration);
67
68 /**
69 * Tests the absolute differences function between entire frames with several planes.
70 * @param testDuration Number of seconds for each test, with range (0, infinity)
71 * @return True, if succeeded
72 */
73 static bool testDifferenceBetweenFramesWithSeveralPlanes(const double testDuration);
74
75 /**
76 * Tests the absolute differences function for two image patches.
77 * @param testDuration Number of seconds for each test, with range (0, infinity)
78 * @return True, if succeeded
79 */
80 static bool testPatch8BitPerChannel(const double testDuration);
81
82 /**
83 * Tests the absolute differences function for two buffers.
84 * @param testDuration Number of seconds for each test, with range (0, infinity)
85 * @return True, if succeeded
86 */
87 static bool testBuffer8BitPerChannel(const double testDuration);
88
89 /**
90 * Tests the sum absolute differences function between an image patch and a buffer.
91 * @param testDuration Number of seconds for each test, with range (0, infinity)
92 * @return True, if succeeded
93 */
94 static bool testPatchBuffer8BitPerChannel(const double testDuration);
95
96 /**
97 * Tests the sum absolute differences function for two image patches which are mirrored at the image border.
98 * @param testDuration Number of seconds for each test, with range (0, infinity)
99 * @return True, if succeeded
100 */
101 static bool testPatchMirroredBorder8BitPerChannel(const double testDuration);
102
103 private:
104
105 /**
106 * Applies one test of the absolute differences function between entire frames with one plane for a specific data type.
107 * @return True, if succeeded
108 * @tparam T The data type to test
109 */
110 template <typename T>
112
113 /**
114 * Applies one test of the absolute differences function between entire frames with one plane for a specific data type and channel number.
115 * @return True, if succeeded
116 * @tparam T The data type to test
117 * @tparam tChannels The number of frame channels, with range [1, 5]
118 */
119 template <typename T, unsigned int tChannels>
121
122 /**
123 * Tests the absolute differences function for two image patches.
124 * @param width The width of the test image, in pixel, with range [tPatchSize, infinity)
125 * @param height The height of the test image, in pixel, with range [tPatchSize, infinity)
126 * @param testDuration Number of seconds for each test, with range (0, infinity)
127 * @return True, if succeeded
128 * @tparam tChannels The number of frame channels, with range [1, infinity)
129 * @tparam tPatchSize The size of the patch, with range [1, infinity)
130 */
131 template <unsigned int tChannels, unsigned int tPatchSize>
132 static bool testPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
133
134 /**
135 * Tests the sum absolute differences function for two buffers.
136 * @param width The width of the test image, in pixel, with range [1, infinity)
137 * @param height The height of the test image, in pixel, with range [1, infinity)
138 * @param testDuration Number of seconds for each test, with range (0, infinity)
139 * @return True, if succeeded
140 * @tparam tChannels The number of frame channels, with range [1, infinity)
141 * @tparam tPixels The number of pixels in the buffer, with range [1, infinity)
142 */
143 template <unsigned int tChannels, unsigned int tPixels>
144 static bool testBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
145
146 /**
147 * Tests the sum absolute differences function between an image patch and a buffer.
148 * @param width The width of the test image, in pixel, with range [tPatchSize, infinity)
149 * @param height The height of the test image, in pixel, with range [tPatchSize, infinity)
150 * @param testDuration Number of seconds for each test, with range (0, infinity)
151 * @return True, if succeeded
152 * @tparam tChannels The number of frame channels, with range [1, infinity)
153 * @tparam tPatchSize The size of the patch, with range [1, infinity)
154 */
155 template <unsigned int tChannels, unsigned int tPatchSize>
156 static bool testPatchBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
157
158 /**
159 * Tests the sum absolute differences function for two image patches which are mirrored at the image border.
160 * @param width The width of the test image, in pixel, with range [tSize, infinity)
161 * @param height The height of the test image, in pixel, with range [tSize, infinity)
162 * @param testDuration Number of seconds for each test, with range (0, infinity)
163 * @return True, if succeeded
164 * @tparam tChannels The number of frame channels, with range [1, infinity)
165 * @tparam tSize The size of the patch, with range [1, infinity)
166 */
167 template <unsigned int tChannels, unsigned int tSize>
168 static bool testPatchMirroredBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
169};
170
171}
172
173}
174
175}
176
177#endif // META_OCEAN_TEST_TESTCV_SUM_ABSOLUTE_DIFFERENCES_H
This class implements sum absolute differences (SAD) tests.
Definition TestSumAbsoluteDifferences.h:31
static bool testDifferenceBetweenFramesWithSeveralPlanes(const double testDuration)
Tests the absolute differences function between entire frames with several planes.
static bool testPatchMirroredBorder8BitPerChannel(const double testDuration)
Tests the sum absolute differences function for two image patches which are mirrored at the image bor...
static bool test(const double testDuration, const TestSelector &selector=TestSelector())
Invokes all tests testing absolute differences functionalities.
static bool testBuffer8BitPerChannel(const double testDuration)
Tests the absolute differences function for two buffers.
static bool testDifferenceBetweenFramesWithOnePlane()
Applies one test of the absolute differences function between entire frames with one plane for a spec...
static bool testPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the absolute differences function for two image patches.
static bool testPatch8BitPerChannel(const double testDuration)
Tests the absolute differences function for two image patches.
static bool testDifferenceBetweenFramesWithOnePlane(const double testDuration)
Tests the absolute differences function between entire frames with one plane.
static bool testDifferenceBetweenFramesWithOnePlane()
Applies one test of the absolute differences function between entire frames with one plane for a spec...
static bool testPatchMirroredBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum absolute differences function for two image patches which are mirrored at the image bor...
static bool testPatchBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum absolute differences function between an image patch and a buffer.
ImplementationType
Definition of individual types of implementation.
Definition TestSumAbsoluteDifferences.h:38
@ IT_TEMPLATE
The template-based implementation.
Definition TestSumAbsoluteDifferences.h:42
@ IT_NAIVE
The naive implementation.
Definition TestSumAbsoluteDifferences.h:40
@ IT_NEON
The NEON-based implementation.
Definition TestSumAbsoluteDifferences.h:46
@ IT_SSE
The SSE-based implementation.
Definition TestSumAbsoluteDifferences.h:44
static bool testPatchBuffer8BitPerChannel(const double testDuration)
Tests the sum absolute differences function between an image patch and a buffer.
static bool testBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum absolute differences function for two buffers.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
The namespace covering the entire Ocean framework.
Definition Accessor.h:15