@@ -25,10 +25,9 @@ bool NDArrayConverter::init_numpy() {
25
25
return true ;
26
26
}
27
27
28
- /*
29
- * The following conversion functions are taken/adapted from OpenCV's cv2.cpp file
30
- * inside modules/python/src2 folder (OpenCV 3.1.0)
31
- */
28
+ // The following conversion functions are taken/adapted from OpenCV's cv2.cpp file
29
+ // inside modules/python/src2 folder (OpenCV 4.5.2)
30
+
32
31
33
32
static PyObject* opencv_error = 0 ;
34
33
@@ -129,7 +128,7 @@ class NumpyAllocator : public MatAllocator
129
128
_sizes[i] = sizes[i];
130
129
if ( cn > 1 )
131
130
_sizes[dims++] = cn;
132
- PyObject* o = PyArray_SimpleNew (dims, _sizes, typenum);
131
+ PyObject* o = PyArray_SimpleNew (dims, _sizes. data () , typenum);
133
132
if (!o)
134
133
CV_Error_ (Error::StsError, (" The numpy array of typenum=%d, ndims=%d can not be created" , typenum, dims));
135
134
return allocate (o, dims0, sizes, type, step);
@@ -192,7 +191,7 @@ bool NDArrayConverter::toMat(PyObject *o, Mat &m)
192
191
m = Mat (sz, 1 , CV_64F);
193
192
for ( i = 0 ; i < sz; i++ )
194
193
{
195
- PyObject* oi = PyTuple_GET_ITEM (o, i);
194
+ PyObject* oi = PyTuple_GetItem (o, i);
196
195
if ( PyInt_Check (oi) )
197
196
m.at <double >(i) = (double )PyInt_AsLong (oi);
198
197
else if ( PyFloat_Check (oi) )
@@ -276,11 +275,11 @@ bool NDArrayConverter::toMat(PyObject *o, Mat &m)
276
275
277
276
if (needcopy)
278
277
{
279
- // if (info.outputarg)
280
- // {
281
- // failmsg("Layout of the output array %s is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)", info.name);
282
- // return false;
283
- // }
278
+ // if (info.outputarg)
279
+ // {
280
+ // failmsg("Layout of the output array %s is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)", info.name);
281
+ // return false;
282
+ // }
284
283
285
284
if ( needcast ) {
286
285
o = PyArray_Cast (oarr, new_typenum);
0 commit comments