Ask Your Question
0

Move SVM between python and cpp ?

asked 2016-08-24 04:20:13 -0600

charles.fox gravatar image

I have trained an OpenCV SVM using the python API but would like to run it in a cpp program. Is there a way to save and import it between the two languages, or would I need to retrain it in cpp ?

edit retag flag offensive close merge delete

Comments

SVM inherits from algorithm, which has a load and save option. Since those models are stored as xml you can load them from whatever language you want. The models itself won't change. Here is a SO question showing you how to save and load a SVM model.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-08-24 06:27:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-08-24 06:27:23 -0600

berak gravatar image

sure, you can just:

svm.save("some.xml") # in python

and

Ptr<ml::SVM> svm = ml::StatModel::load<ml::SVM>("some.xml"); // in c++
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-24 04:20:13 -0600

Seen: 142 times

Last updated: Aug 24 '16