mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
core: fix copyTo(with mask) dst initialization
This commit is contained in:
parent
b0bce60c16
commit
62ed6cdc74
@ -385,12 +385,21 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
|
|||||||
CV_Assert( size() == mask.size() );
|
CV_Assert( size() == mask.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar* data0 = _dst.getMat().data;
|
Mat dst;
|
||||||
_dst.create( dims, size, type() );
|
{
|
||||||
Mat dst = _dst.getMat();
|
Mat dst0 = _dst.getMat();
|
||||||
|
_dst.create(dims, size, type()); // TODO Prohibit 'dst' re-creation, user should pass it explicitly with correct size/type or empty
|
||||||
|
dst = _dst.getMat();
|
||||||
|
|
||||||
if( dst.data != data0 ) // do not leave dst uninitialized
|
if (dst.data != dst0.data) // re-allocation happened
|
||||||
dst = Scalar(0);
|
{
|
||||||
|
#ifdef OPENCV_FUTURE
|
||||||
|
CV_Assert(dst0.empty() &&
|
||||||
|
"copyTo(): dst size/type mismatch (looks like a bug) - use dst.release() before copyTo() call to suppress this message");
|
||||||
|
#endif
|
||||||
|
dst = Scalar(0); // do not leave dst uninitialized
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CV_IPP_RUN_FAST(ipp_copyTo(*this, dst, mask))
|
CV_IPP_RUN_FAST(ipp_copyTo(*this, dst, mask))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user