From 1bf811c3f187f5aea08eeb868bca2ee0cf8ad532 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 2 Oct 2015 11:41:01 +0300 Subject: [PATCH] fix cuda::normalize (dtype < 0) case --- modules/cudaarithm/src/cuda/normalize.cu | 4 ++++ modules/cudaarithm/test/test_reductions.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/cudaarithm/src/cuda/normalize.cu b/modules/cudaarithm/src/cuda/normalize.cu index efbc94ecc..c83f2c0df 100644 --- a/modules/cudaarithm/src/cuda/normalize.cu +++ b/modules/cudaarithm/src/cuda/normalize.cu @@ -249,6 +249,10 @@ void cv::cuda::normalize(InputArray _src, OutputArray _dst, double a, double b, CV_Assert( src.channels() == 1 ); CV_Assert( mask.empty() || (mask.size() == src.size() && mask.type() == CV_8U) ); + if (dtype < 0) + { + dtype = _dst.fixedType() ? _dst.type() : src.type(); + } dtype = CV_MAT_DEPTH(dtype); const int src_depth = src.depth(); diff --git a/modules/cudaarithm/test/test_reductions.cpp b/modules/cudaarithm/test/test_reductions.cpp index 9a8854939..a0ff0dfa4 100644 --- a/modules/cudaarithm/test/test_reductions.cpp +++ b/modules/cudaarithm/test/test_reductions.cpp @@ -951,11 +951,11 @@ CUDA_TEST_P(Normalize, WithMask) cv::cuda::GpuMat dst = createMat(size, type, useRoi); dst.setTo(cv::Scalar::all(0)); - cv::cuda::normalize(loadMat(src, useRoi), dst, alpha, beta, norm_type, type, loadMat(mask, useRoi)); + cv::cuda::normalize(loadMat(src, useRoi), dst, alpha, beta, norm_type, -1, loadMat(mask, useRoi)); cv::Mat dst_gold(size, type); dst_gold.setTo(cv::Scalar::all(0)); - cv::normalize(src, dst_gold, alpha, beta, norm_type, type, mask); + cv::normalize(src, dst_gold, alpha, beta, norm_type, -1, mask); EXPECT_MAT_NEAR(dst_gold, dst, type < CV_32F ? 1.0 : 1e-4); }