Ask Your Question

Revision history [back]

This may be a late answer, but I hope this can help someone who encounters the same problem. The reason why SVM training part is slow: It needs to compute the latent feature matrix from two big matrices (in this question 1000x5000 matrix for 1st case, 5000x5000 for 2nd case and 5000x50000 for the 3rd case) while multiplication big matrices is not an ordinary routine of OpenCV, even when it invokes parallel techniques as a silver bullet. I have noticed that the OpenCV's SVM module has a pre-computed option for using with pre-computed kernel matrix, but it does not implemented currently. Hence, for solving your problem to gain high speed performance, you have to write the code for computing the kernel matrix (for both training and predicting parts) by using a dedicated library (such as OpenBLAS) or parallel techniques (TBB, C++ threads, etc ...) and the code for doing SVM tasks (train and predict) by using LibSVM directly. I have followed this way and gain good performance with 12000 samples, each one is a 25000-D feature vector, on a 64 bit Windows 7 machine with 4Gb RAM. Following are some resource links for reference:

  1. LibSVM
  2. Using LibSVM
  3. How to create training data for LibSVM