Ask Your Question
0

LibSVM -> OpenCV SVM model conversion

asked 2017-06-15 12:59:32 -0600

ThorbjornSomod gravatar image

updated 2017-06-15 13:10:23 -0600

Hi!

I have trained some SVM classifier models for an object recognition by the use of LibSVM. I trained them using LibSVM even though I planned to use them with OpenCV because I thought that since OpenCV's SVM implementations are (or were?) based on LibSVM this would be fine. However, OpenCV uses the .yml format for SVM models while LibSVM uses their own .model format. Is there any way to convert between the two? Does anyone know of any convenient tool that could do said conversion for me? Any help would be appreciated. Cheers!

edit retag flag offensive close merge delete

Comments

what kind of SVM models did you train there ?

problem here is not so much different text formats, but different internal data representation (libsvm uses "sparse" vectors.

maybe it's easier , to use libsvm with opencv data (and your pretrained models)

berak gravatar imageberak ( 2017-06-15 23:56:57 -0600 )edit
1

I trained C-SVM models using an RBF kernel. I have also used LIBLINEAR to train models using the L2 regularized primal solver. As for LIBSVM I don't think they use a sparse representation unless you explicitly set a flag when training? The reason why I wanted to use the OpenCV implementation is that they have a lot of optimized functions that I could make use of :) So far what I have done is to extract feature vectors on a format recognized by libSVM and make wrapper functions. It works fine, but is less optimal when trying to obtain real-time performance.

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-06-16 05:47:56 -0600 )edit
1

i had a quick look at it yesterday, and i do not think, it's possible to convert the data.

opencv has "decision functions", libsvm doesn't, while libsvm has "probA and probB" values, which do not appear in opencv's svm. also the handling of the (uncompressed vs. compressed) support vectors differ.

berak gravatar imageberak ( 2017-06-17 02:02:43 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-18 04:16:51 -0600

ThorbjornSomod gravatar image

Ah alright! Well thank you for taking a look at it! :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-06-15 12:59:32 -0600

Seen: 593 times

Last updated: Jun 15 '17