diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index 5e633c4d0a..619664ba30 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -827,6 +827,20 @@ public: return model->isTrained() ? model : Ptr<_Tp>(); } + /** @brief Loads model from a String + @param strModel The string variable containing the model you want to load. + + This is static template method of StatModel. It's usage is following (in the case of SVM): + Ptr svm = StatModel::loadFromString(myStringModel); + */ + template static Ptr<_Tp> loadFromString(const String& strModel) + { + FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY); + Ptr<_Tp> model = _Tp::create(); + model->read(fs.getFirstTopLevelNode()); + return model->isTrained() ? model : Ptr<_Tp>(); + } + template static Ptr<_Tp> train(const Ptr& data, const typename _Tp::Params& p, int flags=0) { Ptr<_Tp> model = _Tp::create(p); @@ -1511,6 +1525,7 @@ public: }; /** @brief The class represents a decision tree node. It has public members: + - member double value Value at the node: a class label in case of classification or estimated function value in case of regression.