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