diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 5d18dd01d7..b38d95748f 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -414,7 +414,7 @@ inline int Mat::type() const { return CV_MAT_TYPE(flags); } inline int Mat::depth() const { return CV_MAT_DEPTH(flags); } inline int Mat::channels() const { return CV_MAT_CN(flags); } inline size_t Mat::step1(int i) const { return step.p[i]/elemSize1(); } -inline bool Mat::empty() const { return data == 0 || size.p[0] == 0; } +inline bool Mat::empty() const { return data == 0 || total() == 0; } inline size_t Mat::total() const { if( dims <= 2 ) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 1e61d9aa28..17b328dae0 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -205,7 +205,7 @@ void Mat::create(int d, const int* _sizes, int _type) flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL; setSize(*this, d, _sizes, 0, allocator == 0); - if( size.p[0] > 0 ) + if( total() > 0 ) { if( !allocator ) {