Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Training SVM and saving data

Hello. I switched from Java to C++ because of performance in my application, but I am having trouble when training SVM. It take a long time to load 4500+ images, and then the SVM is trained instantly, with true result. This is strange (at least for me), but I cannot save the resulting data. When I call the method svm->save("output.xml"); it results the following error:

OpenCV(3.4.1) Error: Parsing error (SVM model data is invalid, check sv_count, var_* and class_count tags) in cv::ml::SVMImpl::write, file C:\Users\ponto\Documents\vcpkg-master\buildtrees\opencv\src\3.4.1-273ea13f6d\modules\ml\src\svm.cpp, line 2113

What is the cause of this error? And how can I solve it? Sorry if it is obvious, I am not a Cplupluxpert.

Training SVM and saving data

Hello. I switched from Java to C++ because of performance in my application, but I am having trouble when training SVM. It take a long time to load 4500+ images, and then the SVM is trained instantly, with true result. This is strange (at least for me), but I cannot save the resulting data. When I call the method svm->save("output.xml"); it results the following error:

OpenCV(3.4.1) Error: Parsing error (SVM model data is invalid, check sv_count, var_* and class_count tags) in cv::ml::SVMImpl::write, file C:\Users\ponto\Documents\vcpkg-master\buildtrees\opencv\src\3.4.1-273ea13f6d\modules\ml\src\svm.cpp, line 2113

What is the cause of this error? And how can I solve it? Sorry if it is obvious, I am not a Cplupluxpert.

EDIT: This is the pastebin link to my code: https://pastebin.com/tq5Ldgpz