fixed clone of empty matrix

This commit is contained in:
Ilya Lavrenov
2016-07-14 16:36:57 +03:00
parent ce05d6cb89
commit 87ae4e0564
5 changed files with 12 additions and 12 deletions

View File

@@ -115,12 +115,13 @@ cvCreateMatHeader( int rows, int cols, int type )
{
type = CV_MAT_TYPE(type);
if( rows < 0 || cols <= 0 )
if( rows < 0 || cols < 0 )
CV_Error( CV_StsBadSize, "Non-positive width or height" );
int min_step = CV_ELEM_SIZE(type)*cols;
int min_step = CV_ELEM_SIZE(type);
if( min_step <= 0 )
CV_Error( CV_StsUnsupportedFormat, "Invalid matrix type" );
min_step *= cols;
CvMat* arr = (CvMat*)cvAlloc( sizeof(*arr));
@@ -148,7 +149,7 @@ cvInitMatHeader( CvMat* arr, int rows, int cols,
if( (unsigned)CV_MAT_DEPTH(type) > CV_DEPTH_MAX )
CV_Error( CV_BadNumChannels, "" );
if( rows < 0 || cols <= 0 )
if( rows < 0 || cols < 0 )
CV_Error( CV_StsBadSize, "Non-positive cols or rows" );
type = CV_MAT_TYPE( type );

View File

@@ -259,12 +259,6 @@ void Mat::copyTo( OutputArray _dst ) const
return;
}
if( empty() )
{
_dst.release();
return;
}
if( _dst.isUMat() )
{
_dst.create( dims, size.p, type() );

View File

@@ -3909,8 +3909,6 @@ icvReadMat( CvFileStorage* fs, CvFileNode* node )
mat = cvCreateMat( rows, cols, elem_type );
cvReadRawData( fs, data, mat->data.ptr, dt );
}
else if( rows == 0 && cols == 0 )
mat = cvCreateMatHeader( 0, 1, elem_type );
else
mat = cvCreateMatHeader( rows, cols, elem_type );