Ocean
Loading...
Searching...
No Matches
TestSumSquareDifferences.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_SQUARE_DIFFERENCES_H
9#define META_OCEAN_TEST_TESTCV_SUM_SQUARE_DIFFERENCES_H
10
12
14
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestCV
24{
25
26/**
27 * This class implements sum square differences (SSD) tests.
28 * @ingroup testcv
29 */
30class OCEAN_TEST_CV_EXPORT TestSumSquareDifferences
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 * Tests the entire sum square differences functions.
55 * @param testDuration Number of seconds for each test, with range (0, infinity)
56 * @param selector Test selector for filtering sub-tests; default runs all tests
57 * @return True, if succeeded
58 */
59 static bool test(const double testDuration, const TestSelector& selector = TestSelector());
60
61 /**
62 * Tests the sum square differences function for two image patches.
63 * @param testDuration Number of seconds for each test, with range (0, infinity)
64 * @return True, if succeeded
65 */
66 static bool testPatch8BitPerChannel(const double testDuration);
67
68 /**
69 * Tests the sum square differences function for two buffers.
70 * @param testDuration Number of seconds for each test, with range (0, infinity)
71 * @return True, if succeeded
72 */
73 static bool testBuffer8BitPerChannel(const double testDuration);
74
75 /**
76 * Tests the sum square differences function between an image patch and a buffer.
77 * @param testDuration Number of seconds for each test, with range (0, infinity)
78 * @return True, if succeeded
79 */
80 static bool testPatchBuffer8BitPerChannel(const double testDuration);
81
82 /**
83 * Tests the sum square differences function for two image patches which are mirrored at the image border.
84 * @param testDuration Number of seconds for each test, with range (0, infinity)
85 * @return True, if succeeded
86 */
87 static bool testPatchMirroredBorder8BitPerChannel(const double testDuration);
88
89 /**
90 * Tests the sum square differences function for image patches with pixel accuracy which can be partially outside of the image.
91 * @param testDuration Number of seconds for each test, with range (0, infinity)
92 * @return True, if succeeded
93 */
94 static bool testPatchAtBorder8BitPerChannel(const double testDuration);
95
96 private:
97
98 /**
99 * Tests the sum square differences function for two image patches.
100 * @param width The width of the test image, in pixel, with range [tSize, infinity)
101 * @param height The height of the test image, in pixel, with range [tSize, infinity)
102 * @param testDuration Number of seconds for each test, with range (0, infinity)
103 * @return True, if succeeded
104 * @tparam tChannels The number of frame channels, with range [1, infinity)
105 * @tparam tPatchSize The size of the patch, with range [1, infinity)
106 */
107 template <unsigned int tChannels, unsigned int tPatchSize>
108 static bool testPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
109
110 /**
111 * Tests the sum square differences function for two buffers.
112 * @param width The width of the test image, in pixel, with range [tSize, infinity)
113 * @param height The height of the test image, in pixel, with range [tSize, infinity)
114 * @param testDuration Number of seconds for each test, with range (0, infinity)
115 * @return True, if succeeded
116 * @tparam tChannels The number of channels, with range [1, infinity)
117 * @tparam tPixels The number of pixels in the buffer, with range [1, infinity)
118 */
119 template <unsigned int tChannels, unsigned int tPixels>
120 static bool testBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
121
122 /**
123 * Tests the sum square differences function between an image patch and a buffer.
124 * @param width The width of the test image, in pixel, with range [tSize, infinity)
125 * @param height The height of the test image, in pixel, with range [tSize, 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 testPatchBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
133
134 /**
135 * Tests the sum square differences function for image patches with pixel accuracy which can be partially outside of the image.
136 * @param width The width of the test image, in pixel, with range [tSize, infinity)
137 * @param height The height of the test image, in pixel, with range [tSize, 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 tPatchSize The size of the patch, with range [1, infinity)
142 */
143 template <unsigned int tChannels, unsigned int tPatchSize>
144 static bool testPatchAtBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
145
146 /**
147 * Tests the sum square differences function for two image patches which are mirrored at the image border.
148 * @param width The width of the test image, in pixel, with range [tSize, infinity)
149 * @param height The height of the test image, in pixel, with range [tSize, 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 tSize The size of the patch, with range [1, infinity)
154 */
155 template <unsigned int tChannels, unsigned int tSize>
156 static bool testPatchMirroredBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
157
158 protected:
159
160 /**
161 * Calculates the ssd value between two pixel accurate patches which can be partially outside of the frame.
162 * @param frame0 First frame to be used, must be valid, must be valid
163 * @param frame1 Second frame to be used, must be valid, must be valid
164 * @param center0 Center position in the first frame, with range [0, width0 - 1]x[0, height0 - 1]
165 * @param center1 Center position in the first frame, with range [0, width1 - 1]x[0, height1 - 1]
166 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
167 * @return The resulting pair holding the ssd and the number of pixels which contributed to the ssd, and ssd of -1 if a patch0 pixel does not have a corresponding patch1 pixel
168 */
169 static IndexPair32 calculateAtBorder8BitPerChannel(const Frame& frame0, const Frame& frame1, const CV::PixelPosition& center0, const CV::PixelPosition& center1, const unsigned int patchSize);
170};
171
172}
173
174}
175
176}
177
178#endif // META_OCEAN_TEST_TESTCV_SUM_SQUARE_DIFFERENCES_H
This class implements Ocean's image class.
Definition Frame.h:1879
This class implements sum square differences (SSD) tests.
Definition TestSumSquareDifferences.h:31
static bool test(const double testDuration, const TestSelector &selector=TestSelector())
Tests the entire sum square differences functions.
static bool testPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for two image patches.
static bool testPatchMirroredBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for two image patches which are mirrored at the image borde...
static bool testPatchMirroredBorder8BitPerChannel(const double testDuration)
Tests the sum square differences function for two image patches which are mirrored at the image borde...
static bool testPatchAtBorder8BitPerChannel(const double testDuration)
Tests the sum square differences function for image patches with pixel accuracy which can be partiall...
static bool testBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for two buffers.
ImplementationType
Definition of individual types of implementation.
Definition TestSumSquareDifferences.h:38
@ IT_TEMPLATE
The template-based implementation.
Definition TestSumSquareDifferences.h:42
@ IT_NEON
The NEON-based implementation.
Definition TestSumSquareDifferences.h:46
@ IT_NAIVE
The naive implementation.
Definition TestSumSquareDifferences.h:40
@ IT_SSE
The SSE-based implementation.
Definition TestSumSquareDifferences.h:44
static bool testPatchAtBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum square differences function for image patches with pixel accuracy which can be partiall...
static bool testBuffer8BitPerChannel(const double testDuration)
Tests the sum square differences function for two buffers.
static IndexPair32 calculateAtBorder8BitPerChannel(const Frame &frame0, const Frame &frame1, const CV::PixelPosition &center0, const CV::PixelPosition &center1, const unsigned int patchSize)
Calculates the ssd value between two pixel accurate patches which can be partially outside of the fra...
static bool testPatch8BitPerChannel(const double testDuration)
Tests the sum square differences function for two image patches.
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 bool testPatchBuffer8BitPerChannel(const double testDuration)
Tests the sum square differences function between an image patch and a buffer.
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