SVM model fails to load in Android Application

asked 2015-10-16 13:40:35 -0600

User1 gravatar image

updated 2015-10-16 13:41:31 -0600

I have a problem with load() method in SVM module. For example if I run code:

try {
    Uri uri = Uri.fromFile(new File("file:///android_asset/SVM_Bills.xml"));
    mySvm.load(uri.getPath());          
    int in = mySvm.get_support_vector_count();
    if (in != 0) {
        Toast.makeText(context,"done loading : " + uri.getPath(), Toast.LENGTH_SHORT).show();
        value = (int)mySvm.predict(matOfDescriptor);
    }
    else {
        Toast.makeText(context,"error while loading : " + uri.getPath(), Toast.LENGTH_SHORT).show();
    }

It give me the error toast message (i.e it goes to else part and show the toast message). Of course SVM was previously trained.

Any help please?

edit retag flag offensive close merge delete

Comments

you had another question with same topic before - again - the svm is not a java class, but a c++ one. your assets are inside a zip/jar/apk, and the underlying c++ classes cannot read from there.

again, you will have to copy your xml file to some other place (e.g. sdcard), where one can just open a regular file handle. see e.g. the facedetection sample , which suffers from same problem

berak gravatar imageberak ( 2015-10-16 13:49:47 -0600 )edit

BUT svm.load() should take the path of the training file ?!

User1 gravatar imageUser1 ( 2015-10-16 15:27:48 -0600 )edit

Can I use CascadeClassifier with SVM also ??

User1 gravatar imageUser1 ( 2015-10-16 15:57:56 -0600 )edit

"svm.load() should take the path of the training file ?!" - yes

"Can I use CascadeClassifier with SVM also" - ofc. not. why did you think so ?

berak gravatar imageberak ( 2015-10-18 03:04:36 -0600 )edit