From dd45fe13d190e91961e44fe9809d13a6e357f6bb Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 18 Apr 2011 16:32:43 +0000 Subject: [PATCH] fixed OutputArray::create, which resolves several failures in opencv_test_core --- modules/core/src/matrix.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index c6c8003..f3a5458 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1188,11 +1188,15 @@ void OutputArray::create(int dims, const int* size, int type, int i, bool alloca { CV_Assert( i < 0 ); Mat& m = *(Mat*)obj; - if( allocateVector && dims == 2 && m.dims == 2 && - m.type() == type && m.rows == size[1] && m.cols == size[0] && m.isContinuous()) - return; - if( !m.isContinuous() ) - m.release(); + if( allocateVector ) + { + if( !m.isContinuous() ) + m.release(); + + if( dims == 2 && m.dims == 2 && m.data && + m.type() == type && m.rows == size[1] && m.cols == size[0] ) + return; + } m.create(dims, size, type); return; } @@ -1310,11 +1314,15 @@ void OutputArray::create(int dims, const int* size, int type, int i, bool alloca CV_Assert( i < (int)v.size() ); Mat& m = v[i]; - if( allocateVector && dims == 2 && m.dims == 2 && - m.type() == type && m.rows == size[1] && m.cols == size[0] && m.isContinuous()) - return; - if(!m.isContinuous()) - m.release(); + if( allocateVector ) + { + if( !m.isContinuous() ) + m.release(); + + if( dims == 2 && m.dims == 2 && m.data && + m.type() == type && m.rows == size[1] && m.cols == size[0] ) + return; + } m.create(dims, size, type); } } -- 2.7.4