diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 24def2f097..b6c413040e 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -271,7 +271,7 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv) _mv.release(); return; } - CV_Assert( !_mv.fixedType() || _mv.type() == m.depth() ); + CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == m.depth() ); _mv.create(m.channels(), 1, m.depth()); Mat* dst = &_mv.getMatRef(0); split(m, dst); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index a29a1b0772..2540013ac5 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1469,9 +1469,6 @@ int _InputArray::type(int i) const { int k = kind(); - if( k == MATX || k == STD_VECTOR || k == STD_VECTOR_VECTOR || (flags & FIXED_TYPE)) - return CV_MAT_TYPE(flags); - if( k == MAT ) return ((const Mat*)obj)->type(); @@ -1481,14 +1478,21 @@ int _InputArray::type(int i) const if( k == EXPR ) return ((const MatExpr*)obj)->type(); + if( k == MATX || k == STD_VECTOR || k == STD_VECTOR_VECTOR ) + return CV_MAT_TYPE(flags); + if( k == NONE ) return -1; if( k == STD_VECTOR_MAT ) { const std::vector& vv = *(const std::vector*)obj; + if( vv.empty() ) + { + CV_Assert((flags & FIXED_TYPE) != 0); + return CV_MAT_TYPE(flags); + } CV_Assert( i < (int)vv.size() ); - return vv[i >= 0 ? i : 0].type(); }