3

我有一个共享库(util.so),它将以下内容返回给 python:

cv::Mat toCvMat(PyObject *ndArrayObj) {
    // return cv::Mat
}

我使用以下命令从我的 python 脚本中调用该方法:

Python:

testMat = util.toCvMat(orig_frame_gray_img)

当我将它传递给我的其他测试库 (test_library.so) 时,它作为 PyObject* 传递,我如何访问我的 test_library.so 中的 cv::Mat?:

Python:

test_library.process(testMat)

C++

bool TestLibrary::Process( PyObject* pTestImg)
{
// How to get cv::Mat from pTestImg?
}

目前,我的 test_library 没有与 util 链接,它们是单独的 .so 文件。

4

1 回答 1

0

Based on http://yati-sagade.github.io/2013/05/11/numpy-boost-python/

NDArrayConverter cvt;
cv::Mat m;
m = cvt.toMat(pTestImg);

The required NDArrayConverter can be found from https://github.com/yati-sagade/opencv-ndarray-conversion

于 2016-01-18T08:42:00.377 回答