Ocean
Loading...
Searching...
No Matches
TestOptimizerF1.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_F_1_H
9#define META_OCEAN_TEST_TESTCV_TESTSYNTHESIS_TEST_OPTIMIZER_F_1_H
10
12
13#include "ocean/base/Frame.h"
15
17
19
20namespace Ocean
21{
22
23namespace Test
24{
25
26namespace TestCV
27{
28
29namespace TestSynthesis
30{
31
32/**
33 * This class implements a test for optimizers with one frame.
34 * @ingroup testcvsynthesis
35 */
36class OCEAN_TEST_CV_SYNTHESIS_EXPORT TestOptimizerF1
37{
38 public:
39
40 /**
41 * Invokes all test functions.
42 * @param width The width of the source frame in pixel, with range [1, infinity)
43 * @param height The height of the source frame in pixel, with range [1, infinity)
44 * @param testDuration Number of seconds for each test, with range (0, infinity)
45 * @param worker The worker object to distribute the CPU load
46 * @param selector The test selector
47 * @return True, if succeeded
48 */
49 static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker, const TestSelector& selector);
50
51 /**
52 * Tests the 4-neighborhood high performance optimizer.
53 * @param width The width of the source frame in pixel, with range [1, infinity)
54 * @param height The height of the source frame in pixel, with range [1, infinity)
55 * @param testDuration Number of seconds for each test, with range (0, infinity)
56 * @param worker The worker object to distribute the CPU load
57 * @return True, if succeeded
58 */
59 static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
60
61 /**
62 * Tests the 4-neighborhood high performance optimizer.
63 * @param width The width of the source frame in pixel, with range [1, infinity)
64 * @param height The height of the source frame in pixel, with range [1, infinity)
65 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
66 * @param testDuration Number of seconds for each test, with range (0, infinity)
67 * @param worker The worker object to distribute the CPU load
68 * @return True, if succeeded
69 */
70 static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
71
72 /**
73 * Tests the 4-neighborhood optimizer with a reference frame.
74 * @param width The width of the source frame in pixel, with range [1, infinity)
75 * @param height The height of the source frame in pixel, with range [1, infinity)
76 * @param testDuration Number of seconds for each test, with range (0, infinity)
77 * @param worker The worker object to distribute the CPU load
78 * @return True, if succeeded
79 */
80 static bool testReferenceFrame4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
81
82 /**
83 * Tests the 4-neighborhood optimizer with a reference frame.
84 * @param width The width of the source frame in pixel, with range [1, infinity)
85 * @param height The height of the source frame in pixel, with range [1, infinity)
86 * @param channels The number of frame channels which will be used during the test, with range [1, infinity)
87 * @param testDuration Number of seconds for each test, with range (0, infinity)
88 * @param worker The worker object to distribute the CPU load
89 * @return True, if succeeded
90 */
91 static bool testReferenceFrame4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker& worker);
92
93 protected:
94
95 /**
96 * Invokes a high performance optimization with a 4-neighborhood.
97 * @param frame The frame to be used, must be valid
98 * @param mask The mask to be used, must be valid
99 * @param mapping The mapping to be used, must be valid
100 * @param randomGenerator The random generator to be used
101 * @param applyInitialMapping True, to apply the initial mapping; False, to skip the initial mapping
102 * @param radii The number of search radii, with range [1, infinity)
103 * @param iterations The number of optimization iterations, with range [1, infinity)
104 * @param weightFactor The weight factor to be applied, with range [1, infinity)
105 * @param maxSpatialCost The maximal spatial cost to be used, with range [0, infinity)
106 * @return True, if succeeded
107 * @tparam tBorderFactor The border factor to be used, with range [1, infinity)
108 */
109 template <unsigned int tBorderFactor>
110 static bool optimize4Neighborhood(Frame& frame, const Frame& mask, CV::Synthesis::MappingF1& mapping, RandomGenerator& randomGenerator, const bool applyInitialMapping, const unsigned int radii, const unsigned int iterations, const unsigned int weightFactor, const unsigned int maxSpatialCost);
111
112 /**
113 * Invokes an optimization with a 4-neighborhood and a reference frame.
114 * @param frame The frame to be used, must be valid
115 * @param mask The mask to be used, must be valid
116 * @param reference The reference frame to be used, must be valid
117 * @param mapping The mapping to be used, must be valid
118 * @param randomGenerator The random generator to be used
119 * @param applyInitialMapping True, to apply the initial mapping; False, to skip the initial mapping
120 * @param radii The number of search radii, with range [1, infinity)
121 * @param iterations The number of optimization iterations, with range [1, infinity)
122 * @param weightFactor The weight factor to be applied, with range [1, infinity)
123 * @param maxSpatialCost The maximal spatial cost to be used, with range [0, infinity)
124 * @return True, if succeeded
125 * @tparam tBorderFactor The border factor to be used, with range [1, infinity)
126 */
127 template <unsigned int tBorderFactor>
128 static bool optimizeReference4Neighborhood(Frame& frame, const Frame& mask, const Frame& reference, CV::Synthesis::MappingF1& mapping, RandomGenerator& randomGenerator, const bool applyInitialMapping, const unsigned int radii, const unsigned int iterations, const unsigned int weightFactor, const unsigned int maxSpatialCost);
129
130 /**
131 * Determines the cost for a given location.
132 * @param frame The frame to be used, must be valid
133 * @param mask The mask to be used, must be valid
134 * @param mapping The mapping to be used, must be valid
135 * @param targetPosition The target position for which the cost will be determined
136 * @param sourcePosition The source position for which the cost will be determined
137 * @param weightFactor The weight factor to be applied
138 * @param maxSpatialCost The maximal spatial cost to be used
139 * @return The resulting cost composed of spatial and appearance cost
140 * @tparam tBorderFactor The border factor to be used
141 */
142 template <unsigned int tBorderFactor>
143 static Scalar determineCost(const Frame& frame, const Frame& mask, const CV::Synthesis::MappingF1& mapping, const CV::PixelPosition& targetPosition, const Vector2& sourcePosition, const unsigned int weightFactor, const unsigned int maxSpatialCost);
144
145 /**
146 * Determines the cost for a given location.
147 * @param frame The frame to be used, must be valid
148 * @param mask The mask to be used, must be valid
149 * @param reference The reference frame to be used, must be valid
150 * @param mapping The mapping to be used, must be valid
151 * @param targetPosition The target position for which the cost will be determined
152 * @param sourcePosition The source position for which the cost will be determined
153 * @param weightFactor The weight factor to be applied
154 * @param maxSpatialCost The maximal spatial cost to be used
155 * @return The resulting cost composed of spatial and appearance cost
156 * @tparam tBorderFactor The border factor to be used
157 */
158 template <unsigned int tBorderFactor>
159 static Scalar determineCost(const Frame& frame, const Frame& mask, const Frame& reference, const CV::Synthesis::MappingF1& mapping, const CV::PixelPosition& targetPosition, const Vector2& sourcePosition, const unsigned int weightFactor, const unsigned int maxSpatialCost);
160};
161
162}
163
164}
165
166}
167
168}
169
170#endif // META_OCEAN_TEST_TESTCV_TESTSYNTHESIS_TEST_OPTIMIZER_F_1_H
Cost function:
Definition MappingF1.h:52
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 TestOptimizerF1.h:37
static bool optimize4Neighborhood(Frame &frame, const Frame &mask, CV::Synthesis::MappingF1 &mapping, RandomGenerator &randomGenerator, const bool applyInitialMapping, const unsigned int radii, const unsigned int iterations, const unsigned int weightFactor, const unsigned int maxSpatialCost)
Invokes a high performance optimization with a 4-neighborhood.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker, const TestSelector &selector)
Invokes all test functions.
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 Scalar determineCost(const Frame &frame, const Frame &mask, const Frame &reference, const CV::Synthesis::MappingF1 &mapping, const CV::PixelPosition &targetPosition, const Vector2 &sourcePosition, const unsigned int weightFactor, const unsigned int maxSpatialCost)
Determines the cost for a given location.
static bool testReferenceFrame4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood optimizer with a reference frame.
static bool optimizeReference4Neighborhood(Frame &frame, const Frame &mask, const Frame &reference, CV::Synthesis::MappingF1 &mapping, RandomGenerator &randomGenerator, const bool applyInitialMapping, const unsigned int radii, const unsigned int iterations, const unsigned int weightFactor, const unsigned int maxSpatialCost)
Invokes an optimization with a 4-neighborhood and a reference frame.
static bool testReferenceFrame4Neighborhood(const unsigned int width, const unsigned int height, const unsigned int channels, const double testDuration, Worker &worker)
Tests the 4-neighborhood optimizer with a reference frame.
static Scalar determineCost(const Frame &frame, const Frame &mask, const CV::Synthesis::MappingF1 &mapping, const CV::PixelPosition &targetPosition, const Vector2 &sourcePosition, const unsigned int weightFactor, const unsigned int maxSpatialCost)
Determines the cost for a given location.
static bool testHighPerformance4Neighborhood(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the 4-neighborhood high performance optimizer.
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
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15