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
15namespace Ocean
16{
17
18namespace Test
19{
20
21namespace TestCV
22{
23
24/**
25 * This class implements sum square differences (SSD) tests.
26 * @ingroup testcv
27 */
28class OCEAN_TEST_CV_EXPORT TestSumSquareDifferences
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 * Tests the entire sum square differences functions.
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 sum square differences function for two image patches.
60 * @param testDuration Number of seconds for each test, with range (0, infinity)
61 * @return True, if succeeded
62 */
63 static bool testPatch8BitPerChannel(const double testDuration);
64
65 /**
66 * Tests the sum square differences function for two buffers.
67 * @param testDuration Number of seconds for each test, with range (0, infinity)
68 * @return True, if succeeded
69 */
70 static bool testBuffer8BitPerChannel(const double testDuration);
71
72 /**
73 * Tests the sum square differences function between an image patch and a buffer.
74 * @param testDuration Number of seconds for each test, with range (0, infinity)
75 * @return True, if succeeded
76 */
77 static bool testPatchBuffer8BitPerChannel(const double testDuration);
78
79 /**
80 * Tests the sum square differences function for two image patches which are mirrored at the image border.
81 * @param testDuration Number of seconds for each test, with range (0, infinity)
82 * @return True, if succeeded
83 */
84 static bool testPatchMirroredBorder8BitPerChannel(const double testDuration);
85
86 /**
87 * Tests the sum square differences function for image patches with pixel accuracy which can be partially outside of the image.
88 * @param testDuration Number of seconds for each test, with range (0, infinity)
89 * @return True, if succeeded
90 */
91 static bool testPatchAtBorder8BitPerChannel(const double testDuration);
92
93 private:
94
95 /**
96 * Tests the sum square differences function for two image patches.
97 * @param width The width of the test image, in pixel, with range [tSize, infinity)
98 * @param height The height of the test image, in pixel, with range [tSize, infinity)
99 * @param testDuration Number of seconds for each test, with range (0, infinity)
100 * @return True, if succeeded
101 * @tparam tChannels The number of frame channels, with range [1, infinity)
102 * @tparam tPatchSize The size of the patch, with range [1, infinity)
103 */
104 template <unsigned int tChannels, unsigned int tPatchSize>
105 static bool testPatch8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
106
107 /**
108 * Tests the sum square differences function for two buffers.
109 * @param width The width of the test image, in pixel, with range [tSize, infinity)
110 * @param height The height of the test image, in pixel, with range [tSize, infinity)
111 * @param testDuration Number of seconds for each test, with range (0, infinity)
112 * @return True, if succeeded
113 * @tparam tChannels The number of channels, with range [1, infinity)
114 * @tparam tPixels The number of pixels in the buffer, with range [1, infinity)
115 */
116 template <unsigned int tChannels, unsigned int tPixels>
117 static bool testBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
118
119 /**
120 * Tests the sum square differences function between an image patch and a buffer.
121 * @param width The width of the test image, in pixel, with range [tSize, infinity)
122 * @param height The height of the test image, in pixel, with range [tSize, 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 testPatchBuffer8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
130
131 /**
132 * Tests the sum square differences function for image patches with pixel accuracy which can be partially outside of the image.
133 * @param width The width of the test image, in pixel, with range [tSize, infinity)
134 * @param height The height of the test image, in pixel, with range [tSize, 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 tPatchSize The size of the patch, with range [1, infinity)
139 */
140 template <unsigned int tChannels, unsigned int tPatchSize>
141 static bool testPatchAtBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
142
143 /**
144 * Tests the sum square differences function for two image patches which are mirrored at the image border.
145 * @param width The width of the test image, in pixel, with range [tSize, infinity)
146 * @param height The height of the test image, in pixel, with range [tSize, 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 tSize The size of the patch, with range [1, infinity)
151 */
152 template <unsigned int tChannels, unsigned int tSize>
153 static bool testPatchMirroredBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
154
155 protected:
156
157 /**
158 * Calculates the ssd value between two pixel accurate patches which can be partially outside of the frame.
159 * @param frame0 First frame to be used, must be valid, must be valid
160 * @param frame1 Second frame to be used, must be valid, must be valid
161 * @param center0 Center position in the first frame, with range [0, width0 - 1]x[0, height0 - 1]
162 * @param center1 Center position in the first frame, with range [0, width1 - 1]x[0, height1 - 1]
163 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
164 * @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
165 */
166 static IndexPair32 calculateAtBorder8BitPerChannel(const Frame& frame0, const Frame& frame1, const CV::PixelPosition& center0, const CV::PixelPosition& center1, const unsigned int patchSize);
167};
168
169}
170
171}
172
173}
174
175#endif // META_OCEAN_TEST_TESTCV_SUM_SQUARE_DIFFERENCES_H
This class implements Ocean's image class.
Definition Frame.h:1808
This class implements sum square differences (SSD) tests.
Definition TestSumSquareDifferences.h:29
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:36
@ IT_TEMPLATE
The template-based implementation.
Definition TestSumSquareDifferences.h:40
@ IT_NEON
The NEON-based implementation.
Definition TestSumSquareDifferences.h:44
@ IT_NAIVE
The naive implementation.
Definition TestSumSquareDifferences.h:38
@ IT_SSE
The SSE-based implementation.
Definition TestSumSquareDifferences.h:42
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 test(const double testDuration)
Tests the entire sum square differences functions.
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.
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