Ask Your Question

wampir's profile - activity

2015-06-04 06:52:46 -0600 received badge  Famous Question (source)
2014-10-01 09:39:05 -0600 received badge  Good Question (source)
2014-07-02 04:03:45 -0600 received badge  Notable Question (source)
2014-03-07 04:24:22 -0600 received badge  Popular Question (source)
2013-08-08 03:51:45 -0600 received badge  Nice Question (source)
2013-05-16 08:47:55 -0600 commented answer Machine learning save/load problem

Once again. I don't have problems with save() method (except CvKNearest class) - I get good xml file after saving, but I can't properly load those xml files. After loading my classifier is corrupted and when I try to classify I will receive error message which is given in my first post.

2013-05-15 16:25:35 -0600 commented answer Machine learning save/load problem

About third point -> I'm sure that I'm reading correct XML model. I've checked it twice;)

2013-05-15 14:35:30 -0600 received badge  Student (source)
2013-05-15 14:31:10 -0600 received badge  Editor (source)
2013-05-15 14:27:37 -0600 asked a question Machine learning save/load problem

Hello,

I have a problem with save() and load() methods in ml module. for example if I run code:

CvSVM *SVM = new CvSVM;
SVM->load("SVM.xml");
SVM->predict(DataRow);

I'll obtain this error:

OpenCV Error: Bad argument (The SVM should be trained first) in CvSVM::predict, file /home/wampir/OpenCV-2.4.3/modules/ml/src/svm.cpp, line 2072
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/wampir/OpenCV-2.4.3/modules/ml/src/svm.cpp:2072: error: (-5) The SVM should be trained first in function CvSVM::predict

Model in "SVM.xml" is saved with: SVM->save("SVN.xml","NET"); of course SVM was previously trained;

When I'm doing the same with CvRTrees, method load() gives me a segmentation fault (core dumped). For CvERTrees, CvGBTrees and CvNormalBayesClassifier it works exactly like for CvSVM.

CvKNearest is bigger problem because I can't even save my trained model to a file, for example when I run this code:

KNearest->save("KNearest.xml");

for trained CvKNearest *KNearest=new KNearest; my "KNearest.xml" will contain only:

<?xml version="1.0"?>
<opencv_storage>

and nothing more.

After that Ill obtain this error:

OpenCV Error: The function/feature is not implemented () in CvStatModel::write, file /home/wampir/OpenCV-2.4.3/modules/ml/src/inner_functions.cpp, line 114
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/wampir/OpenCV-2.4.3/modules/ml/src/inner_functions.cpp:114: error: (-213)  in function CvStatModel::write

Can somebody help me, and tell me how to properly save and load my models or if it is a bug fix it?

Thank you very much ;)

PS: I almost forgot. Im working under ubuntu 12.10 x86, kernel Linux 3.5.0-17-generic.

PS2: Ow - One more thing - Im using OpenCV 2.4.4