3#include "../_cexports/c_minos.h"
5#include "../global.hpp"
7#include "classifier.hpp"
8#include "training_set.hpp"
25 class ClassifierFactory
28 ClassifierFactory() noexcept
48 CExports::TLearnControlStructure lcs = {};
49 lcs.Param1 =
static_cast<CExports::cvbval_t
>(indifferenceRadius_);
50 lcs.Param2 =
static_cast<CExports::cvbval_t
>(lround(negativeDensity_ * 1000.0));
51 lcs.Param3 =
static_cast<CExports::cvbval_t
>(contrastTrigger_);
52 lcs.Param4 =
static_cast<CExports::cvbval_t
>(ensembleSize_);
53 lcs.Param5 =
static_cast<CExports::cvbval_t
>(polydromy_);
54 lcs.Param6 =
static_cast<CExports::cvbval_t
>(minPairFeatures_);
55 LearnProgressData progressData = {trainingSet,
false};
56 lcs.Data = &progressData;
57 lcs.ShowProgress = NativeLearnProgress;
59 CExports::CLF clf =
nullptr;
60 CVB_CALL_CAPI_CHECKED(LearnCLFFromMTSTyped(trainingSet.
Handle(), trainingSet.
FileName().c_str(), lcs, clf));
61 if (progressData.wasInterrupted)
66 HandleGuard<Classifier> clfGuard(clf);
68 CVB_CALL_CAPI(SetCLFQualityType(clf, CExports::Quality_ReturnCorrelation));
69 CVB_CALL_CAPI(SetCLFThreshold(clf, 0.6));
142 return indifferenceRadius_;
153 if (indifferenceRadius < 0)
157 indifferenceRadius_ = indifferenceRadius;
167 return negativeDensity_;
179 if (negativeDensity < 0.0 || negativeDensity > 1.0)
183 negativeDensity_ = negativeDensity;
194 return contrastTrigger_;
207 if (contrastTrigger < 1 || contrastTrigger > 254)
211 contrastTrigger_ = contrastTrigger;
222 return ensembleSize_;
233 if (ensembleSize < 1)
237 ensembleSize_ = ensembleSize;
262 polydromy_ = polydromy;
272 return minPairFeatures_;
282 if (minPairFeatures < 1)
286 minPairFeatures_ = minPairFeatures;
290 struct LearnProgressData
296 static CExports::cvbbool_t __stdcall NativeLearnProgress(
void *pPrivate, CExports::MTSINSTANCE instance,
297 CExports::cvbval_t total, CExports::cvbval_t correct,
298 CExports::cvbval_t current)
300 LearnProgressData *pdata =
reinterpret_cast<LearnProgressData *
>(pPrivate);
312 int indifferenceRadius_;
313 double negativeDensity_;
314 int contrastTrigger_;
317 int minPairFeatures_;
25 class ClassifierFactory {
…};
static int ContrastTriggerDefault() noexcept
Default value for the ContrastTrigger.
Definition classifier_factory.hpp:98
std::unique_ptr< Classifier > Learn(const TrainingSet &trainingSet)
Learn a new classifier from the trainingSet using the parameters stored in the properties of this obj...
Definition classifier_factory.hpp:46
int MinPairFeatures() const noexcept
Get the minimum number of features to extract for each model when building a classifier.
Definition classifier_factory.hpp:270
void SetEnsembleSize(int ensembleSize)
Set the maximum size of the Ensembles of similar instance images to be used for pair feature calculat...
Definition classifier_factory.hpp:231
static int PolydromyDefault() noexcept
Default value for the Polydromy.
Definition classifier_factory.hpp:118
int IndifferenceRadius() const noexcept
Get the minimum distance to be assumed between a (labeled) positive sample and a counter sample in a ...
Definition classifier_factory.hpp:140
void SetIndifferenceRadius(int indifferenceRadius)
Set the minimum distance to be assumed between a (labeled) positive sample and a counter sample in a ...
Definition classifier_factory.hpp:151
int ContrastTrigger() const noexcept
Get the minimum contrast a Minos feature must achieve before it is eligible to become part of the cla...
Definition classifier_factory.hpp:192
void SetMinPairFeatures(int minPairFeatures)
Set the minimum number of features to extract for each model when building a classifier.
Definition classifier_factory.hpp:280
static double NegativeDensityDefault() noexcept
Default value for the NegativeDensity.
Definition classifier_factory.hpp:88
int Polydromy() const noexcept
Get the polydromy value controlling the complexity of the feature search tree in the classifier.
Definition classifier_factory.hpp:245
static int EnsembleSizeDefault() noexcept
Default value for the EnsembleSize.
Definition classifier_factory.hpp:108
int EnsembleSize() const noexcept
Get the maximum size of the Ensembles of similar instance images to be used for pair feature calculat...
Definition classifier_factory.hpp:220
void SetContrastTrigger(int contrastTrigger)
Set the minimum contrast a Minos feature must achieve before it is eligible to become part of the cla...
Definition classifier_factory.hpp:205
static int MinPairFeaturesDefault() noexcept
Default value for the MinPairFeatures.
Definition classifier_factory.hpp:128
void SetNegativeDensity(double negativeDensity)
Set the scan density with which to extract counter samples from the training set images....
Definition classifier_factory.hpp:177
static int IndifferenceRadiusDefault() noexcept
Default value for the IndifferenceRadius.
Definition classifier_factory.hpp:78
double NegativeDensity() const noexcept
Get the scan density with which to extract counter samples from the training set images.
Definition classifier_factory.hpp:165
void SetPolydromy(int polydromy)
Set the polydromy value controlling the complexity of the feature search tree in the classifier....
Definition classifier_factory.hpp:256
static std::unique_ptr< Classifier > FromHandle(HandleGuard< Classifier > &&guard)
Creates classifier from a classic API handle.
Definition classifier.hpp:390
A Minos Training Set from which a classifier can be generated.
Definition training_set.hpp:1188
String FileName() const
Name of the file, from which this training set was loaded (empty string if this image list was neithe...
Definition training_set.hpp:1448
void * Handle() const noexcept
Classic API CLF handle.
Definition training_set.hpp:1295
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for the Minos package.
Definition classifier.hpp:29
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17