diff python/ml.py @ 791:1158a6e2d28e dev

temporary solution for classification, with corrected svm.cpp and ml.hpp for loading saved classifiers
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 29 Apr 2016 16:07:35 -0400
parents 5b970a5bc233
children 180b6b0231c0
line wrap: on
line diff
--- a/python/ml.py	Thu Mar 24 16:37:37 2016 -0400
+++ b/python/ml.py	Fri Apr 29 16:07:35 2016 -0400
@@ -20,7 +20,9 @@
 #####################
 
 class StatModel(object):
-    '''Abstract class for loading/saving model'''    
+    '''Abstract class for loading/saving model
+
+    Issues with OpenCV, does not seem to work'''    
     def load(self, filename):
         if path.exists(filename):
             self.model.load(filename)
@@ -43,6 +45,12 @@
         self.model.setNu(nu)
         self.model.setP(p)
 
+    def load(self, filename):
+        if path.exists(filename):
+            cv2.ml.SVM_load(filename)
+        else:
+            print('Provided filename {} does not exist: model not loaded!'.format(filename))
+
     def train(self, samples, layout, responses):
         self.model.train(samples, layout, responses)