# Exporting R model to OpenCV's Machine Learning Library

I'm wonder if it's possible to export a model trained in R, to OpenCV's Machine Learning (ML) library format? The latter appears to save/read models in XML/YAML, whereas the former might be exportable via PMML. Specifically, I'm working with Random Forests, which are classifiers available both in R and OpenCV's ML library.

Any advice on how I can get the two to share models would be greatly appreciated.

• Writing a conversion script seems the most straightforward way to do this. Dec 12 '14 at 16:18
• @AmirAliAkbari - Have you done something like that with R and OpenCV? If so, can you provide an example in the form of an answer? If not, can you point out some promising approaches for writing such a conversion script? Dec 12 '14 at 22:52

Instead of exporting your models, consider creating an R-based interoperable environment for your modeling needs. Such environment would consists of R environment proper as well as integration layers for your third-party libraries. In particular, for the OpenCV project, consider either using r-opencv open source project (https://code.google.com/p/r-opencv), or integration via OpenCV C++ APIs and R Rcpp package (http://dirk.eddelbuettel.com/code/rcpp.html). Finally, if you want to add PMML support to the mix and create a deployable-to-cloud solution, take a look at the following excellent blog post with relevant examples: http://things-about-r.tumblr.com/post/37861967022/predictive-modeling-using-r-and-the.
• Unfortunately, it looks as if r-opencv is relatively unmaintained (last updates 9 months ago, followed by 5 years ago). The PMML option and associated link appear to be great resources. Thanks! Dec 15 '14 at 2:53