Python 将opencv Mat转换为PyObject*
我尝试用以下代码将OpenCVPython 将opencv Mat转换为PyObject*,python,c++,opencv,pythonanywhere,python-embedding,Python,C++,Opencv,Pythonanywhere,Python Embedding,我尝试用以下代码将OpenCVMat转换为PyObject*: PyObject* ConvertMatToPyArray(const cv::Mat& mat) { npy_intp dims[3] = { mat.rows, mat.cols, mat.channels() }; const int ND = 3; PyObject *pArray = PyArray_SimpleNewFromData( ND, dims, NPY_UINT
Mat
转换为PyObject*
:
PyObject* ConvertMatToPyArray(const cv::Mat& mat) {
npy_intp dims[3] = { mat.rows, mat.cols, mat.channels() };
const int ND = 3;
PyObject *pArray = PyArray_SimpleNewFromData(
ND, dims, NPY_UINT8, reinterpret_cast<void*>(mat.data));
return pArray;
}
我哪里错了?或者如何将Mat转换为PyObject*
在代码的开头,我使用了:
Py_Initialize();
PySys_SetArgv(argc,(wchar_t**)argv);
但是当我想添加import\u array()
时,发生了以下错误:
RuntimeError: _ARRAY_API is not PyCapsule object
RuntimeError: _ARRAY_API is not PyCapsule object