Load SVM from disk on iOS
Hi everyone,
I am reading an SVM from my iOS app's document directory and it seemed to be working until I tried predicting something on it. The code is as follows:
Ptr<ml::svm> SVMAVB;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docs = [paths objectAtIndex:0];
docs = [docs stringByAppendingPathComponent:@"Classifiers/"];
NSString *vocabPath = [docs stringByAppendingPathComponent:@"SVMAVB.xml"];
FileStorage fs([vocabPath UTF8String], FileStorage::READ);
SVMAVB->load<ml::svm>(std::string([vocabPath UTF8String]));
return SVMAVB->predict(features);
However after inspecting the code before predict runs, it turns out the object is null. This is surprising, I expected a warning or error! However the program proceeds to crash when executing predict, yielding a bad access to address 0x0. Could anyone provide any help on why this might not be loading?
I'm confident the SVM is not accurate (not sure why yet, I'll come to that later), but it does exist so I expected it to at least work! Thanks for the help.