Hi, I am using opencv v3.4.2 with QT Creator IDE in C++.
I am trying to wrap an OpenCV matrix (Mat) as a numpyarray (PyObject *) so that an pass it to a python script for processing. I am using the built-in wrapper functions from here: opencv/cv2.cpp. In particular this function:
PyObject* pyopencv_from(const Mat& m)
{
if( !m.data )
Py_RETURN_NONE;
Mat temp, *p = (Mat*)&m;
if(!p->u || p->allocator != &g_numpyAllocator)
{
temp.allocator = &g_numpyAllocator;
ERRWRAP2(m.copyTo(temp));
p = &temp;
}
PyObject* o = (PyObject*)p->u->userdata;
Py_INCREF(o);
return o;
}
So I have something like this:
Mat frame;
/*frame is populated*/
PyObject* pMat = opencv_from(frame);
The code compiles fine but when I call the function it hangs on m.copyTo(temp)
.
Does anyone have any advice on why this is not working ? Thanks.