CVB++ 14.0
search_parameters.hpp
1#pragma once
2
3#include "dnc.hpp"
4
5#include "../value_range.hpp"
6
7namespace Cvb
8{
9
10CVB_BEGIN_INLINE_NS
11
12namespace Dnc
13{
14
16
21#pragma pack (push, 4)
23{
24 public:
25
27
30 SearchParameters() = default;
31
33
42 double HypothesesThreshold() const noexcept
43 {
44 return hypothesesThreshold_;
45 }
46
48
52 void SetHypothesesThreshold(double value)
53 {
54 if (value < 0.5)
55 throw std::invalid_argument("HypothesesThreshold must not be < 0.5");
56 hypothesesThreshold_ = value;
57 }
58
60
68 int DerivativePatchSize() const noexcept
69 {
70 return derivativePatchSize_;
71 }
72
74
78 void SetDerivativePatchSize(int value)
79 {
80 if (value < 3)
81 throw std::invalid_argument("DerivativePatchSize must not be < 3");
82 derivativePatchSize_ = value;
83 }
84
86
92 double IndifferentRadius() const noexcept
93 {
94 return indifferentRadius_;
95 }
96
98
102 void SetIndifferentRadius(double value)
103 {
104 if (value < 0.5)
105 throw std::invalid_argument("IndifferentRadius must not be < 0.5");
106 indifferentRadius_ = value;
107 }
108
110
116 int PartsToFind() const noexcept
117 {
118 return partsToFind_;
119 }
120
122
126 void SetPartsToFind(int value)
127 {
128 if (value < 0)
129 throw std::invalid_argument("PartsToFind must not be < 0");
130 partsToFind_ = value;
131 }
132
134
142 bool RawResultsOnly() const noexcept
143 {
144 return rawResultsOnly_;
145 }
146
148
152 void SetRawResultsOnly(bool value) noexcept
153 {
154 rawResultsOnly_ = value;
155 }
156
158
167 int ICPShrink() const noexcept
168 {
169 return icpShrink_;
170 }
171
173
177 void SetICPShrink(int value)
178 {
179 if (value < 1)
180 throw std::invalid_argument("ICPShrink must not be < 1");
181 icpShrink_ = value;
182 }
183
185
193 int ICPMaxIterations() const noexcept
194 {
195 return icpMaxIterations_;
196 }
197
199
203 void SetICPMaxIterations(int value)
204 {
205 if (value < 1)
206 throw std::invalid_argument("ICPMaxIterations must not be < 1");
207 icpMaxIterations_ = value;
208 }
209
211
219 double PrecisionThreshold() const noexcept
220 {
221 return precisionThreshold_;
222 }
223
225
229 void SetPrecisionThreshold(double value)
230 {
231 if (value < 0.0)
232 throw std::invalid_argument("PrecisionThreshold must not be < 0.0");
233 precisionThreshold_ = value;
234 }
235
237
245 double MinCoverage() const noexcept
246 {
247 return minCoverage_;
248 }
249
251
255 void SetMinCoverage(double value)
256 {
257 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
258 throw std::invalid_argument("MinCoverage must be in range 0..1");
259 minCoverage_ = value;
260 }
261
263
272 double MaxOcclusion() const noexcept
273 {
274 return maxOcclusion_;
275 }
276
278
282 void SetMaxOcclusion(double value)
283 {
284 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
285 throw std::invalid_argument("MaxOcclusion must be in range 0..1");
286 maxOcclusion_ = value;
287 }
288
290
299 double MaxInconsistency() const noexcept
300 {
301 return maxInconsistency_;
302 }
303
305
309 void SetMaxInconsistency(double value)
310 {
311 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
312 throw std::invalid_argument("MaxInconsistency must be in range 0..1");
313 maxInconsistency_ = value;
314 }
315
317
325 double MinScore() const noexcept
326 {
327 return minScore_;
328 }
329
331
335 void SetMinScore(double value)
336 {
337 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
338 throw std::invalid_argument("MinScore must be in range 0..1");
339 minScore_ = value;
340 }
341
342 private:
343
344 template<class T>
345 bool IsInRange(T value, ValueRange<T> range)
346 {
347 return value <= range.Max() && value >= range.Min();
348 }
349
350 double hypothesesThreshold_ = 0.7;
351 int derivativePatchSize_ = 5;
352 double indifferentRadius_ = 0.6;
353 int partsToFind_ = 0;
354 bool rawResultsOnly_ = false;
355 int icpShrink_ = 4;
356 int icpMaxIterations_ = 10;
357 double precisionThreshold_ = 2.0;
358 double minCoverage_ = 0.7;
359 double maxOcclusion_ = 0.2;
360 double maxInconsistency_ = 0.2;
361 double minScore_ = 0.7;
362
363
364};
365#pragma pack (pop)
366
367}
368
369CVB_END_INLINE_NS
370
371}
Definition of search parameters.
Definition: search_parameters.hpp:23
int ICPMaxIterations() const noexcept
Get the maximum number of iterations of the ICP algorithm.
Definition: search_parameters.hpp:193
double HypothesesThreshold() const noexcept
Get minimum feature score for hypotheses generation.
Definition: search_parameters.hpp:42
void SetMaxInconsistency(double value)
Set maximum inconsistency.
Definition: search_parameters.hpp:309
int DerivativePatchSize() const noexcept
Get smoothing area in pixels for gradient and normal calculation.
Definition: search_parameters.hpp:68
void SetPrecisionThreshold(double value)
Set precision threshold.
Definition: search_parameters.hpp:229
double MinScore() const noexcept
Get minimum score.
Definition: search_parameters.hpp:325
bool RawResultsOnly() const noexcept
Get the raw results flag.
Definition: search_parameters.hpp:142
int PartsToFind() const noexcept
Get the maximum number of objects to find.
Definition: search_parameters.hpp:116
void SetMaxOcclusion(double value)
Set maximum occlusion.
Definition: search_parameters.hpp:282
double MaxInconsistency() const noexcept
Get maximum inconsistency.
Definition: search_parameters.hpp:299
void SetHypothesesThreshold(double value)
Set minimum feature score for hypotheses generation.
Definition: search_parameters.hpp:52
void SetMinScore(double value)
Set minimum score.
Definition: search_parameters.hpp:335
void SetDerivativePatchSize(int value)
Set smoothing area in pixels for gradient and normal calculation.
Definition: search_parameters.hpp:78
void SetICPMaxIterations(int value)
Set the maximum number of iterations of the ICP algorithm.
Definition: search_parameters.hpp:203
void SetICPShrink(int value)
Set the subsample factor for ICP.
Definition: search_parameters.hpp:177
double MinCoverage() const noexcept
Get minimum coverage.
Definition: search_parameters.hpp:245
void SetMinCoverage(double value)
Set minimum coverage.
Definition: search_parameters.hpp:255
void SetPartsToFind(int value)
Set the maximum number of objects to find.
Definition: search_parameters.hpp:126
double IndifferentRadius() const noexcept
Get fraction of template size which accounts for a single object.
Definition: search_parameters.hpp:92
void SetRawResultsOnly(bool value) noexcept
Set the raw results flag.
Definition: search_parameters.hpp:152
void SetIndifferentRadius(double value)
Set fraction of template size which accounts for a single object.
Definition: search_parameters.hpp:102
double PrecisionThreshold() const noexcept
Get precision threshold.
Definition: search_parameters.hpp:219
double MaxOcclusion() const noexcept
Get maximum occlusion.
Definition: search_parameters.hpp:272
int ICPShrink() const noexcept
Get the subsample factor for ICP.
Definition: search_parameters.hpp:167
SearchParameters()=default
Default search parameters.
T Min() const noexcept
Gets the minimum value.
Definition: value_range.hpp:50
T Max() const noexcept
Gets the maximum value.
Definition: value_range.hpp:72
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24