Training SVM and saving data [closed]

asked 2018-09-07 17:07:23 -0600

Taarak gravatar image

updated 2018-09-08 13:40:04 -0600

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

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-13 14:26:11.036267

Comments

can we see your code, please ?

also, training may fail. did you check the return value from svm->train() ?

berak gravatar imageberak ( 2018-09-07 23:28:52 -0600 )edit

The link to the code is on the question now, and yes, I checked the result of the operation to see if it was successful.

Taarak gravatar imageTaarak ( 2018-09-08 13:41:06 -0600 )edit

mate did you fixed this problem ? i have the same issue and as you SVM is trained but the problem in saving.

manef gravatar imagemanef ( 2019-01-02 12:29:42 -0600 )edit