CVB++ 14.0
classification_predictor_factory.hpp
1#pragma once
2
3#include "../_cexports/c_polimago.h"
4
5#include "../global.hpp"
6#include "predictor_factory_base.hpp"
7#include "classification_predictor.hpp"
8#include "classification_test_result.hpp"
9#include "../minos/training_set.hpp"
10#include "../sample_database/sample_classification_image_list.hpp"
11
12#include <memory>
13
14namespace Cvb
15{
16CVB_BEGIN_INLINE_NS
17
19namespace Polimago
20{
22namespace Training
23{
24
25namespace Private
26{
27inline CExports::TClassifierUsage ToClassifierUsageType(ClassificationType val)
28{
29 switch (val)
30 {
32 return CExports::CU_ClassifyOneVersusAll;
34 return CExports::CU_ClassifyOneVersusOne;
35 }
36 throw std::invalid_argument("invalid classification type");
37}
38
39inline ClassificationType ToClassificationType(CExports::TClassifierUsage val)
40{
41 switch (val)
42 {
43 case CExports::CU_ClassifyOneVersusAll:
45 case CExports::CU_ClassifyOneVersusOne:
47 }
48 throw std::invalid_argument("invalid classification type");
49}
50} /* namespace Private */
51
53
56{
57public:
59
65 usage_(Private::ToClassifierUsageType(usageType))
66 {}
67
69
71
73
74public:
76
80 ClassificationType Usage() const noexcept
81 {
82 return Private::ToClassificationType(usage_);
83 }
84
86
91 {
92 usage_ = Private::ToClassifierUsageType(usage);
93 }
94
96
102 {
103 PredictorFactoryBaseEx::UseSettingsFromPredictor (clf);
104 SetUsage (clf.Classification ());
105 }
106
108
114 {
115 PredictorFactoryBaseEx::UseSettingsFromTestResult (res);
116 }
117
118#if 0
120
127 {
128 return Internal::DoResCallObjectOut<ClassificatioPredictor>([&](void* & res)
129 {
130 return CVB_CALL_CAPI(PMTrainClassifierFromSil(sil.Handle(), ..., usage_, preproCode_, featureResolution_, lambda_, interpolation_ == InterpolationType::Linear, res);
131 });
132 }
133
135
142 {
143 return Internal::DoResCallObjectOut<ClassificatioPredictor>([&](void* & res)
144 {
145 return CVB_CALL_CAPI(PMTrainClassifierFromMts(sil.Handle(), ..., usage_, preproCode_, featureResolution_, lambda_, interpolation_ == InterpolationType::Linear, res);
146 });
147 }
148#endif
149
150private:
151 CExports::TClassifierUsage usage_;
152};
153
156
157
158} /* namespace Training */
159
162
163} /* namespace Polimago */
164CVB_END_INLINE_NS
165} /* namespace Cvb */
A Minos Training Set from which a classifier can be generated.
Definition: training_set.hpp:1151
Predictor to classify patterns with.
Definition: classification_predictor.hpp:45
ClassificationType Classification() const
The classification type for which this classifier has been generated.
Definition: classification_predictor.hpp:150
Classification test result object.
Definition: classification_test_result.hpp:27
Predictor factory for classification predictor.
Definition: classification_predictor_factory.hpp:56
void SetUsage(ClassificationType usage)
Sets the type of classification for which to generate the predictor.
Definition: classification_predictor_factory.hpp:90
ClassificationType Usage() const noexcept
Gets the type of classification for which to generate the predictor.
Definition: classification_predictor_factory.hpp:80
ClassificationPredictorFactory(ClassificationType usageType)
Constructor.
Definition: classification_predictor_factory.hpp:63
void UseSettingsFromPredictor(const ClassificationPredictor &clf)
Copy the predictor generation settings from a predictor.
Definition: classification_predictor_factory.hpp:101
void UseSettingsFromTestResult(const ClassificationTestResult &res)
Copy the predictor generation settings from a test result.
Definition: classification_predictor_factory.hpp:113
Base class for classifier factory classes.
Definition: predictor_factory_base.hpp:178
Classifier type that operates on images.
Definition: decl_classification_sil.hpp:204
void * Handle() const noexcept
Classic API SIL handle.
Definition: sample_list.hpp:403
ClassificationType
Determine the classification type to be carried out.
Definition: classification_predictor.hpp:32
@ OneVersusAll
Quick classification, that tests versus all classes simultaneously (but potentially at the cost of re...
@ OneVersusOne
Thorough classification, that tests all possible pairs of classes (which yields potentially better re...
@ Linear
Image data is (if necessary) extracted with linear interpolation.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24