From 3fb9c52272d2a9a585d13142847e0128871e25e5 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 31 Jul 2013 16:19:40 +0400 Subject: [PATCH] cast to reference --- modules/cudaarithm/src/cuda/minmax.cu | 9 ++------- modules/cudaarithm/src/cuda/sum.cu | 21 ++++++--------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/modules/cudaarithm/src/cuda/minmax.cu b/modules/cudaarithm/src/cuda/minmax.cu index eec861bdc..084bed870 100644 --- a/modules/cudaarithm/src/cuda/minmax.cu +++ b/modules/cudaarithm/src/cuda/minmax.cu @@ -64,8 +64,8 @@ namespace typename SelectIf::value, float, int>::type >::type work_type; - GpuMat_ src(_src); - GpuMat_ buf(_buf); + const GpuMat_& src = (const GpuMat_&) _src; + GpuMat_& buf = (GpuMat_&) _buf; if (mask.empty()) gridFindMinMaxVal(src, buf); @@ -103,11 +103,6 @@ void cv::cuda::minMax(InputArray _src, double* minVal, double* maxVal, InputArra CV_Assert( src.channels() == 1 ); CV_DbgAssert( mask.empty() || (mask.size() == src.size() && mask.type() == CV_8U) ); - const int depth = src.depth(); - - const int work_type = depth == CV_64F ? CV_64F : depth == CV_32F ? CV_32F : CV_32S; - ensureSizeIsEnough(1, 2, work_type, buf); - const func_t func = funcs[src.depth()]; func(src, mask, buf, minVal, maxVal); diff --git a/modules/cudaarithm/src/cuda/sum.cu b/modules/cudaarithm/src/cuda/sum.cu index ab900503c..cced9c56e 100644 --- a/modules/cudaarithm/src/cuda/sum.cu +++ b/modules/cudaarithm/src/cuda/sum.cu @@ -61,8 +61,8 @@ namespace typedef typename MakeVec::type src_type; typedef typename MakeVec::type res_type; - GpuMat_ src(_src); - GpuMat_ buf(_buf); + const GpuMat_& src = (const GpuMat_&) _src; + GpuMat_& buf = (GpuMat_&) _buf; if (mask.empty()) gridCalcSum(src, buf); @@ -82,8 +82,8 @@ namespace typedef typename MakeVec::type src_type; typedef typename MakeVec::type res_type; - GpuMat_ src(_src); - GpuMat_ buf(_buf); + const GpuMat_& src = (const GpuMat_&) _src; + GpuMat_& buf = (GpuMat_&) _buf; if (mask.empty()) gridCalcSum(abs_(cvt_(src)), buf); @@ -103,8 +103,8 @@ namespace typedef typename MakeVec::type src_type; typedef typename MakeVec::type res_type; - GpuMat_ src(_src); - GpuMat_ buf(_buf); + const GpuMat_& src = (const GpuMat_&) _src; + GpuMat_& buf = (GpuMat_&) _buf; if (mask.empty()) gridCalcSum(sqr_(cvt_(src)), buf); @@ -138,9 +138,6 @@ cv::Scalar cv::cuda::sum(InputArray _src, InputArray _mask, GpuMat& buf) CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) ); - const int res_depth = std::max(src.depth(), CV_32F); - cv::cuda::ensureSizeIsEnough(1, 1, CV_MAKE_TYPE(res_depth, src.channels()), buf); - const func_t func = funcs[src.depth()][src.channels() - 1]; return func(src, mask, buf); @@ -165,9 +162,6 @@ cv::Scalar cv::cuda::absSum(InputArray _src, InputArray _mask, GpuMat& buf) CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) ); - const int res_depth = std::max(src.depth(), CV_32F); - cv::cuda::ensureSizeIsEnough(1, 1, CV_MAKE_TYPE(res_depth, src.channels()), buf); - const func_t func = funcs[src.depth()][src.channels() - 1]; return func(src, mask, buf); @@ -192,9 +186,6 @@ cv::Scalar cv::cuda::sqrSum(InputArray _src, InputArray _mask, GpuMat& buf) CV_DbgAssert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == src.size()) ); - const int res_depth = CV_64F; - cv::cuda::ensureSizeIsEnough(1, 1, CV_MAKE_TYPE(res_depth, src.channels()), buf); - const func_t func = funcs[src.depth()][src.channels() - 1]; return func(src, mask, buf);