From ecc9bd0925cd15190495ee1f607fc2e4df7ebd07 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Mon, 17 Sep 2018 23:31:54 +0900 Subject: [PATCH] Support GpuMat in copyTo() functions --- modules/core/src/copy.cpp | 8 ++++++++ modules/core/src/matrix_wrap.cpp | 8 ++++++++ modules/core/src/umatrix.cpp | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 321c54b..38264cc 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -238,6 +238,14 @@ void Mat::copyTo( OutputArray _dst ) const { CV_INSTRUMENT_REGION(); +#ifdef HAVE_CUDA + if (_dst.isGpuMat()) + { + _dst.getGpuMat().upload(*this); + return; + } +#endif + int dtype = _dst.type(); if( _dst.fixedType() && dtype != type() ) { diff --git a/modules/core/src/matrix_wrap.cpp b/modules/core/src/matrix_wrap.cpp index b5b4514..e64d097 100644 --- a/modules/core/src/matrix_wrap.cpp +++ b/modules/core/src/matrix_wrap.cpp @@ -1146,6 +1146,10 @@ void _InputArray::copyTo(const _OutputArray& arr) const } else if( k == UMAT ) ((UMat*)obj)->copyTo(arr); +#ifdef HAVE_CUDA + else if (k == CUDA_GPU_MAT) + ((cuda::GpuMat*)obj)->copyTo(arr); +#endif else CV_Error(Error::StsNotImplemented, ""); } @@ -1163,6 +1167,10 @@ void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) cons } else if( k == UMAT ) ((UMat*)obj)->copyTo(arr, mask); +#ifdef HAVE_CUDA + else if (k == CUDA_GPU_MAT) + ((cuda::GpuMat*)obj)->copyTo(arr, mask); +#endif else CV_Error(Error::StsNotImplemented, ""); } diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index 248b679..27d587b 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -874,6 +874,14 @@ void UMat::copyTo(OutputArray _dst) const { CV_INSTRUMENT_REGION(); +#ifdef HAVE_CUDA + if (_dst.isGpuMat()) + { + _dst.getGpuMat().upload(*this); + return; + } +#endif + int dtype = _dst.type(); if( _dst.fixedType() && dtype != type() ) { -- 2.7.4