Saving or Loading model in SVM

asked 2016-11-26 07:04:26 -0600

Zahraa11 gravatar image

hello I am using SVM to train my project. I am facing problem with saving the model and use (load) it again in java (android). can anyone give me suggestions please.

edit retag flag offensive close merge delete

Comments

which opencv version is it ?

berak gravatar imageberak ( 2016-11-26 10:04:19 -0600 )edit

version 2.4.9

Zahraa11 gravatar imageZahraa11 ( 2016-11-26 10:52:15 -0600 )edit

what about the builtin methods for this ?

if you're facing any errors, - please show us !

berak gravatar imageberak ( 2016-11-27 04:42:58 -0600 )edit

here is my code :

CvSVM svm= new CvSVM();
svm.train(trainData, sampleIdx);
String model= String.valueOf(svm);// i changed the svm object to string because save() accept only a string object
svm.save(model);

here is the error :

12-06 19:25:17.488 2712-2712/? E/cv::error(): OpenCV Error: Unspecified error (Could not open the file storage. Check the path and permissions) in CvStatModel::save, file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/ml/src/inner_functions.cpp, line 71

**line 71 = svm.save(model);**
Zahraa11 gravatar imageZahraa11 ( 2016-12-06 10:26:32 -0600 )edit

Actually looking at the error, I am suspecting it is not able to locate the saved SVM correctly. Could you check path and make sure you use absolute locations?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-12-07 03:19:38 -0600 )edit