From a7aa198b4caa07895b41593fdd9adf480a40c5c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christoph=20Sp=C3=B6rk?= Date: Mon, 4 Jan 2016 15:47:26 +0100 Subject: [PATCH] fixing issue #4969 of Itseez/opencv. Someone forgot to wrap the load function for SVMs in the corresponding ml python module. Fixed that. --- modules/ml/include/opencv2/ml.hpp | 4 ++++ modules/ml/src/svm.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index 862f3f9..013d918 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -719,6 +719,10 @@ public: Use StatModel::train to train the model. Since %SVM has several parameters, you may want to find the best parameters for your problem, it can be done with SVM::trainAuto. */ CV_WRAP static Ptr create(); + + CV_WRAP virtual void read( const FileNode& fn ) = 0; + + CV_WRAP static Ptr load(const String& fs); }; /****************************************************************************************\ diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp index 757bb7a..639f6e2 100644 --- a/modules/ml/src/svm.cpp +++ b/modules/ml/src/svm.cpp @@ -2261,6 +2261,17 @@ Ptr SVM::create() return makePtr(); } +Ptr SVM::load(const String& filename) +{ + FileStorage fs; + fs.open(filename, FileStorage::READ); + + Ptr svm = makePtr(); + + svm->read(fs.getFirstTopLevelNode()); + return svm; +} + Mat SVM::getUncompressedSupportVectors() const { const SVMImpl* this_ = dynamic_cast(this); -- 2.7.4