Ask Your Question

Move SVM between python and cpp ?

asked 2016-08-24 04:20:13 -0600 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


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

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

berak gravatar image

sure, you can just:"some.xml") # in python


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

Question Tools

1 follower


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

Seen: 122 times

Last updated: Aug 24 '16