From 7b90a1e85ad42054f2e19ecc54e853678c39888a Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Tue, 21 Aug 2018 14:46:00 +0900 Subject: [PATCH] Closes #6349 - a bug in cuda::meanShiftSegmentation --- modules/cudaimgproc/include/opencv2/cudaimgproc.hpp | 2 +- modules/cudaimgproc/src/mssegmentation.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp b/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp index a0731121e4..b558610690 100644 --- a/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp +++ b/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp @@ -639,7 +639,7 @@ CV_EXPORTS void meanShiftProc(InputArray src, OutputArray dstr, OutputArray dsts /** @brief Performs a mean-shift segmentation of the source image and eliminates small segments. @param src Source image. Only CV_8UC4 images are supported for now. -@param dst Segmented image with the same size and type as src (host memory). +@param dst Segmented image with the same size and type as src (host or gpu memory). @param sp Spatial window radius. @param sr Color window radius. @param minsize Minimum segment size. Smaller segments are merged. diff --git a/modules/cudaimgproc/src/mssegmentation.cpp b/modules/cudaimgproc/src/mssegmentation.cpp index 2bc071813e..de8ed84146 100644 --- a/modules/cudaimgproc/src/mssegmentation.cpp +++ b/modules/cudaimgproc/src/mssegmentation.cpp @@ -372,8 +372,7 @@ void cv::cuda::meanShiftSegmentation(InputArray _src, OutputArray _dst, int sp, } // Create final image, color of each segment is the average color of its pixels - _dst.create(src.size(), src.type()); - Mat dst = _dst.getMat(); + Mat dst(src.size(), src.type()); for (int y = 0; y < nrows; ++y) { @@ -389,6 +388,7 @@ void cv::cuda::meanShiftSegmentation(InputArray _src, OutputArray _dst, int sp, dstcol[3] = 255; } } + dst.copyTo(_dst); } #endif // #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)