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
10 CVB_BEGIN_INLINE_NS
11
12 namespace Dnc
13 {
14
16
21#pragma pack(push, 4)
22 class SearchParameters final
23 {
24 public:
26
29 SearchParameters() = default;
30
32
39 double HypothesesThreshold() const noexcept
40 {
41 return hypothesesThreshold_;
42 }
43
45
62 void SetHypothesesThreshold(double value)
63 {
64 if (value < 0.5)
65 throw std::invalid_argument("HypothesesThreshold must not be < 0.5");
66 hypothesesThreshold_ = value;
67 }
68
70
77 int DerivativePatchSize() const noexcept
78 {
79 return derivativePatchSize_;
80 }
81
83
92 void SetDerivativePatchSize(int value)
93 {
94 if (value < 3)
95 throw std::invalid_argument("DerivativePatchSize must not be < 3");
96 derivativePatchSize_ = value;
97 }
98
100
107 double IndifferentRadius() const noexcept
108 {
109 return indifferentRadius_;
110 }
111
113
122 void SetIndifferentRadius(double value)
123 {
124 if (value < 0.5)
125 throw std::invalid_argument("IndifferentRadius must not be < 0.5");
126 indifferentRadius_ = value;
127 }
128
130
137 int PartsToFind() const noexcept
138 {
139 return partsToFind_;
140 }
141
143
150 void SetPartsToFind(int value)
151 {
152 if (value < 0)
153 throw std::invalid_argument("PartsToFind must not be < 0");
154 partsToFind_ = value;
155 }
156
158
165 bool RawResultsOnly() const noexcept
166 {
167 return rawResultsOnly_;
168 }
169
171
186 void SetRawResultsOnly(bool value) noexcept
187 {
188 rawResultsOnly_ = value;
189 }
190
192
199 int ICPShrink() const noexcept
200 {
201 return icpShrink_;
202 }
203
205
215 void SetICPShrink(int value)
216 {
217 if (value < 1)
218 throw std::invalid_argument("ICPShrink must not be < 1");
219 icpShrink_ = value;
220 }
221
223
230 int ICPMaxIterations() const noexcept
231 {
232 return icpMaxIterations_;
233 }
234
236
244 void SetICPMaxIterations(int value)
245 {
246 if (value < 1)
247 throw std::invalid_argument("ICPMaxIterations must not be < 1");
248 icpMaxIterations_ = value;
249 }
250
252
259 double PrecisionThreshold() const noexcept
260 {
261 return precisionThreshold_;
262 }
263
265
274 void SetPrecisionThreshold(double value)
275 {
276 if (value < 0.0)
277 throw std::invalid_argument("PrecisionThreshold must not be < 0.0");
278 precisionThreshold_ = value;
279 }
280
282
289 double MinCoverage() const noexcept
290 {
291 return minCoverage_;
292 }
293
295
303 void SetMinCoverage(double value)
304 {
305 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
306 throw std::invalid_argument("MinCoverage must be in range 0..1");
307 minCoverage_ = value;
308 }
309
311
318 double MaxOcclusion() const noexcept
319 {
320 return maxOcclusion_;
321 }
322
324
333 void SetMaxOcclusion(double value)
334 {
335 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
336 throw std::invalid_argument("MaxOcclusion must be in range 0..1");
337 maxOcclusion_ = value;
338 }
339
341
348 double MaxInconsistency() const noexcept
349 {
350 return maxInconsistency_;
351 }
352
354
363 void SetMaxInconsistency(double value)
364 {
365 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
366 throw std::invalid_argument("MaxInconsistency must be in range 0..1");
367 maxInconsistency_ = value;
368 }
369
371
378 double MinScore() const noexcept
379 {
380 return minScore_;
381 }
382
384
392 void SetMinScore(double value)
393 {
394 if (!IsInRange(value, ValueRange<double>(0.0, 1.0)))
395 throw std::invalid_argument("MinScore must be in range 0..1");
396 minScore_ = value;
397 }
398
399 private:
400 template <class T>
401 bool IsInRange(T value, ValueRange<T> range)
402 {
403 return value <= range.Max() && value >= range.Min();
404 }
405
406 double hypothesesThreshold_ = 0.7;
407 int derivativePatchSize_ = 5;
408 double indifferentRadius_ = 0.6;
409 int partsToFind_ = 0;
410 bool rawResultsOnly_ = false;
411 int icpShrink_ = 4;
412 int icpMaxIterations_ = 10;
413 double precisionThreshold_ = 2.0;
414 double minCoverage_ = 0.7;
415 double maxOcclusion_ = 0.2;
416 double maxInconsistency_ = 0.2;
417 double minScore_ = 0.7;
418 };
419#pragma pack(pop)
420
421 } // namespace Dnc
422
423 CVB_END_INLINE_NS
424
425} // namespace Cvb
int ICPMaxIterations() const noexcept
Get the maximum number of iterations of the ICP algorithm.
Definition search_parameters.hpp:230
double HypothesesThreshold() const noexcept
Get minimum feature score for hypotheses generation.
Definition search_parameters.hpp:39
void SetMaxInconsistency(double value)
Set maximum inconsistency.
Definition search_parameters.hpp:363
int DerivativePatchSize() const noexcept
Get smoothing area in pixels for gradient and normal calculation.
Definition search_parameters.hpp:77
void SetPrecisionThreshold(double value)
Set precision threshold.
Definition search_parameters.hpp:274
double MinScore() const noexcept
Get minimum score.
Definition search_parameters.hpp:378
bool RawResultsOnly() const noexcept
Get the raw results flag.
Definition search_parameters.hpp:165
int PartsToFind() const noexcept
Get the maximum number of objects to find.
Definition search_parameters.hpp:137
void SetMaxOcclusion(double value)
Set maximum occlusion.
Definition search_parameters.hpp:333
double MaxInconsistency() const noexcept
Get maximum inconsistency.
Definition search_parameters.hpp:348
void SetHypothesesThreshold(double value)
Set minimum feature score for hypotheses generation.
Definition search_parameters.hpp:62
void SetMinScore(double value)
Set minimum score.
Definition search_parameters.hpp:392
void SetDerivativePatchSize(int value)
Set smoothing area in pixels for gradient and normal calculation.
Definition search_parameters.hpp:92
void SetICPMaxIterations(int value)
Set the maximum number of iterations of the ICP algorithm.
Definition search_parameters.hpp:244
void SetICPShrink(int value)
Set the subsample factor for ICP.
Definition search_parameters.hpp:215
double MinCoverage() const noexcept
Get minimum coverage.
Definition search_parameters.hpp:289
void SetMinCoverage(double value)
Set minimum coverage.
Definition search_parameters.hpp:303
void SetPartsToFind(int value)
Set the maximum number of objects to find.
Definition search_parameters.hpp:150
double IndifferentRadius() const noexcept
Get fraction of template size which accounts for a single object.
Definition search_parameters.hpp:107
void SetRawResultsOnly(bool value) noexcept
Set the raw results flag.
Definition search_parameters.hpp:186
void SetIndifferentRadius(double value)
Set fraction of template size which accounts for a single object.
Definition search_parameters.hpp:122
double PrecisionThreshold() const noexcept
Get precision threshold.
Definition search_parameters.hpp:259
double MaxOcclusion() const noexcept
Get maximum occlusion.
Definition search_parameters.hpp:318
int ICPShrink() const noexcept
Get the subsample factor for ICP.
Definition search_parameters.hpp:199
SearchParameters()=default
Default search parameters.
Container for range definitions.
Definition value_range.hpp:17
T Min() const noexcept
Gets the minimum value.
Definition value_range.hpp:47
T Max() const noexcept
Gets the maximum value.
Definition value_range.hpp:69
Namespace for Match3D DNC (CAD-based 3D-object recognition).
Definition dnc.hpp:27
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17