mirror of
https://github.com/opencv/opencv.git
synced 2026-07-28 23:03:03 +04:00
Replace static numpy allocator by function containing static.
That enables the numpy code to be its own library, in case some users want to (e.g. CLIF library).
This commit is contained in:
@@ -56,7 +56,7 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
|
||||
if(!o || o == Py_None)
|
||||
{
|
||||
if( !m.data )
|
||||
m.allocator = &g_numpyAllocator;
|
||||
m.allocator = &GetNumpyAllocator();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -298,14 +298,14 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
|
||||
#endif
|
||||
|
||||
m = Mat(ndims, size, type, PyArray_DATA(oarr), step);
|
||||
m.u = g_numpyAllocator.allocate(o, ndims, size, type, step);
|
||||
m.u = GetNumpyAllocator().allocate(o, ndims, size, type, step);
|
||||
m.addref();
|
||||
|
||||
if( !needcopy )
|
||||
{
|
||||
Py_INCREF(o);
|
||||
}
|
||||
m.allocator = &g_numpyAllocator;
|
||||
m.allocator = &GetNumpyAllocator();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -316,9 +316,9 @@ PyObject* pyopencv_from(const cv::Mat& m)
|
||||
if( !m.data )
|
||||
Py_RETURN_NONE;
|
||||
cv::Mat temp, *p = (cv::Mat*)&m;
|
||||
if(!p->u || p->allocator != &g_numpyAllocator)
|
||||
if(!p->u || p->allocator != &GetNumpyAllocator())
|
||||
{
|
||||
temp.allocator = &g_numpyAllocator;
|
||||
temp.allocator = &GetNumpyAllocator();
|
||||
ERRWRAP2(m.copyTo(temp));
|
||||
p = &temp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user