/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.13// Copyright (C) 2009, Willow Garage Inc., all rights reserved.14// Third party copyrights are property of their respective owners.15//16// Redistribution and use in source and binary forms, with or without modification,17// are permitted provided that the following conditions are met:18//19// * Redistribution's of source code must retain the above copyright notice,20// this list of conditions and the following disclaimer.21//22// * Redistribution's in binary form must reproduce the above copyright notice,23// this list of conditions and the following disclaimer in the documentation24// and/or other materials provided with the distribution.25//26// * The name of the copyright holders may not be used to endorse or promote products27// derived from this software without specific prior written permission.28//29// This software is provided by the copyright holders and contributors "as is" and30// any express or implied warranties, including, but not limited to, the implied31// warranties of merchantability and fitness for a particular purpose are disclaimed.32// In no event shall the Intel Corporation or contributors be liable for any direct,33// indirect, incidental, special, exemplary, or consequential damages34// (including, but not limited to, procurement of substitute goods or services;35// loss of use, data, or profits; or business interruption) however caused36// and on any theory of liability, whether in contract, strict liability,37// or tort (including negligence or otherwise) arising in any way out of38// the use of this software, even if advised of the possibility of such damage.39//40//M*/4142#include "perf_precomp.hpp"4344#include "opencv2/photo/cuda.hpp"45#include "opencv2/ts/cuda_perf.hpp"4647#include "opencv2/opencv_modules.hpp"4849#if defined (HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAIMGPROC)5051namespace opencv_test { namespace {52using namespace perf;5354#define CUDA_DENOISING_IMAGE_SIZES testing::Values(perf::szVGA, perf::sz720p)5556//////////////////////////////////////////////////////////////////////57// nonLocalMeans5859DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);6061PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_NonLocalMeans,62Combine(CUDA_DENOISING_IMAGE_SIZES,63Values<MatDepth>(CV_8U),64CUDA_CHANNELS_1_3,65Values(21),66Values(5)))67{68declare.time(600.0);6970const cv::Size size = GET_PARAM(0);71const int depth = GET_PARAM(1);72const int channels = GET_PARAM(2);73const int search_widow_size = GET_PARAM(3);74const int block_size = GET_PARAM(4);7576const float h = 10;77const int borderMode = cv::BORDER_REFLECT101;7879const int type = CV_MAKE_TYPE(depth, channels);8081cv::Mat src(size, type);82declare.in(src, WARMUP_RNG);8384if (PERF_RUN_CUDA())85{86const cv::cuda::GpuMat d_src(src);87cv::cuda::GpuMat dst;8889TEST_CYCLE() cv::cuda::nonLocalMeans(d_src, dst, h, search_widow_size, block_size, borderMode);9091CUDA_SANITY_CHECK(dst);92}93else94{95FAIL_NO_CPU();96}97}9899100//////////////////////////////////////////////////////////////////////101// fastNonLocalMeans102103DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);104105PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_FastNonLocalMeans,106Combine(CUDA_DENOISING_IMAGE_SIZES,107Values<MatDepth>(CV_8U),108CUDA_CHANNELS_1_3,109Values(21),110Values(7)))111{112declare.time(60.0);113114const cv::Size size = GET_PARAM(0);115const int depth = GET_PARAM(1);116const int search_widow_size = GET_PARAM(2);117const int block_size = GET_PARAM(3);118119const float h = 10;120const int type = CV_MAKE_TYPE(depth, 1);121122cv::Mat src(size, type);123declare.in(src, WARMUP_RNG);124125if (PERF_RUN_CUDA())126{127const cv::cuda::GpuMat d_src(src);128cv::cuda::GpuMat dst;129130TEST_CYCLE() cv::cuda::fastNlMeansDenoising(d_src, dst, h, search_widow_size, block_size);131132CUDA_SANITY_CHECK(dst);133}134else135{136cv::Mat dst;137138TEST_CYCLE() cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);139140CPU_SANITY_CHECK(dst);141}142}143144//////////////////////////////////////////////////////////////////////145// fastNonLocalMeans (colored)146147DEF_PARAM_TEST(Sz_Depth_WinSz_BlockSz, cv::Size, MatDepth, int, int);148149PERF_TEST_P(Sz_Depth_WinSz_BlockSz, CUDA_FastNonLocalMeansColored,150Combine(CUDA_DENOISING_IMAGE_SIZES,151Values<MatDepth>(CV_8U),152Values(21),153Values(7)))154{155declare.time(60.0);156157const cv::Size size = GET_PARAM(0);158const int depth = GET_PARAM(1);159const int search_widow_size = GET_PARAM(2);160const int block_size = GET_PARAM(3);161162const float h = 10;163const int type = CV_MAKE_TYPE(depth, 3);164165cv::Mat src(size, type);166declare.in(src, WARMUP_RNG);167168if (PERF_RUN_CUDA())169{170const cv::cuda::GpuMat d_src(src);171cv::cuda::GpuMat dst;172173TEST_CYCLE() cv::cuda::fastNlMeansDenoisingColored(d_src, dst, h, h, search_widow_size, block_size);174175CUDA_SANITY_CHECK(dst);176}177else178{179cv::Mat dst;180181TEST_CYCLE() cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);182183CPU_SANITY_CHECK(dst);184}185}186187}} // namespace188#endif189190191