Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/photo/perf/perf_cuda.cpp
16337 views
1
/*M///////////////////////////////////////////////////////////////////////////////////////
2
//
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
//
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
8
//
9
//
10
// License Agreement
11
// For Open Source Computer Vision Library
12
//
13
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
// Third party copyrights are property of their respective owners.
16
//
17
// Redistribution and use in source and binary forms, with or without modification,
18
// are permitted provided that the following conditions are met:
19
//
20
// * Redistribution's of source code must retain the above copyright notice,
21
// this list of conditions and the following disclaimer.
22
//
23
// * Redistribution's in binary form must reproduce the above copyright notice,
24
// this list of conditions and the following disclaimer in the documentation
25
// and/or other materials provided with the distribution.
26
//
27
// * The name of the copyright holders may not be used to endorse or promote products
28
// derived from this software without specific prior written permission.
29
//
30
// This software is provided by the copyright holders and contributors "as is" and
31
// any express or implied warranties, including, but not limited to, the implied
32
// warranties of merchantability and fitness for a particular purpose are disclaimed.
33
// In no event shall the Intel Corporation or contributors be liable for any direct,
34
// indirect, incidental, special, exemplary, or consequential damages
35
// (including, but not limited to, procurement of substitute goods or services;
36
// loss of use, data, or profits; or business interruption) however caused
37
// and on any theory of liability, whether in contract, strict liability,
38
// or tort (including negligence or otherwise) arising in any way out of
39
// the use of this software, even if advised of the possibility of such damage.
40
//
41
//M*/
42
43
#include "perf_precomp.hpp"
44
45
#include "opencv2/photo/cuda.hpp"
46
#include "opencv2/ts/cuda_perf.hpp"
47
48
#include "opencv2/opencv_modules.hpp"
49
50
#if defined (HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAIMGPROC)
51
52
namespace opencv_test { namespace {
53
using namespace perf;
54
55
#define CUDA_DENOISING_IMAGE_SIZES testing::Values(perf::szVGA, perf::sz720p)
56
57
//////////////////////////////////////////////////////////////////////
58
// nonLocalMeans
59
60
DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
61
62
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_NonLocalMeans,
63
Combine(CUDA_DENOISING_IMAGE_SIZES,
64
Values<MatDepth>(CV_8U),
65
CUDA_CHANNELS_1_3,
66
Values(21),
67
Values(5)))
68
{
69
declare.time(600.0);
70
71
const cv::Size size = GET_PARAM(0);
72
const int depth = GET_PARAM(1);
73
const int channels = GET_PARAM(2);
74
const int search_widow_size = GET_PARAM(3);
75
const int block_size = GET_PARAM(4);
76
77
const float h = 10;
78
const int borderMode = cv::BORDER_REFLECT101;
79
80
const int type = CV_MAKE_TYPE(depth, channels);
81
82
cv::Mat src(size, type);
83
declare.in(src, WARMUP_RNG);
84
85
if (PERF_RUN_CUDA())
86
{
87
const cv::cuda::GpuMat d_src(src);
88
cv::cuda::GpuMat dst;
89
90
TEST_CYCLE() cv::cuda::nonLocalMeans(d_src, dst, h, search_widow_size, block_size, borderMode);
91
92
CUDA_SANITY_CHECK(dst);
93
}
94
else
95
{
96
FAIL_NO_CPU();
97
}
98
}
99
100
101
//////////////////////////////////////////////////////////////////////
102
// fastNonLocalMeans
103
104
DEF_PARAM_TEST(Sz_Depth_Cn_WinSz_BlockSz, cv::Size, MatDepth, MatCn, int, int);
105
106
PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_FastNonLocalMeans,
107
Combine(CUDA_DENOISING_IMAGE_SIZES,
108
Values<MatDepth>(CV_8U),
109
CUDA_CHANNELS_1_3,
110
Values(21),
111
Values(7)))
112
{
113
declare.time(60.0);
114
115
const cv::Size size = GET_PARAM(0);
116
const int depth = GET_PARAM(1);
117
const int search_widow_size = GET_PARAM(2);
118
const int block_size = GET_PARAM(3);
119
120
const float h = 10;
121
const int type = CV_MAKE_TYPE(depth, 1);
122
123
cv::Mat src(size, type);
124
declare.in(src, WARMUP_RNG);
125
126
if (PERF_RUN_CUDA())
127
{
128
const cv::cuda::GpuMat d_src(src);
129
cv::cuda::GpuMat dst;
130
131
TEST_CYCLE() cv::cuda::fastNlMeansDenoising(d_src, dst, h, search_widow_size, block_size);
132
133
CUDA_SANITY_CHECK(dst);
134
}
135
else
136
{
137
cv::Mat dst;
138
139
TEST_CYCLE() cv::fastNlMeansDenoising(src, dst, h, block_size, search_widow_size);
140
141
CPU_SANITY_CHECK(dst);
142
}
143
}
144
145
//////////////////////////////////////////////////////////////////////
146
// fastNonLocalMeans (colored)
147
148
DEF_PARAM_TEST(Sz_Depth_WinSz_BlockSz, cv::Size, MatDepth, int, int);
149
150
PERF_TEST_P(Sz_Depth_WinSz_BlockSz, CUDA_FastNonLocalMeansColored,
151
Combine(CUDA_DENOISING_IMAGE_SIZES,
152
Values<MatDepth>(CV_8U),
153
Values(21),
154
Values(7)))
155
{
156
declare.time(60.0);
157
158
const cv::Size size = GET_PARAM(0);
159
const int depth = GET_PARAM(1);
160
const int search_widow_size = GET_PARAM(2);
161
const int block_size = GET_PARAM(3);
162
163
const float h = 10;
164
const int type = CV_MAKE_TYPE(depth, 3);
165
166
cv::Mat src(size, type);
167
declare.in(src, WARMUP_RNG);
168
169
if (PERF_RUN_CUDA())
170
{
171
const cv::cuda::GpuMat d_src(src);
172
cv::cuda::GpuMat dst;
173
174
TEST_CYCLE() cv::cuda::fastNlMeansDenoisingColored(d_src, dst, h, h, search_widow_size, block_size);
175
176
CUDA_SANITY_CHECK(dst);
177
}
178
else
179
{
180
cv::Mat dst;
181
182
TEST_CYCLE() cv::fastNlMeansDenoisingColored(src, dst, h, h, block_size, search_widow_size);
183
184
CPU_SANITY_CHECK(dst);
185
}
186
}
187
188
}} // namespace
189
#endif
190
191