mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 19:50:38 +08:00
fixed clone of empty matrix
This commit is contained in:
parent
ce05d6cb89
commit
87ae4e0564
@ -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 );
|
||||
|
@ -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() );
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -706,7 +706,6 @@ protected:
|
||||
|
||||
EXPECT_EQ(_em_in.rows , _em_out.rows);
|
||||
EXPECT_EQ(_em_in.cols , _em_out.cols);
|
||||
EXPECT_EQ(_em_in.dims , _em_out.dims);
|
||||
EXPECT_EQ(_em_in.depth(), _em_out.depth());
|
||||
EXPECT_TRUE(_em_in.empty());
|
||||
|
||||
|
@ -1538,3 +1538,11 @@ TEST(Mat, push_back_vector)
|
||||
|
||||
ASSERT_EQ(6, result.rows);
|
||||
}
|
||||
|
||||
TEST(Mat, regression_5917_clone_empty)
|
||||
{
|
||||
Mat cloned;
|
||||
Mat_<Point2f> source(5, 0);
|
||||
|
||||
ASSERT_NO_THROW(cloned = source.clone());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user