SVM model fails to load in Android Application
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?
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
BUT svm.load() should take the path of the training file ?!
Can I use CascadeClassifier with SVM also ??
"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 ?