Support GpuMat in copyTo() functions
authorHamdi Sahloul <hamdisahloul@hotmail.com>
Mon, 17 Sep 2018 14:31:54 +0000 (23:31 +0900)
committerHamdi Sahloul <hamdisahloul@hotmail.com>
Mon, 17 Sep 2018 14:43:14 +0000 (23:43 +0900)
modules/core/src/copy.cpp
modules/core/src/matrix_wrap.cpp
modules/core/src/umatrix.cpp

index 321c54b..38264cc 100644 (file)
@@ -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() )
     {
index b5b4514..e64d097 100644 (file)
@@ -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, "");
 }
index 248b679..27d587b 100644 (file)
@@ -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() )
     {