diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index 3614a91298..2067ac8375 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -393,6 +393,17 @@ public: /** Creates empty model Use StatModel::train to train the model after creation. */ CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized NormalBayesClassifier from a file + * + * Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. + * Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized NormalBayesClassifier + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); }; /****************************************************************************************\ @@ -927,6 +938,17 @@ public: can use one of the EM::train\* methods or load it from file using Algorithm::load\(filename). */ CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized EM from a file + * + * Use EM::save to serialize and store an EM to disk. + * Load the EM from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized EM + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); }; /****************************************************************************************\ @@ -1512,6 +1534,17 @@ public: Creates Logistic Regression model with parameters given. */ CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized LogisticRegression from a file + * + * Use LogisticRegression::save to serialize and store an LogisticRegression to disk. + * Load the LogisticRegression from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized LogisticRegression + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); }; @@ -1627,6 +1660,17 @@ public: */ CV_WRAP static Ptr create(); + /** @brief Loads and creates a serialized SVMSGD from a file + * + * Use SVMSGD::save to serialize and store an SVMSGD to disk. + * Load the SVMSGD from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized SVMSGD + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); + /** @brief Function sets optimal parameters values for chosen SVM SGD model. * @param svmsgdType is the type of SVMSGD classifier. * @param marginType is the type of margin constraint. diff --git a/modules/ml/src/em.cpp b/modules/ml/src/em.cpp index 5b833cdae0..40993ff441 100644 --- a/modules/ml/src/em.cpp +++ b/modules/ml/src/em.cpp @@ -845,6 +845,11 @@ Ptr EM::create() return makePtr(); } +Ptr EM::load(const String& filepath, const String& nodeName) +{ + return Algorithm::load(filepath, nodeName); +} + } } // namespace cv diff --git a/modules/ml/src/lr.cpp b/modules/ml/src/lr.cpp index c3c314228b..8198003da5 100644 --- a/modules/ml/src/lr.cpp +++ b/modules/ml/src/lr.cpp @@ -127,6 +127,12 @@ Ptr LogisticRegression::create() return makePtr(); } +Ptr LogisticRegression::load(const String& filepath, const String& nodeName) +{ + return Algorithm::load(filepath, nodeName); +} + + bool LogisticRegressionImpl::train(const Ptr& trainData, int) { // return value diff --git a/modules/ml/src/nbayes.cpp b/modules/ml/src/nbayes.cpp index c46367cefa..ae82a1463f 100644 --- a/modules/ml/src/nbayes.cpp +++ b/modules/ml/src/nbayes.cpp @@ -458,6 +458,11 @@ Ptr NormalBayesClassifier::create() return p; } +Ptr NormalBayesClassifier::load(const String& filepath, const String& nodeName) +{ + return Algorithm::load(filepath, nodeName); +} + } } diff --git a/modules/ml/src/svmsgd.cpp b/modules/ml/src/svmsgd.cpp index 0ef9175dad..4b92079978 100644 --- a/modules/ml/src/svmsgd.cpp +++ b/modules/ml/src/svmsgd.cpp @@ -134,6 +134,12 @@ Ptr SVMSGD::create() return makePtr(); } +Ptr SVMSGD::load(const String& filepath, const String& nodeName) +{ + return Algorithm::load(filepath, nodeName); +} + + void SVMSGDImpl::normalizeSamples(Mat &samples, Mat &average, float &multiplier) { int featuresCount = samples.cols;