从 C++ 调用 scikit-learn 函数
Calling scikit-learn functions from C++
有没有办法从c++调用scikit-learn的函数?我的其余大部分代码都使用 opencv 在 C++ 中编写。我希望能够使用 scikit-learn 提供的分类器。据我所知,没有简单的方法 - 我需要使用 boost::python 或 swig。我还遇到了这个项目 (https://github.com/spillai/numpy-opencv-converter),它显示了 numpy 数组 <==> cv::Mat 对象之间的互操作,但我只知道如何从我的 python 脚本中调用 C++ 代码,不是相反。
您可以通过包含 python headers 并通过 Py* 包装器调用您的 python 脚本 and/or scikit 方法,以非常简单的方式完成。
有关详细示例,请参阅 https://docs.python.org/2/extending/embedding.html#pure-embedding。
跟进,今天似乎有两种方法可以解决问题
有没有办法从c++调用scikit-learn的函数?我的其余大部分代码都使用 opencv 在 C++ 中编写。我希望能够使用 scikit-learn 提供的分类器。据我所知,没有简单的方法 - 我需要使用 boost::python 或 swig。我还遇到了这个项目 (https://github.com/spillai/numpy-opencv-converter),它显示了 numpy 数组 <==> cv::Mat 对象之间的互操作,但我只知道如何从我的 python 脚本中调用 C++ 代码,不是相反。
您可以通过包含 python headers 并通过 Py* 包装器调用您的 python 脚本 and/or scikit 方法,以非常简单的方式完成。
有关详细示例,请参阅 https://docs.python.org/2/extending/embedding.html#pure-embedding。
跟进