CVB++ 15.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
40 double HypothesesThreshold() const noexcept
41 {
42 return hypothesesThreshold_;
43 }
44
46
63 void SetHypothesesThreshold(double value)
64 {
65 if (value < 0.5)
66 throw std::invalid_argument("HypothesesThreshold must not be < 0.5");
67 hypothesesThreshold_ = value;
68 }
69
71
78 int DerivativePatchSize() const noexcept
79 {
80 return derivativePatchSize_;
81 }
82
84
93 void SetDerivativePatchSize(int value)
94 {
95 if (value < 3)
96 throw std::invalid_argument("DerivativePatchSize must not be < 3");
97 derivativePatchSize_ = value;
98 }
99
101
108 double IndifferentRadius() const noexcept
109 {
110 return indifferentRadius_;
111 }
112
114
123 void SetIndifferentRadius(double value)
124 {
125 if (value < 0.5)
126 throw std::invalid_argument("IndifferentRadius must not be < 0.5");
127 indifferentRadius_ = value;
128 }
129
131
138 int PartsToFind() const noexcept
139 {
140 return partsToFind_;
141 }
142
144
151 void SetPartsToFind(int value)
152 {
153 if (value < 0)
154 throw std::invalid_argument("PartsToFind must not be < 0");
155 partsToFind_ = value;
156 }
157
159
166 bool RawResultsOnly() const noexcept
167 {
168 return rawResultsOnly_;
169 }
170
172
187 void SetRawResultsOnly(bool value) noexcept
188 {
189 rawResultsOnly_ = value;
190 }
191
193
200 int ICPShrink() const noexcept
201 {
202 return icpShrink_;
203 }
204
206
216 void SetICPShrink(int value)
217 {
218 if (value < 1)
219 throw std::invalid_argument("ICPShrink must not be < 1");
220 icpShrink_ = value;
221 }
222
224
231 int ICPMaxIterations() const noexcept
232 {
233 return icpMaxIterations_;
234 }
235
237
245 void SetICPMaxIterations(int value)
246 {
247 if (value < 1)
248 throw std::invalid_argument("ICPMaxIterations must not be < 1");
249 icpMaxIterations_ = value;
250 }
251
253
260 double PrecisionThreshold() const noexcept
261 {
262 return precisionThreshold_;
263 }
264
266
275 void SetPrecisionThreshold(double value)
276 {
277 if (value < 0.0)
278 throw std::invalid_argument("PrecisionThreshold must not be < 0.0");
279 precisionThreshold_ = value;
280 }
281
283
290 double MinCoverage() const noexcept
291 {
292 return minCoverage_;
293 }
294
296
304 void SetMinCoverage(double value)
305 {
306 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
307 throw std::invalid_argument("MinCoverage must be in range 0..1");
308 minCoverage_ = value;
309 }
310
312
319 double MaxOcclusion() const noexcept
320 {
321 return maxOcclusion_;
322 }
323
325
334 void SetMaxOcclusion(double value)
335 {
336 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
337 throw std::invalid_argument("MaxOcclusion must be in range 0..1");
338 maxOcclusion_ = value;
339 }
340
342
349 double MaxInconsistency() const noexcept
350 {
351 return maxInconsistency_;
352 }
353
355
364 void SetMaxInconsistency(double value)
365 {
366 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
367 throw std::invalid_argument("MaxInconsistency must be in range 0..1");
368 maxInconsistency_ = value;
369 }
370
372
379 double MinScore() const noexcept
380 {
381 return minScore_;
382 }
383
385
393 void SetMinScore(double value)
394 {
395 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
396 throw std::invalid_argument("MinScore must be in range 0..1");
397 minScore_ = value;
398 }
399
400 private:
401
402 template<class T>
403 bool IsInRange(T value, ValueRange<T> range)
404 {
405 return value <= range.Max() && value >= range.Min();
406 }
407
408 double hypothesesThreshold_ = 0.7;
409 int derivativePatchSize_ = 5;
410 double indifferentRadius_ = 0.6;
411 int partsToFind_ = 0;
412 bool rawResultsOnly_ = false;
413 int icpShrink_ = 4;
414 int icpMaxIterations_ = 10;
415 double precisionThreshold_ = 2.0;
416 double minCoverage_ = 0.7;
417 double maxOcclusion_ = 0.2;
418 double maxInconsistency_ = 0.2;
419 double minScore_ = 0.7;
420
421
422};
423#pragma pack (pop)
424
425}
426
427CVB_END_INLINE_NS
428
429}
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:231
double HypothesesThreshold() const noexcept
Get minimum feature score for hypotheses generation.
Definition: search_parameters.hpp:40
void SetMaxInconsistency(double value)
Set maximum inconsistency.
Definition: search_parameters.hpp:364
int DerivativePatchSize() const noexcept
Get smoothing area in pixels for gradient and normal calculation.
Definition: search_parameters.hpp:78
void SetPrecisionThreshold(double value)
Set precision threshold.
Definition: search_parameters.hpp:275
double MinScore() const noexcept
Get minimum score.
Definition: search_parameters.hpp:379
bool RawResultsOnly() const noexcept
Get the raw results flag.
Definition: search_parameters.hpp:166
int PartsToFind() const noexcept
Get the maximum number of objects to find.
Definition: search_parameters.hpp:138
void SetMaxOcclusion(double value)
Set maximum occlusion.
Definition: search_parameters.hpp:334
double MaxInconsistency() const noexcept
Get maximum inconsistency.
Definition: search_parameters.hpp:349
void SetHypothesesThreshold(double value)
Set minimum feature score for hypotheses generation.
Definition: search_parameters.hpp:63
void SetMinScore(double value)
Set minimum score.
Definition: search_parameters.hpp:393
void SetDerivativePatchSize(int value)
Set smoothing area in pixels for gradient and normal calculation.
Definition: search_parameters.hpp:93
void SetICPMaxIterations(int value)
Set the maximum number of iterations of the ICP algorithm.
Definition: search_parameters.hpp:245
void SetICPShrink(int value)
Set the subsample factor for ICP.
Definition: search_parameters.hpp:216
double MinCoverage() const noexcept
Get minimum coverage.
Definition: search_parameters.hpp:290
void SetMinCoverage(double value)
Set minimum coverage.
Definition: search_parameters.hpp:304
void SetPartsToFind(int value)
Set the maximum number of objects to find.
Definition: search_parameters.hpp:151
double IndifferentRadius() const noexcept
Get fraction of template size which accounts for a single object.
Definition: search_parameters.hpp:108
void SetRawResultsOnly(bool value) noexcept
Set the raw results flag.
Definition: search_parameters.hpp:187
void SetIndifferentRadius(double value)
Set fraction of template size which accounts for a single object.
Definition: search_parameters.hpp:123
double PrecisionThreshold() const noexcept
Get precision threshold.
Definition: search_parameters.hpp:260
double MaxOcclusion() const noexcept
Get maximum occlusion.
Definition: search_parameters.hpp:319
int ICPShrink() const noexcept
Get the subsample factor for ICP.
Definition: search_parameters.hpp:200
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