Support GpuMat in copyTo() functions

This commit is contained in:
Hamdi Sahloul 2018-09-17 23:31:54 +09:00
parent 3512cb2226
commit ecc9bd0925
3 changed files with 24 additions and 0 deletions

View File

@ -238,6 +238,14 @@ void Mat::copyTo( OutputArray _dst ) const
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
#ifdef HAVE_CUDA
if (_dst.isGpuMat())
{
_dst.getGpuMat().upload(*this);
return;
}
#endif
int dtype = _dst.type(); int dtype = _dst.type();
if( _dst.fixedType() && dtype != type() ) if( _dst.fixedType() && dtype != type() )
{ {

View File

@ -1146,6 +1146,10 @@ void _InputArray::copyTo(const _OutputArray& arr) const
} }
else if( k == UMAT ) else if( k == UMAT )
((UMat*)obj)->copyTo(arr); ((UMat*)obj)->copyTo(arr);
#ifdef HAVE_CUDA
else if (k == CUDA_GPU_MAT)
((cuda::GpuMat*)obj)->copyTo(arr);
#endif
else else
CV_Error(Error::StsNotImplemented, ""); CV_Error(Error::StsNotImplemented, "");
} }
@ -1163,6 +1167,10 @@ void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) cons
} }
else if( k == UMAT ) else if( k == UMAT )
((UMat*)obj)->copyTo(arr, mask); ((UMat*)obj)->copyTo(arr, mask);
#ifdef HAVE_CUDA
else if (k == CUDA_GPU_MAT)
((cuda::GpuMat*)obj)->copyTo(arr, mask);
#endif
else else
CV_Error(Error::StsNotImplemented, ""); CV_Error(Error::StsNotImplemented, "");
} }

View File

@ -874,6 +874,14 @@ void UMat::copyTo(OutputArray _dst) const
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
#ifdef HAVE_CUDA
if (_dst.isGpuMat())
{
_dst.getGpuMat().upload(*this);
return;
}
#endif
int dtype = _dst.type(); int dtype = _dst.type();
if( _dst.fixedType() && dtype != type() ) if( _dst.fixedType() && dtype != type() )
{ {