问题
I've tried to convert OpenCV Mat
to PyObject*
with this code :
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;
}
but always raise this exception :
Exception thrown at 0x00007FF75B5EDF03 in EmbededPython.exe: 0xC0000005: Access violation reading location 0x0000000000000010.
Where I mistake? or How can I convert Mat to PyObject* ?
In the beginning of my code I used :
Py_Initialize();
PySys_SetArgv(argc,(wchar_t**)argv);
But when I want to add import_array()
this error occurred:
RuntimeError: _ARRAY_API is not PyCapsule object
来源:https://stackoverflow.com/questions/57533462/convert-opencv-mat-to-pyobject