i want to use string streams in memory instead of a file stream to read in the file from disk for performance purposes. the parameters for svm-predict is: ./svm-predict test_file model_file output_file. Here is my code (using libsvm):
Where poseData is the string stream that contains the same input svm values as the working flat file version.
char temp[5120000];
char temp2[512];
sprintf(temp2, "./svm-predict %s %s %s", (FILE *)poseData, "tmp_train.model", (FILE*)temp );
// sprintf(temp2, "./svm-predict %s%i%s %s %s%i%s", "./Test_Files/", pos,".jpg.txt","tmp_train.model", "./Output/",pos,".jpg.output");
The commented out version of sprintf works, but is slow because of hard drive access. also the sprintf poseData looks exactly like the flat file but i cannot cast it to one…
svm-predict takes file system locations for data and models (this is why your first attempt works). You can’t pass memory pointers to the external program.
You’ll need to use either the
libsvmlibrary, or OpenCV has CvSVM that you might try using internally for performance. Here are a couple of tutorials on use SVM in OpenCV. OpenCV’s SVM implementation is based on LibSVM, so that’s probably what I would use since you are already using OpenCV anyway.