From f87987ed72dce109135d093b733d5296efc6e404 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sat, 22 Dec 2012 17:56:02 +0400 Subject: [PATCH] Honor multidimensional matrices in InputArray::total --- modules/core/src/matrix.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 5ea21cf8a1..7b58debfc7 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(); } -- GitLab