Ocean
Loading...
Searching...
No Matches
TestMappingI1.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_TESTSYNTHESIS_TEST_MAPPING_I_1_H
9#define META_OCEAN_TEST_TESTCV_TESTSYNTHESIS_TEST_MAPPING_I_1_H
10
12
13#include "ocean/base/Frame.h"
14
16
18
19namespace Ocean
20{
21
22namespace Test
23{
24
25namespace TestCV
26{
27
28namespace TestSynthesis
29{
30
31/**
32 * This class implements a synthesis pixel mapping test.
33 * @ingroup testcvsynthesis
34 */
35class OCEAN_TEST_CV_SYNTHESIS_EXPORT TestMappingI1 : protected CV::Synthesis::MappingI1
36{
37 public:
38
39 /**
40 * Tests all mapping functions.
41 * @param width The width of the source frame in pixel, with range [1, infinity)
42 * @param height The height of the source frame in pixel, with range [1, infinity)
43 * @param testDuration Number of seconds for each test, with range (0, infinity)
44 * @param worker The worker object to distribute the CPU load
45 * @param selector The test selector
46 * @return True, if succeeded
47 */
48 static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker, const TestSelector& selector);
49
50 /**
51 * Tests the applyMapping function.
52 * @param width The width of the source frame in pixel, with range [1, infinity)
53 * @param height The height of the source frame in pixel, with range [1, infinity)
54 * @param testDuration Number of seconds for each test, with range (0, infinity)
55 * @param worker The worker object to distribute the CPU load
56 * @return True, if succeeded
57 */
58 static bool testApplyMapping(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
59
60 /**
61 * Tests the applyMapping function for a specific pixel format.
62 * @param width The width of the source frame in pixel, with range [1, infinity)
63 * @param height The height of the source frame in pixel, with range [1, infinity)
64 * @param channels The number of frame channels to be used, with range [1, infinity)
65 * @param testDuration Number of seconds for each test, with range (0, infinity)
66 * @param worker The worker object to distribute the CPU load
67 * @return True, if succeeded
68 */
69 static bool testApplyMapping(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
70
71 /**
72 * Tests the sum of squared differences calculation using a mask and skipping the center pixel.
73 * @param width The width of the source frame in pixel, with range [1, infinity)
74 * @param height The height of the source frame in pixel, with range [1, infinity)
75 * @param testDuration Number of seconds for each test, with range (0, infinity)
76 * @return True, if succeeded
77 */
78 static bool testSumSquaredDifference5x5MaskNoCenter(const unsigned int width, const unsigned int height, const double testDuration);
79
80 /**
81 * Tests the sum of squared differences calculation using a mask and skipping the center pixel.
82 * @param width The width of the source frame in pixel, with range [1, infinity)
83 * @param height The height of the source frame in pixel, with range [1, infinity)
84 * @param testDuration Number of seconds for each test, with range (0, infinity)
85 * @return True, if succeeded
86 * @tparam tChannels The number of frame channels to be used, with range [1, infinity)
87 */
88 template <unsigned int tChannels>
89 static bool testSumSquaredDifference5x5MaskNoCenter(const unsigned int width, const unsigned int height, const double testDuration);
90
91 /**
92 * Tests the 5x5 appearance cost function.
93 * @param width The width of the source frame in pixel, with range [1, infinity)
94 * @param height The height of the source frame in pixel, with range [1, infinity)
95 * @param testDuration Number of seconds for each test, with range (0, infinity)
96 * @return True, if succeeded
97 */
98 static bool testAppearanceCost5x5(const unsigned int width, const unsigned int height, const double testDuration);
99
100 /**
101 * Tests the 5x5 appearance cost function.
102 * @param width The width of the source frame in pixel, with range [1, infinity)
103 * @param height The height of the source frame in pixel, with range [1, infinity)
104 * @param testDuration Number of seconds for each test, with range (0, infinity)
105 * @return True, if succeeded
106 * @tparam tChannels The number of frame channels to be used, with range [1, infinity)
107 */
108 template <unsigned int tChannels>
109 static bool testAppearanceCost5x5(const unsigned int width, const unsigned int height, const double testDuration);
110
111 /**
112 * Tests the spatial cost with 4-neighborhood.
113 * @param width The width of the source frame in pixel, with range [1, infinity)
114 * @param height The height of the source frame in pixel, with range [1, infinity)
115 * @param testDuration Number of seconds for each test, with range (0, infinity)
116 * @return True, if succeeded
117 */
118 static bool testSpatialCost4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration);
119
120 /**
121 * Tests the spatial cost with 4-neighborhood.
122 * @param width The width of the source frame in pixel, with range [1, infinity)
123 * @param height The height of the source frame in pixel, with range [1, infinity)
124 * @param testDuration Number of seconds for each test, with range (0, infinity)
125 * @return True, if succeeded
126 * @tparam tChannels The number of frame channels to be used, with range [1, infinity)
127 */
128 template <unsigned int tChannels>
129 static bool testSpatialCost4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration);
130
131 /**
132 * Tests the spatial cost with 8-neighborhood.
133 * @param width The width of the source frame in pixel, with range [1, infinity)
134 * @param height The height of the source frame 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 */
138 static bool testSpatialCost8Neighborhood(const unsigned int width, const unsigned int height, const double testDuration);
139
140 /**
141 * Tests the spatial cost with 8-neighborhood.
142 * @param width The width of the source frame in pixel, with range [1, infinity)
143 * @param height The height of the source frame in pixel, with range [1, infinity)
144 * @param testDuration Number of seconds for each test, with range (0, infinity)
145 * @return True, if succeeded
146 * @tparam tChannels The number of frame channels to be used, with range [1, infinity)
147 */
148 template <unsigned int tChannels>
149 static bool testSpatialCost8Neighborhood(const unsigned int width, const unsigned int height, const double testDuration);
150
151 private:
152
153 /**
154 * Validates the mapping results for a frame and corresponding mapping.
155 * @param frame The result frame, must be valid
156 * @param mask The mask frame, must be valid
157 * @param mapping The mapping which has been used
158 * @param boundingBox The bounding box defining the area of interest, must be valid
159 * @return True, if succeeded
160 */
161 static bool validateMapping(const Frame& frame, const Frame& mask, const CV::Synthesis::MappingI1& mapping, const CV::PixelBoundingBox& boundingBox);
162
163 /**
164 * Validates the 5x5 sum of squared differences skipping the center pixel.
165 * @param frame0 The first frame, must be valid
166 * @param frame1 The second frame, must be valid
167 * @param mask0 The mask for the first frame, must be valid
168 * @param topLeftPositions0 The top left positions in the first frame
169 * @param topLeftPositions1 The top left positions in the second frame
170 * @param results The SSD results to verify, one for each position
171 * @param borderFactor The border factor to be used
172 * @return True, if succeeded
173 */
174 static bool validateSumSquaredDifference5x5MaskNoCenter(const Frame& frame0, const Frame& frame1, const Frame& mask0, const CV::PixelPositions& topLeftPositions0, const CV::PixelPositions& topLeftPositions1, const Indices32& results, const unsigned int borderFactor);
175
176 /**
177 * Determines the appearance cost.
178 * @param frame The frame for which the cost will be determined, must be valid
179 * @param mask The mask associated with the frame, defining valid and invalid frame pixels, must be valid
180 * @param source The source location within the frame, with range [0, frame.width()-1]x[0, frame.height()-1]
181 * @param target The target location within the frame, with range [0, frame.width()-1]x[0, frame.height()-1]
182 * @param patchSize The size of the image patch, in pixels, with range [1, infinity), must be odd
183 * @param borderFactor The factor which will be applied to target pixels outside of the mask, with range [1, infinity)
184 * @param normalizationFactor The normalization factor to be applied, with range [1, infinity)
185 * @return The resulting cost
186 */
187 static uint64_t determineAppearanceCost(const Frame& frame, const Frame& mask, const CV::PixelPosition& source, const CV::PixelPosition& target, const unsigned int patchSize, const unsigned int borderFactor, const unsigned int normalizationFactor);
188
189 /**
190 * Determines the spatial cost in a 4-neighborhood.
191 * @param mapping The mapping to be used, must be valid
192 * @param mask The mask associated with the frame, defining valid and invalid frame pixels, must be valid
193 * @param source The source location within the frame, with range [0, frame.width()-1]x[0, frame.height()-1]
194 * @param target The target location within the frame, with range [0, frame.width()-1]x[0, frame.height()-1]
195 * @param maxCost The maximal cost, with range [0, infinity)
196 * @param normalizationFactor The normalization factor to be applied, with range [1, infinity)
197 * @return The resulting cost
198 */
199 static uint64_t determineSpatialCost4Neighborhood(const CV::Synthesis::MappingI1& mapping, const Frame& mask, const CV::PixelPosition& source, const CV::PixelPosition& target, const uint32_t maxCost, const unsigned int normalizationFactor);
200
201 /**
202 * Determines the spatial cost in a 8-neighborhood.
203 * @param mapping The mapping to be used, must be valid
204 * @param mask The mask associated with the frame, defining valid and invalid frame pixels, must be valid
205 * @param source The source location within the frame, with range [0, frame.width()-1]x[0, frame.height()-1]
206 * @param target The target location within the frame, with range [0, frame.width()-1]x[0, frame.height()-1]
207 * @param maxCost The maximal cost, with range [0, infinity)
208 * @param normalizationFactor The normalization factor to be applied, with range [1, infinity)
209 * @return The resulting cost
210 */
211 static uint64_t determineSpatialCost8Neighborhood(const CV::Synthesis::MappingI1& mapping, const Frame& mask, const CV::PixelPosition& source, const CV::PixelPosition& target, const uint32_t maxCost, const unsigned int normalizationFactor);
212};
213
214}
215
216}
217
218}
219
220}
221
222#endif // META_OCEAN_TEST_TESTCV_TESTSYNTHESIS_TEST_MAPPING_I_1_H
This class implements the pixel mapping between source and target frames.
Definition MappingI1.h:49
This class implements Ocean's image class.
Definition Frame.h:1879
This class implements a synthesis pixel mapping test.
Definition TestMappingI1.h:36
static bool testSpatialCost4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration)
Tests the spatial cost with 4-neighborhood.
static uint64_t determineAppearanceCost(const Frame &frame, const Frame &mask, const CV::PixelPosition &source, const CV::PixelPosition &target, const unsigned int patchSize, const unsigned int borderFactor, const unsigned int normalizationFactor)
Determines the appearance cost.
static bool testSpatialCost8Neighborhood(const unsigned int width, const unsigned int height, const double testDuration)
Tests the spatial cost with 8-neighborhood.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker, const TestSelector &selector)
Tests all mapping functions.
static uint64_t determineSpatialCost4Neighborhood(const CV::Synthesis::MappingI1 &mapping, const Frame &mask, const CV::PixelPosition &source, const CV::PixelPosition &target, const uint32_t maxCost, const unsigned int normalizationFactor)
Determines the spatial cost in a 4-neighborhood.
static bool testAppearanceCost5x5(const unsigned int width, const unsigned int height, const double testDuration)
Tests the 5x5 appearance cost function.
static bool testSpatialCost4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration)
Tests the spatial cost with 4-neighborhood.
static bool testApplyMapping(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the applyMapping function for a specific pixel format.
static bool testSumSquaredDifference5x5MaskNoCenter(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum of squared differences calculation using a mask and skipping the center pixel.
static bool testSumSquaredDifference5x5MaskNoCenter(const unsigned int width, const unsigned int height, const double testDuration)
Tests the sum of squared differences calculation using a mask and skipping the center pixel.
static bool validateSumSquaredDifference5x5MaskNoCenter(const Frame &frame0, const Frame &frame1, const Frame &mask0, const CV::PixelPositions &topLeftPositions0, const CV::PixelPositions &topLeftPositions1, const Indices32 &results, const unsigned int borderFactor)
Validates the 5x5 sum of squared differences skipping the center pixel.
static bool testAppearanceCost5x5(const unsigned int width, const unsigned int height, const double testDuration)
Tests the 5x5 appearance cost function.
static uint64_t determineSpatialCost8Neighborhood(const CV::Synthesis::MappingI1 &mapping, const Frame &mask, const CV::PixelPosition &source, const CV::PixelPosition &target, const uint32_t maxCost, const unsigned int normalizationFactor)
Determines the spatial cost in a 8-neighborhood.
static bool testSpatialCost8Neighborhood(const unsigned int width, const unsigned int height, const double testDuration)
Tests the spatial cost with 8-neighborhood.
static bool testApplyMapping(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the applyMapping function.
static bool validateMapping(const Frame &frame, const Frame &mask, const CV::Synthesis::MappingI1 &mapping, const CV::PixelBoundingBox &boundingBox)
Validates the mapping results for a frame and corresponding mapping.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< PixelPosition > PixelPositions
Definition of a vector holding pixel positions (with positive coordinate values).
Definition PixelPosition.h:46
The namespace covering the entire Ocean framework.
Definition Accessor.h:15