Ocean
Loading...
Searching...
No Matches
TestAdvancedZeroMeanSumSquareDifferences.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_TESTADVANCED_TEST_ADVANCED_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
9#define META_OCEAN_TEST_TESTCV_TESTADVANCED_TEST_ADVANCED_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
10
12
13#include "ocean/base/Frame.h"
14#include "ocean/base/Worker.h"
15
17
18#include "ocean/math/Vector2.h"
19
21
22namespace Ocean
23{
24
25namespace Test
26{
27
28namespace TestCV
29{
30
31namespace TestAdvanced
32{
33
34/**
35 * This class implements an advanced zero-mean sum square differences test.
36 * @ingroup testcvadvanced
37 */
38class OCEAN_TEST_CV_ADVANCED_EXPORT TestAdvancedZeroMeanSumSquareDifferences
39{
40 protected:
41
42 /**
43 * Definition of individual types of implementation.
44 */
45 enum ImplementationType : uint32_t
46 {
47 /// The naive implementation.
49 /// The template-based implementation.
51 /// The SSE-based implementation.
53 /// The NEON-based implementation.
55 /// The default implementation (which is actually used by default).
56 IT_DEFAULT
57 };
58
59 public:
60
61 /**
62 * Tests all advanced zero-mean sum square differences functions.
63 * @param testDuration Number of seconds for each test, with range (0, infinity)
64 * @param selector The test selector to filter tests
65 * @return True, if succeeded
66 */
67 static bool test(const double testDuration, const TestSelector& selector);
68
69 /**
70 * Tests the sum square differences function for two sub-pixel accurate patches in two images.
71 * @param testDuration Number of seconds for each test, with range (0, infinity)
72 * @return True, if succeeded
73 */
74 static bool testTwoSubPixelPatch8BitPerChannel(const double testDuration);
75
76 /**
77 * Tests the sum square differences function for one sub-pixel accurate patch and one pixel-accurate patch in two images.
78 * @param testDuration Number of seconds for each test, with range (0, infinity)
79 * @return True, if succeeded
80 */
81 static bool testOneSubPixelPatch8BitPerChannel(const double testDuration);
82
83 /**
84 * Tests the sum square differences function between an image patch and a buffer.
85 * @param testDuration Number of seconds for each test, with range (0, infinity)
86 * @return True, if succeeded
87 */
88 static bool testPatchBuffer8BitPerChannel(const double testDuration);
89
90 /**
91 * Tests the sum square differences function between a sub-pixel image patch and a buffer.
92 * @param testDuration Number of seconds for each test, with range (0, infinity)
93 * @return True, if succeeded
94 */
95 static bool testPatchMirroredBorderBuffer8BitPerChannel(const double testDuration);
96
97 /**
98 * Tests the sum square differences function for two pixel accurate patches in combination with a mask.
99 * @param testDuration Number of seconds for each test, with range (0, infinity)
100 * @return True, if succeeded
101 */
102 static bool testTwoPixelPatchWithMask8BitPerChannel(const double testDuration);
103
104 private:
105
106 /**
107 * Tests the sum square differences function for two sub-pixel accurate patches in two images.
108 * @param width The width of the test image, in pixel, with range [tSize, infinity)
109 * @param height The height of the test image, in pixel, with range [tSize, infinity)
110 * @param testDuration Number of seconds for each test, with range (0, infinity)
111 * @return True, if succeeded
112 * @tparam tChannels The number of frame channels, with range [1, infinity)
113 * @tparam tPatchSize The size of the patch, with range [1, infinity)
114 */
115 template <unsigned int tChannels, unsigned int tPatchSize>
116 static bool testTwoSubPixelPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
117
118 /**
119 * Tests the sum square differences function for one sub-pixel accurate patch and one pixel-accurate patch in two images.
120 * @param width The width of the test image, in pixel, with range [tSize, infinity)
121 * @param height The height of the test image, in pixel, with range [tSize, infinity)
122 * @param testDuration Number of seconds for each test, with range (0, infinity)
123 * @return True, if succeeded
124 * @tparam tChannels The number of frame channels, with range [1, infinity)
125 * @tparam tPatchSize The size of the patch, with range [1, infinity)
126 */
127 template <unsigned int tChannels, unsigned int tPatchSize>
128 static bool testOneSubPixelPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
129
130 /**
131 * Tests the sum square differences function between an image patch and a buffer.
132 * @param width The width of the test image, in pixel, with range [tSize, infinity)
133 * @param height The height of the test image, in pixel, with range [tSize, infinity)
134 * @param testDuration Number of seconds for each test, with range (0, infinity)
135 * @return True, if succeeded
136 * @tparam tChannels The number of frame channels, with range [1, infinity)
137 * @tparam tPatchSize The size of the patch, with range [1, infinity)
138 */
139 template <unsigned int tChannels, unsigned int tPatchSize>
140 static bool testPatchBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
141
142 /**
143 * Tests the sum square differences function between an image patch (mirrored at the image border) and a buffer.
144 * @param width The width of the test image, in pixel, with range [tSize, infinity)
145 * @param height The height of the test image, in pixel, with range [tSize, infinity)
146 * @param testDuration Number of seconds for each test, with range (0, infinity)
147 * @return True, if succeeded
148 * @tparam tChannels The number of frame channels, with range [1, infinity)
149 * @tparam tPatchSize The size of the patch, with range [1, infinity)
150 */
151 template <unsigned int tChannels, unsigned int tPatchSize>
152 static bool testPatchMirroredBorderBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
153
154 /**
155 * Tests the sum square differences function for two pixel accurate patches in combination with a mask.
156 * @param width The width of the test image, in pixel, with range [tSize, infinity)
157 * @param height The height of the test image, in pixel, with range [tSize, infinity)
158 * @param testDuration Number of seconds for each test, with range (0, infinity)
159 * @return True, if succeeded
160 * @tparam tChannels The number of frame channels, with range [1, infinity)
161 * @tparam tPatchSize The size of the patch, with range [1, infinity)
162 */
163 template <unsigned int tChannels, unsigned int tPatchSize>
164 static bool testTwoPixelPatchWithMask8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
165
166 /**
167 * CCalculates the ssd value between two sub-pixel patches.
168 * @param frame0 First frame to be used, must be valid, must be valid
169 * @param frame1 Second frame to be used, must be valid, must be valid
170 * @param center0 Center position in the first frame, with range [patchSize/2, width0 - patchSize/2 - 1)x[patchSize/2, height0 - patchSize/2 - 1)
171 * @param center1 Center position in the second frame, with range [patchSize/2, width1 - patchSize/2 - 1)x[patchSize/2, height1 - patchSize/2 - 1)
172 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
173 * @return The resulting ssd
174 */
175 static uint32_t calculate8BitPerChannel(const Frame& frame0, const Frame& frame1, const Vector2& center0, const Vector2& center1, const unsigned int patchSize);
176
177 /**
178 * Calculates the ssd value between one sub-pixel patch and one pixel-accurate patch.
179 * @param frame0 First frame to be used, must be valid, must be valid
180 * @param frame1 Second frame to be used, must be valid, must be valid
181 * @param center0 Center position in the first frame, with range [patchSize/2, width0 - tSize/2)x[patchSize/2, height0 - patchSize/2)
182 * @param center1 Center position in the second frame, with range [patchSize/2, width1 - patchSize/2 - 1)x[patchSize/2, height1 - patchSize/2 - 1)
183 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
184 * @return The resulting ssd
185 */
186 static uint32_t calculate8BitPerChannel(const Frame& frame0, const Frame& frame1, const CV::PixelPosition& center0, const Vector2& center1, const unsigned int patchSize);
187
188 /**
189 * Calculates the ssd value between one sub-pixel patch and a buffer.
190 * @param frame0 First frame to be used, must be valid, must be valid
191 * @param center0 Center position in the first frame, with range [patchSize/2, width0 - patchSize/2 - 1)x[patchSize/2, height0 - patchSize/2 - 1)
192 * @param buffer1 The pointer to the buffer, must be valid
193 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
194 * @return The resulting ssd
195 */
196 static uint32_t calculate8BitPerChannel(const Frame& frame0, const Vector2& center0, const uint8_t* buffer1, const unsigned int patchSize);
197
198 /**
199 * Calculates the ssd value between one sub-pixel patch (mirrored at the image border) and a buffer.
200 * @param frame0 First frame to be used, must be valid, must be valid
201 * @param center0 Center position in the first frame, with range [patchSize/2, width0 - patchSize/2 - 1)x[patchSize/2, height0 - patchSize/2 - 1)
202 * @param buffer1 The pointer to the buffer, must be valid
203 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
204 * @return The resulting ssd
205 */
206 static uint32_t calculateMirroredBorder8BitPerChannel(const Frame& frame0, const Vector2& center0, const uint8_t* buffer1, const unsigned int patchSize);
207
208 /**
209 * Calculates the sum of squared differences value between two patches with associated masks.
210 * @param frame0 First frame to be used, must be valid, must be valid
211 * @param frame1 Second frame to be used, must be valid, must be valid
212 * @param mask0 First mask to be used, must be valid, must be valid
213 * @param mask1 Second mask to be used, must be valid, must be valid
214 * @param center0 Center position in the first frame, with range [patchSize/2, width0 - tSize/2)x[patchSize/2, height0 - patchSize/2)
215 * @param center1 Center position in the second frame, with range [patchSize/2, width1 - tSize/2 - 1)x[patchSize/2, height1 - patchSize/2 - 1)
216 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
217 * @param maskValue The pixel value for mask pixels which will be excluded from SSD calculation
218 * @return The resulting ssd
219 */
220 static IndexPair32 calculateWithMask8BitPerChannel(const Frame& frame0, const Frame& frame1, const Frame& mask0, const Frame& mask1, const CV::PixelPosition& center0, const CV::PixelPosition& center1, const unsigned int patchSize, const uint8_t maskValue);
221};
222
223}
224
225}
226
227}
228
229}
230
231#endif // META_OCEAN_TEST_TESTCV_TESTADVANCED_TEST_ADVANCED_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
This class implements Ocean's image class.
Definition Frame.h:1879
This class implements an advanced zero-mean sum square differences test.
Definition TestAdvancedZeroMeanSumSquareDifferences.h:39
static bool testOneSubPixelPatch8BitPerChannel(const double testDuration)
Tests the sum square differences function for one sub-pixel accurate patch and one pixel-accurate pat...
static uint32_t calculate8BitPerChannel(const Frame &frame0, const Frame &frame1, const Vector2 &center0, const Vector2 &center1, const unsigned int patchSize)
CCalculates the ssd value between two sub-pixel patches.
static bool testTwoPixelPatchWithMask8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for two pixel accurate patches in combination with a mask.
static bool testPatchMirroredBorderBuffer8BitPerChannel(const double testDuration)
Tests the sum square differences function between a sub-pixel image patch and a buffer.
static bool testPatchBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function between an image patch and a buffer.
static uint32_t calculate8BitPerChannel(const Frame &frame0, const Frame &frame1, const CV::PixelPosition &center0, const Vector2 &center1, const unsigned int patchSize)
Calculates the ssd value between one sub-pixel patch and one pixel-accurate patch.
static bool testTwoPixelPatchWithMask8BitPerChannel(const double testDuration)
Tests the sum square differences function for two pixel accurate patches in combination with a mask.
static bool testPatchBuffer8BitPerChannel(const double testDuration)
Tests the sum square differences function between an image patch and a buffer.
static uint32_t calculateMirroredBorder8BitPerChannel(const Frame &frame0, const Vector2 &center0, const uint8_t *buffer1, const unsigned int patchSize)
Calculates the ssd value between one sub-pixel patch (mirrored at the image border) and a buffer.
static bool testPatchMirroredBorderBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function between an image patch (mirrored at the image border) and a...
ImplementationType
Definition of individual types of implementation.
Definition TestAdvancedZeroMeanSumSquareDifferences.h:46
@ IT_TEMPLATE
The template-based implementation.
Definition TestAdvancedZeroMeanSumSquareDifferences.h:50
@ IT_NEON
The NEON-based implementation.
Definition TestAdvancedZeroMeanSumSquareDifferences.h:54
@ IT_SSE
The SSE-based implementation.
Definition TestAdvancedZeroMeanSumSquareDifferences.h:52
@ IT_NAIVE
The naive implementation.
Definition TestAdvancedZeroMeanSumSquareDifferences.h:48
static uint32_t calculate8BitPerChannel(const Frame &frame0, const Vector2 &center0, const uint8_t *buffer1, const unsigned int patchSize)
Calculates the ssd value between one sub-pixel patch and a buffer.
static bool testTwoSubPixelPatch8BitPerChannel(const double testDuration)
Tests the sum square differences function for two sub-pixel accurate patches in two images.
static bool testTwoSubPixelPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for two sub-pixel accurate patches in two images.
static bool testOneSubPixelPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for one sub-pixel accurate patch and one pixel-accurate pat...
static bool test(const double testDuration, const TestSelector &selector)
Tests all advanced zero-mean sum square differences functions.
static IndexPair32 calculateWithMask8BitPerChannel(const Frame &frame0, const Frame &frame1, const Frame &mask0, const Frame &mask1, const CV::PixelPosition &center0, const CV::PixelPosition &center1, const unsigned int patchSize, const uint8_t maskValue)
Calculates the sum of squared differences value between two patches with associated masks.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
std::pair< Index32, Index32 > IndexPair32
Definition of a pair holding 32 bit indices.
Definition Base.h:138
The namespace covering the entire Ocean framework.
Definition Accessor.h:15