1
/*M///////////////////////////////////////////////////////////////////////////////////////
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11
// For Open Source Computer Vision Library
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.
17
// Redistribution and use in source and binary forms, with or without modification,
18
// are permitted provided that the following conditions are met:
20
// * Redistribution's of source code must retain the above copyright notice,
21
// this list of conditions and the following disclaimer.
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.
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.
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.
43
#include "perf_precomp.hpp"
46
using namespace testing;
49
#define ARITHM_MAT_DEPTH Values(CV_8U, CV_16U, CV_32F, CV_64F)
51
//////////////////////////////////////////////////////////////////////
54
PERF_TEST_P(Sz_Depth_Cn, Merge,
55
Combine(CUDA_TYPICAL_MAT_SIZES,
59
const cv::Size size = GET_PARAM(0);
60
const int depth = GET_PARAM(1);
61
const int channels = GET_PARAM(2);
63
std::vector<cv::Mat> src(channels);
64
for (int i = 0; i < channels; ++i)
66
src[i].create(size, depth);
67
declare.in(src[i], WARMUP_RNG);
72
std::vector<cv::cuda::GpuMat> d_src(channels);
73
for (int i = 0; i < channels; ++i)
74
d_src[i].upload(src[i]);
78
TEST_CYCLE() cv::cuda::merge(d_src, dst);
80
CUDA_SANITY_CHECK(dst, 1e-10);
86
TEST_CYCLE() cv::merge(src, dst);
88
CPU_SANITY_CHECK(dst);
92
//////////////////////////////////////////////////////////////////////
95
PERF_TEST_P(Sz_Depth_Cn, Split,
96
Combine(CUDA_TYPICAL_MAT_SIZES,
100
const cv::Size size = GET_PARAM(0);
101
const int depth = GET_PARAM(1);
102
const int channels = GET_PARAM(2);
104
cv::Mat src(size, CV_MAKE_TYPE(depth, channels));
105
declare.in(src, WARMUP_RNG);
109
const cv::cuda::GpuMat d_src(src);
110
std::vector<cv::cuda::GpuMat> dst;
112
TEST_CYCLE() cv::cuda::split(d_src, dst);
114
const cv::cuda::GpuMat& dst0 = dst[0];
115
const cv::cuda::GpuMat& dst1 = dst[1];
117
CUDA_SANITY_CHECK(dst0, 1e-10);
118
CUDA_SANITY_CHECK(dst1, 1e-10);
122
std::vector<cv::Mat> dst;
124
TEST_CYCLE() cv::split(src, dst);
126
const cv::Mat& dst0 = dst[0];
127
const cv::Mat& dst1 = dst[1];
129
CPU_SANITY_CHECK(dst0);
130
CPU_SANITY_CHECK(dst1);
134
//////////////////////////////////////////////////////////////////////
137
PERF_TEST_P(Sz_Type, Transpose,
138
Combine(CUDA_TYPICAL_MAT_SIZES,
139
Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1)))
141
const cv::Size size = GET_PARAM(0);
142
const int type = GET_PARAM(1);
144
cv::Mat src(size, type);
145
declare.in(src, WARMUP_RNG);
149
const cv::cuda::GpuMat d_src(src);
150
cv::cuda::GpuMat dst;
152
TEST_CYCLE() cv::cuda::transpose(d_src, dst);
154
CUDA_SANITY_CHECK(dst, 1e-10);
160
TEST_CYCLE() cv::transpose(src, dst);
162
CPU_SANITY_CHECK(dst);
166
//////////////////////////////////////////////////////////////////////
169
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
170
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
172
DEF_PARAM_TEST(Sz_Depth_Cn_Code, cv::Size, MatDepth, MatCn, FlipCode);
174
PERF_TEST_P(Sz_Depth_Cn_Code, Flip,
175
Combine(CUDA_TYPICAL_MAT_SIZES,
176
Values(CV_8U, CV_16U, CV_32F),
180
const cv::Size size = GET_PARAM(0);
181
const int depth = GET_PARAM(1);
182
const int channels = GET_PARAM(2);
183
const int flipCode = GET_PARAM(3);
185
const int type = CV_MAKE_TYPE(depth, channels);
187
cv::Mat src(size, type);
188
declare.in(src, WARMUP_RNG);
192
const cv::cuda::GpuMat d_src(src);
193
cv::cuda::GpuMat dst;
195
TEST_CYCLE() cv::cuda::flip(d_src, dst, flipCode);
197
CUDA_SANITY_CHECK(dst);
203
TEST_CYCLE() cv::flip(src, dst, flipCode);
205
CPU_SANITY_CHECK(dst);
209
//////////////////////////////////////////////////////////////////////
212
PERF_TEST_P(Sz_Type, LutOneChannel,
213
Combine(CUDA_TYPICAL_MAT_SIZES,
214
Values(CV_8UC1, CV_8UC3)))
216
const cv::Size size = GET_PARAM(0);
217
const int type = GET_PARAM(1);
219
cv::Mat src(size, type);
220
declare.in(src, WARMUP_RNG);
222
cv::Mat lut(1, 256, CV_8UC1);
223
declare.in(lut, WARMUP_RNG);
227
cv::Ptr<cv::cuda::LookUpTable> lutAlg = cv::cuda::createLookUpTable(lut);
229
const cv::cuda::GpuMat d_src(src);
230
cv::cuda::GpuMat dst;
232
TEST_CYCLE() lutAlg->transform(d_src, dst);
234
CUDA_SANITY_CHECK(dst);
240
TEST_CYCLE() cv::LUT(src, lut, dst);
242
CPU_SANITY_CHECK(dst);
246
//////////////////////////////////////////////////////////////////////
249
PERF_TEST_P(Sz_Type, LutMultiChannel,
250
Combine(CUDA_TYPICAL_MAT_SIZES,
251
Values<MatType>(CV_8UC3)))
253
const cv::Size size = GET_PARAM(0);
254
const int type = GET_PARAM(1);
256
cv::Mat src(size, type);
257
declare.in(src, WARMUP_RNG);
259
cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels()));
260
declare.in(lut, WARMUP_RNG);
264
cv::Ptr<cv::cuda::LookUpTable> lutAlg = cv::cuda::createLookUpTable(lut);
266
const cv::cuda::GpuMat d_src(src);
267
cv::cuda::GpuMat dst;
269
TEST_CYCLE() lutAlg->transform(d_src, dst);
271
CUDA_SANITY_CHECK(dst);
277
TEST_CYCLE() cv::LUT(src, lut, dst);
279
CPU_SANITY_CHECK(dst);
283
//////////////////////////////////////////////////////////////////////
286
DEF_PARAM_TEST(Sz_Depth_Cn_Border, cv::Size, MatDepth, MatCn, BorderMode);
288
PERF_TEST_P(Sz_Depth_Cn_Border, CopyMakeBorder,
289
Combine(CUDA_TYPICAL_MAT_SIZES,
290
Values(CV_8U, CV_16U, CV_32F),
294
const cv::Size size = GET_PARAM(0);
295
const int depth = GET_PARAM(1);
296
const int channels = GET_PARAM(2);
297
const int borderMode = GET_PARAM(3);
299
const int type = CV_MAKE_TYPE(depth, channels);
301
cv::Mat src(size, type);
302
declare.in(src, WARMUP_RNG);
306
const cv::cuda::GpuMat d_src(src);
307
cv::cuda::GpuMat dst;
309
TEST_CYCLE() cv::cuda::copyMakeBorder(d_src, dst, 5, 5, 5, 5, borderMode);
311
CUDA_SANITY_CHECK(dst);
317
TEST_CYCLE() cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);
319
CPU_SANITY_CHECK(dst);