1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

onnx coverage

This commit is contained in:
Abhishek Gola
2026-07-14 19:47:32 +05:30
parent 2d2611d5bd
commit ae392712b1
3 changed files with 21 additions and 4 deletions
+15
View File
@@ -316,7 +316,22 @@ template<>
PyObject* pyopencv_from(const cv::Mat& m)
{
if( !m.data )
{
// Shaped Mat with a zero-length dim: return a matching empty array, not None.
if( m.dims >= 1 )
{
int cn = m.channels();
int typenum = cvDepthToNumpyType(m.depth());
int dims = m.dims;
cv::AutoBuffer<npy_intp> _sizes(dims + 1);
for( int i = 0; i < dims; i++ )
_sizes[i] = (npy_intp)m.size[i];
if( cn > 1 )
_sizes[dims++] = cn;
return PyArray_SimpleNew(dims, _sizes.data(), typenum);
}
Py_RETURN_NONE;
}
// 0D (scalar) Mat: return a true 0D numpy array.
if( m.dims == 0 )
{