你可以使用 pybind11 将 cv::Mat 类型转换成 NumPy 数组,然后将其返回给 Python 调用。

首先,你需要在 C++ 代码中包含 pybind11 头文件:

#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>

然后,你需要定义一个 Python 函数,将 cv::Mat 类型的结果作为输入参数:

void process_mat(const cv::Mat &amp;mat) {
    // Do some processing on the mat here...
}

版权声明:本文为weixin_35756130原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_35756130/article/details/128868146