Ocean
Loading...
Searching...
No Matches
TestOptimizerI1.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_OPTIMIZER_I_1_H
9#define META_OCEAN_TEST_TESTCV_TESTSYNTHESIS_TEST_OPTIMIZER_I_1_H
10
12
13#include "ocean/base/Frame.h"
15
18
20
21namespace Ocean
22{
23
24namespace Test
25{
26
27namespace TestCV
28{
29
30namespace TestSynthesis
31{
32
33/**
34 * This class implements a test for optimizers with one frame.
35 * @ingroup testcvsynthesis
36 */
37class OCEAN_TEST_CV_SYNTHESIS_EXPORT TestOptimizerI1
38{
39 public:
40
41 /**
42 * Invokes all test functions.
43 * @param width The width of the source frame in pixel, with range [1, infinity)
44 * @param height The height of the source frame in pixel, with range [1, infinity)
45 * @param testDuration Number of seconds for each test, with range (0, infinity)
46 * @param worker The worker object to distribute the CPU load
47 * @param selector The test selector
48 * @return True, if succeeded
49 */
50 static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker, const TestSelector& selector);
51
52 /**
53 * Tests the 4-neighborhood optimizer with constrained area.
54 * @param width The width of the source frame in pixel, with range [1, infinity)
55 * @param height The height of the source frame in pixel, with range [1, infinity)
56 * @param testDuration Number of seconds for each test, with range (0, infinity)
57 * @param worker The worker object to distribute the CPU load
58 * @return True, if succeeded
59 */
60 static bool testAreaConstrained4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
61
62 /**
63 * Tests the 4-neighborhood optimizer with constrained area.
64 * @param width The width of the source frame in pixel, with range [1, infinity)
65 * @param height The height of the source frame in pixel, with range [1, infinity)
66 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
67 * @param testDuration Number of seconds for each test, with range (0, infinity)
68 * @param worker The worker object to distribute the CPU load
69 * @return True, if succeeded
70 */
71 static bool testAreaConstrained4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
72
73 /**
74 * Tests the 4-neighborhood high performance optimizer.
75 * @param width The width of the source frame in pixel, with range [1, infinity)
76 * @param height The height of the source frame in pixel, with range [1, infinity)
77 * @param testDuration Number of seconds for each test, with range (0, infinity)
78 * @param worker The worker object to distribute the CPU load
79 * @return True, if succeeded
80 */
81 static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
82
83 /**
84 * Tests the 4-neighborhood high performance optimizer.
85 * @param width The width of the source frame in pixel, with range [1, infinity)
86 * @param height The height of the source frame in pixel, with range [1, infinity)
87 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
88 * @param testDuration Number of seconds for each test, with range (0, infinity)
89 * @param worker The worker object to distribute the CPU load
90 * @return True, if succeeded
91 */
92 static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
93
94 /**
95 * Tests the 4-neighborhood high performance optimizer skipping if spatial cost is already optimal.
96 * @param width The width of the source frame in pixel, with range [1, infinity)
97 * @param height The height of the source frame in pixel, with range [1, infinity)
98 * @param testDuration Number of seconds for each test, with range (0, infinity)
99 * @param worker The worker object to distribute the CPU load
100 * @return True, if succeeded
101 */
102 static bool testHighPerformance4NeighborhoodSkipping(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
103
104 /**
105 * Tests the 4-neighborhood high performance optimizer skipping if spatial cost is already optimal.
106 * @param width The width of the source frame in pixel, with range [1, infinity)
107 * @param height The height of the source frame in pixel, with range [1, infinity)
108 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
109 * @param testDuration Number of seconds for each test, with range (0, infinity)
110 * @param worker The worker object to distribute the CPU load
111 * @return True, if succeeded
112 */
113 static bool testHighPerformance4NeighborhoodSkipping(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
114
115 /**
116 * Tests the 4-neighborhood high performance optimizer with skipping mask.
117 * @param width The width of the source frame in pixel, with range [1, infinity)
118 * @param height The height of the source frame in pixel, with range [1, infinity)
119 * @param testDuration Number of seconds for each test, with range (0, infinity)
120 * @param worker The worker object to distribute the CPU load
121 * @return True, if succeeded
122 */
123 static bool testHighPerformance4NeighborhoodSkippingByCostMask(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
124
125 /**
126 * Tests the 4-neighborhood high performance optimizer with skipping mask.
127 * @param width The width of the source frame in pixel, with range [1, infinity)
128 * @param height The height of the source frame in pixel, with range [1, infinity)
129 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
130 * @param testDuration Number of seconds for each test, with range (0, infinity)
131 * @param worker The worker object to distribute the CPU load
132 * @return True, if succeeded
133 */
134 static bool testHighPerformance4NeighborhoodSkippingByCostMask(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
135
136 /**
137 * Tests the 4-neighborhood optimizer with structural constrains.
138 * @param width The width of the source frame in pixel, with range [1, infinity)
139 * @param height The height of the source frame in pixel, with range [1, infinity)
140 * @param testDuration Number of seconds for each test, with range (0, infinity)
141 * @param worker The worker object to distribute the CPU load
142 * @return True, if succeeded
143 */
144 static bool testStructuralConstrained4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
145
146 /**
147 * Tests the 4-neighborhood optimizer with structural constrains.
148 * @param width The width of the source frame in pixel, with range [1, infinity)
149 * @param height The height of the source frame in pixel, with range [1, infinity)
150 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
151 * @param testDuration Number of seconds for each test, with range (0, infinity)
152 * @param worker The worker object to distribute the CPU load
153 * @return True, if succeeded
154 */
155 static bool testStructuralConstrained4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
156
157 protected:
158
159 /**
160 * Invokes a high performance optimization with a 4-neighborhood.
161 * @param frame The frame to be used, must be valid
162 * @param mask The mask to be used, must be valid
163 * @param filterMask Optional filter mask to constrained the optimization; invalid to avoid and additional filter
164 * @param skippingMask Optional mask defining pixels to be skipped; invalid to avoid this additional option
165 * @param constraints Optional constraints to be applied during optimization, nullptr to avoid using constraints
166 * @param mapping The mapping to be used, must be valid
167 * @param randomGenerator The random generator to be used
168 * @param applyInitialMapping True, to apply the initial mapping; False, to skip the initial mapping
169 * @param radii The number of search radii, with range [1, infinity)
170 * @param iterations The number of optimization iterations, with range [1, infinity)
171 * @param weightFactor The weight factor to be applied, with range [1, infinity)
172 * @param maxSpatialCost The maximal spatial cost to be used, with range [0, infinity)
173 * @param spatialSkipping True, to apply spatial skipping
174 * @return True, if succeeded
175 * @tparam tBorderFactor The border factor to be used, with range [1, infinity)
176 */
177 template <unsigned int tBorderFactor>
178 static bool optimize4Neighborhood(Frame& frame, const Frame& mask, const Frame& filterMask, const Frame& skippingMask, const CV::Synthesis::Constraints* constraints, CV::Synthesis::MappingI1& mapping, RandomGenerator& randomGenerator, const bool applyInitialMapping, const unsigned int radii, const unsigned int iterations, const unsigned int weightFactor, const unsigned int maxSpatialCost, const bool spatialSkipping);
179
180 /**
181 * Determines the cost for a given location.
182 * @param frame The frame to be used, must be valid
183 * @param mask The mask to be used, must be valid
184 * @param mapping The mapping to be used, must be valid
185 * @param targetPosition The target position for which the cost will be determined
186 * @param sourcePosition The source position for which the cost will be determined
187 * @param weightFactor The weight factor to be applied
188 * @param maxSpatialCost The maximal spatial cost to be used
189 * @return The resulting cost composed of spatial and appearance cost
190 * @tparam tBorderFactor The border factor to be used
191 */
192 template <unsigned int tBorderFactor>
193 static uint64_t determineCost(const Frame& frame, const Frame& mask, const CV::Synthesis::MappingI1& mapping, const CV::PixelPosition& targetPosition, const CV::PixelPosition& sourcePosition, const unsigned int weightFactor, const unsigned int maxSpatialCost);
194};
195
196}
197
198}
199
200}
201
202}
203
204#endif // META_OCEAN_TEST_TESTCV_TESTSYNTHESIS_TEST_OPTIMIZER_I_1_H
This class implements a container holding constraints.
Definition Constraint.h:304
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 generator for random numbers.
Definition RandomGenerator.h:42
This class implements a test for optimizers with one frame.
Definition TestOptimizerI1.h:38
static bool testStructuralConstrained4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood optimizer with structural constrains.
static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer.
static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer.
static bool testHighPerformance4NeighborhoodSkipping(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer skipping if spatial cost is already optimal.
static bool testHighPerformance4NeighborhoodSkippingByCostMask(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer with skipping mask.
static bool testStructuralConstrained4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 4-neighborhood optimizer with structural constrains.
static bool optimize4Neighborhood(Frame &frame, const Frame &mask, const Frame &filterMask, const Frame &skippingMask, const CV::Synthesis::Constraints *constraints, CV::Synthesis::MappingI1 &mapping, RandomGenerator &randomGenerator, const bool applyInitialMapping, const unsigned int radii, const unsigned int iterations, const unsigned int weightFactor, const unsigned int maxSpatialCost, const bool spatialSkipping)
Invokes a high performance optimization with a 4-neighborhood.
static bool testHighPerformance4NeighborhoodSkipping(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer skipping if spatial cost is already optimal.
static bool testAreaConstrained4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 4-neighborhood optimizer with constrained area.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker, const TestSelector &selector)
Invokes all test functions.
static uint64_t determineCost(const Frame &frame, const Frame &mask, const CV::Synthesis::MappingI1 &mapping, const CV::PixelPosition &targetPosition, const CV::PixelPosition &sourcePosition, const unsigned int weightFactor, const unsigned int maxSpatialCost)
Determines the cost for a given location.
static bool testAreaConstrained4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood optimizer with constrained area.
static bool testHighPerformance4NeighborhoodSkippingByCostMask(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer with skipping mask.
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
The namespace covering the entire Ocean framework.
Definition Accessor.h:15