diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 5ea21cf8a..7b58debfc 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1188,6 +1188,24 @@ Size _InputArray::size(int i) const size_t _InputArray::total(int i) const { + int k = kind(); + + if( k == MAT ) + { + CV_Assert( i < 0 ); + return ((const Mat*)obj)->total(); + } + + if( k == STD_VECTOR_MAT ) + { + const vector& vv = *(const vector*)obj; + if( i < 0 ) + return vv.size(); + + CV_Assert( i < (int)vv.size() ); + return vv[i].total(); + } + return size(i).area(); }