21 #ifndef otbMachineLearningModelFactory_hxx
22 #define otbMachineLearningModelFactory_hxx
25 #include "otbConfigure.h"
28 #include "otb_opencv_api.h"
50 template <
class TInputValue,
class TOutputValue>
54 RegisterBuiltInFactories();
56 std::list<MachineLearningModelTypePointer> possibleMachineLearningModel;
57 std::list<LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance(
"otbMachineLearningModel");
58 for (std::list<LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i)
63 possibleMachineLearningModel.push_back(io);
67 std::cerr <<
"Error MachineLearningModel Factory did not return an MachineLearningModel: " << (*i)->
GetNameOfClass() << std::endl;
70 for (
typename std::list<MachineLearningModelTypePointer>::iterator k = possibleMachineLearningModel.begin(); k != possibleMachineLearningModel.end(); ++k)
74 if ((*k)->CanReadFile(path))
79 else if (mode == WriteMode)
81 if ((*k)->CanWriteFile(path))
90 template <
class TInputValue,
class TOutputValue>
93 std::lock_guard<std::mutex> lockHolder(mutex);
104 #ifdef OTB_USE_OPENCV
115 template <
class TInputValue,
class TOutputValue>
121 itk::ObjectFactoryBase::UnRegisterFactory(factory);
122 itk::ObjectFactoryBase::RegisterFactory(factory);
125 template <
class TInputValue,
class TOutputValue>
128 std::lock_guard<std::mutex> lockHolder(mutex);
130 std::list<itk::ObjectFactoryBase*> factories = itk::ObjectFactoryBase::GetRegisteredFactories();
131 std::list<itk::ObjectFactoryBase*>::iterator itFac;
133 for (itFac = factories.begin(); itFac != factories.end(); ++itFac)
135 #ifdef OTB_USE_LIBSVM
140 itk::ObjectFactoryBase::UnRegisterFactory(libsvmFactory);
150 itk::ObjectFactoryBase::UnRegisterFactory(sharkRFFactory);
156 if (sharkKMeansFactory)
158 itk::ObjectFactoryBase::UnRegisterFactory(sharkKMeansFactory);
163 #ifdef OTB_USE_OPENCV
169 itk::ObjectFactoryBase::UnRegisterFactory(rfFactory);
176 itk::ObjectFactoryBase::UnRegisterFactory(svmFactory);
184 itk::ObjectFactoryBase::UnRegisterFactory(boostFactory);
192 itk::ObjectFactoryBase::UnRegisterFactory(annFactory);
200 itk::ObjectFactoryBase::UnRegisterFactory(bayesFactory);
208 itk::ObjectFactoryBase::UnRegisterFactory(dtFactory);
216 itk::ObjectFactoryBase::UnRegisterFactory(knnFactory);
Create an instance of SVMMachineLearningModel through the object factory.
Creation d'un instance d'un object SVMMachineLearningModel utilisant les object factory.
Create an instance of KNearestNeighborsMachineLearningModel through the object factory.
Creation of an instance of an object SVMMachineLearningModel using the objects factory.
static void RegisterFactory(itk::ObjectFactoryBase *factory)
static MachineLearningModelTypePointer CreateMachineLearningModel(const std::string &path, FileModeType mode)
static void CleanFactories()
static void RegisterBuiltInFactories()
MachineLearningModel is the base class for all classifier objects (SVM, KNN, Random Forests,...
itk::SmartPointer< Self > Pointer
virtual const char * GetNameOfClass() const
Create an instance of SVMMachineLearningModel through the object factory.
Creation of an instance of object SVMMachineLearningModel using the objects factory.
Creation of an instance of a RandomForestsMachineLearningModel object using the object factory.
Creation d'un instance d'un object SVMMachineLearningModel utilisant les object factory.
Creation of an instance of a SharkKMeansMachineLearningModel object using the object factory.
Creation of an instance of a SharkRandomForestsMachineLearningModel object using the object factory.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.