Merge pull request #11634 from vpisarev:empty_mat_with_types_2
fixes handling of empty matrices in some functions (#11634) * a part of PR #11416 by Yuki Takehara * moved the empty mat check in Mat::copyTo() * fixed some test failures
This commit is contained in:
committed by
Alexander Alekhin
parent
da75e463a8
commit
7d19bd6c19
@@ -1673,7 +1673,7 @@ Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
|
||||
{
|
||||
return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0));
|
||||
}
|
||||
CV_DbgAssert(DataType<_Tp>::channels == m.channels());
|
||||
CV_Assert(DataType<_Tp>::channels == m.channels() || m.empty());
|
||||
m.convertTo(*this, type());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1233,6 +1233,12 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
|
||||
CV_Assert( op == CMP_LT || op == CMP_LE || op == CMP_EQ ||
|
||||
op == CMP_NE || op == CMP_GE || op == CMP_GT );
|
||||
|
||||
if(_src1.empty() && _src2.empty())
|
||||
{
|
||||
_dst.release();
|
||||
return;
|
||||
}
|
||||
|
||||
bool haveScalar = false;
|
||||
|
||||
if ((_src1.isMatx() + _src2.isMatx()) == 1
|
||||
|
||||
@@ -1304,6 +1304,12 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
|
||||
if( empty() )
|
||||
{
|
||||
_dst.release();
|
||||
return;
|
||||
}
|
||||
|
||||
bool noScale = fabs(alpha-1) < DBL_EPSILON && fabs(beta) < DBL_EPSILON;
|
||||
|
||||
if( _type < 0 )
|
||||
|
||||
@@ -246,13 +246,14 @@ void Mat::copyTo( OutputArray _dst ) const
|
||||
return;
|
||||
}
|
||||
|
||||
if( empty() )
|
||||
{
|
||||
_dst.release();
|
||||
return;
|
||||
}
|
||||
|
||||
if( _dst.isUMat() )
|
||||
{
|
||||
if( empty() )
|
||||
{
|
||||
_dst.release();
|
||||
return;
|
||||
}
|
||||
_dst.create( dims, size.p, type() );
|
||||
UMat dst = _dst.getUMat();
|
||||
CV_Assert(dst.u != NULL);
|
||||
|
||||
Reference in New Issue
Block a user