diff --git a/modules/cudaarithm/src/arithm.cpp b/modules/cudaarithm/src/arithm.cpp index b2107dd1f..08de4e428 100644 --- a/modules/cudaarithm/src/arithm.cpp +++ b/modules/cudaarithm/src/arithm.cpp @@ -315,13 +315,20 @@ void cv::cuda::dft(InputArray _src, OutputArray _dst, Size dft_size, int flags, // We don't support real-to-real transform CV_Assert( is_complex_input || is_complex_output ); - GpuMat src_cont = src; - // Make sure here we work with the continuous input, // as CUFFT can't handle gaps - createContinuous(src.rows, src.cols, src.type(), src_cont); - if (src_cont.data != src.data) + GpuMat src_cont; + if (src.isContinuous()) + { + src_cont = src; + } + else + { + BufferPool pool(stream); + src_cont.allocator = pool.getAllocator(); + createContinuous(src.rows, src.cols, src.type(), src_cont); src.copyTo(src_cont, stream); + } Size dft_size_opt = dft_size; if (is_1d_input && !is_row_dft) diff --git a/modules/cudaarithm/src/cuda/integral.cu b/modules/cudaarithm/src/cuda/integral.cu index db554eb30..4a70ab0de 100644 --- a/modules/cudaarithm/src/cuda/integral.cu +++ b/modules/cudaarithm/src/cuda/integral.cu @@ -50,51 +50,58 @@ #include "opencv2/cudaarithm.hpp" #include "opencv2/cudev.hpp" +#include "opencv2/core/private.cuda.hpp" +using namespace cv; +using namespace cv::cuda; using namespace cv::cudev; //////////////////////////////////////////////////////////////////////// // integral -void cv::cuda::integral(InputArray _src, OutputArray _dst, GpuMat& buffer, Stream& stream) +void cv::cuda::integral(InputArray _src, OutputArray _dst, Stream& stream) { - GpuMat src = _src.getGpuMat(); + GpuMat src = getInputMat(_src, stream); CV_Assert( src.type() == CV_8UC1 ); - GpuMat_& res = (GpuMat_&) buffer; + BufferPool pool(stream); + GpuMat_ res(src.size(), pool.getAllocator()); gridIntegral(globPtr(src), res, stream); - _dst.create(src.rows + 1, src.cols + 1, CV_32SC1); - GpuMat dst = _dst.getGpuMat(); + GpuMat dst = getOutputMat(_dst, src.rows + 1, src.cols + 1, CV_32SC1, stream); dst.setTo(Scalar::all(0), stream); GpuMat inner = dst(Rect(1, 1, src.cols, src.rows)); res.copyTo(inner, stream); + + syncOutput(dst, _dst, stream); } ////////////////////////////////////////////////////////////////////////////// // sqrIntegral -void cv::cuda::sqrIntegral(InputArray _src, OutputArray _dst, GpuMat& buf, Stream& stream) +void cv::cuda::sqrIntegral(InputArray _src, OutputArray _dst, Stream& stream) { - GpuMat src = _src.getGpuMat(); + GpuMat src = getInputMat(_src, stream); CV_Assert( src.type() == CV_8UC1 ); - GpuMat_& res = (GpuMat_&) buf; + BufferPool pool(Stream::Null()); + GpuMat_ res(pool.getBuffer(src.size(), CV_64FC1)); gridIntegral(sqr_(cvt_(globPtr(src))), res, stream); - _dst.create(src.rows + 1, src.cols + 1, CV_64FC1); - GpuMat dst = _dst.getGpuMat(); + GpuMat dst = getOutputMat(_dst, src.rows + 1, src.cols + 1, CV_64FC1, stream); dst.setTo(Scalar::all(0), stream); GpuMat inner = dst(Rect(1, 1, src.cols, src.rows)); res.copyTo(inner, stream); + + syncOutput(dst, _dst, stream); } #endif