CVB++ 15.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{
16 CVB_BEGIN_INLINE_NS
17
19 namespace Polimago
20 {
22 namespace Training
23 {
24
25 namespace Private
26 {
27 inline CExports::TClassifierUsage ToClassifierUsageType(ClassificationType val)
28 {
29 switch (val)
30 {
31 default:
32 throw std::invalid_argument("invalid classification type");
34 return CExports::CU_ClassifyOneVersusAll;
36 return CExports::CU_ClassifyOneVersusOne;
37 }
38 }
39
40 inline ClassificationType ToClassificationType(CExports::TClassifierUsage val) noexcept
41 {
42 switch (val)
43 {
44 default:
46 case CExports::CU_ClassifyOneVersusAll:
48 case CExports::CU_ClassifyOneVersusOne:
50 }
51 }
52 } /* namespace Private */
53
55
58 class ClassificationPredictorFactory : public PredictorFactoryBaseEx
59 {
60 public:
62
67 : PredictorFactoryBaseEx()
68 , usage_(Private::ToClassifierUsageType(usageType))
69 {
70 }
71
72 public:
74
78 ClassificationType Usage() const noexcept
79 {
80 return Private::ToClassificationType(usage_);
81 }
82
84
89 {
90 usage_ = Private::ToClassifierUsageType(usage);
91 }
92
94
100 {
101 PredictorFactoryBaseEx::UseSettingsFromPredictor(clf);
103 }
104
106
112 {
113 PredictorFactoryBaseEx::UseSettingsFromTestResult(res);
114 }
115
116#if 0
118
125 {
126 return Internal::DoResCallObjectOut<ClassificatioPredictor>([&](void* & res)
127 {
128 return CVB_CALL_CAPI(PMTrainClassifierFromSil(sil.Handle(), ..., usage_, preproCode_, featureResolution_, lambda_, interpolation_ == InterpolationType::Linear, res);
129 });
130 }
131
133
140 {
141 return Internal::DoResCallObjectOut<ClassificatioPredictor>([&](void* & res)
142 {
143 return CVB_CALL_CAPI(PMTrainClassifierFromMts(sil.Handle(), ..., usage_, preproCode_, featureResolution_, lambda_, interpolation_ == InterpolationType::Linear, res);
144 });
145 }
146#endif
147
148 private:
149 CExports::TClassifierUsage usage_;
150 };
151
154
155 } /* namespace Training */
156
159
160 } /* namespace Polimago */
161 CVB_END_INLINE_NS
162} /* namespace Cvb */
A Minos Training Set from which a classifier can be generated.
Definition training_set.hpp:1188
ClassificationPredictorFactory(ClassificationType usageType)
Constructor.
Definition classification_predictor_factory.hpp:66
Predictor to classify patterns with.
Definition classification_predictor.hpp:57
ClassificationType Classification() const
The classification type for which this classifier has been generated.
Definition classification_predictor.hpp:151
Classification test result object.
Definition classification_test_result.hpp:27
Predictor factory for classification predictor.
Definition classification_predictor_factory.hpp:59
void SetUsage(ClassificationType usage)
Sets the type of classification for which to generate the predictor.
Definition classification_predictor_factory.hpp:88
ClassificationType Usage() const noexcept
Gets the type of classification for which to generate the predictor.
Definition classification_predictor_factory.hpp:78
ClassificationPredictorFactory(ClassificationType usageType)
Constructor.
Definition classification_predictor_factory.hpp:66
void UseSettingsFromPredictor(const ClassificationPredictor &clf)
Copy the predictor generation settings from a predictor.
Definition classification_predictor_factory.hpp:99
void UseSettingsFromTestResult(const ClassificationTestResult &res)
Copy the predictor generation settings from a test result.
Definition classification_predictor_factory.hpp:111
Classifier type that operates on images.
Definition decl_classification_sil.hpp:213
void * Handle() const noexcept
Classic API SIL handle.
Definition sample_list.hpp:411
Namespace for the Polimago package training functionality.
Definition classification_predictor_factory.hpp:23
std::shared_ptr< ClassificationPredictorFactory > ClassificationPredictorFactoryPtr
Convenience shared pointer for ClassificationPredictorFactory.
Definition classification_predictor_factory.hpp:153
Namespace for the Polimago package.
Definition classification_predictor.hpp:38
ClassificationType
Determine the classification type to be carried out.
Definition classification_predictor.hpp:42
@ None
The enum element indicating undefined state.
Definition classification_predictor.hpp:44
@ OneVersusAll
Definition classification_predictor.hpp:47
@ OneVersusOne
Definition classification_predictor.hpp:50
@ Linear
Image data is (if necessary) extracted with linear interpolation.
Definition predictor_base.hpp:37
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17