Skip to content

Commit 217a9dd

Browse files
committed
Use cv::AutoBuffer::operator _Tp*() on older versions
Signed-off-by: Shane Loretz <[email protected]>
1 parent 7be045c commit 217a9dd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ndarray_converter.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ class NumpyAllocator : public MatAllocator
128128
_sizes[i] = sizes[i];
129129
if( cn > 1 )
130130
_sizes[dims++] = cn;
131+
#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION == 3 && CV_VERSION_MINOR >= 5) || (CV_MAJOR_VERSION == 3 && CV_VERSION_MINOR == 4 && CV_VERSION_REVISION >= 3)
132+
// Use cv::AutoBuffer::data() in OpenCV 3.4.3 and above
131133
PyObject* o = PyArray_SimpleNew(dims, _sizes.data(), typenum);
134+
#else
135+
// Use older cv::AutoBuffer::operator _Tp*()
136+
PyObject* o = PyArray_SimpleNew(dims, &(_sizes[0]), typenum);
137+
#endif
132138
if(!o)
133139
CV_Error_(Error::StsError, ("The numpy array of typenum=%d, ndims=%d can not be created", typenum, dims));
134140
return allocate(o, dims0, sizes, type, step);

0 commit comments

Comments
 (0)