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
yea, you hit some wasp nest there