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
//////////////////////////////////////////////////////////////////////
52
enum { HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH };
53
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH)
55
void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode)
57
for (int j = 0; j < map_x.rows; ++j)
59
for (int i = 0; i < map_x.cols; ++i)
64
if (i > map_x.cols*0.25 && i < map_x.cols*0.75 && j > map_x.rows*0.25 && j < map_x.rows*0.75)
66
map_x.at<float>(j,i) = 2.f * (i - map_x.cols * 0.25f) + 0.5f;
67
map_y.at<float>(j,i) = 2.f * (j - map_x.rows * 0.25f) + 0.5f;
71
map_x.at<float>(j,i) = 0.f;
72
map_y.at<float>(j,i) = 0.f;
76
map_x.at<float>(j,i) = static_cast<float>(i);
77
map_y.at<float>(j,i) = static_cast<float>(map_x.rows - j);
80
map_x.at<float>(j,i) = static_cast<float>(map_x.cols - i);
81
map_y.at<float>(j,i) = static_cast<float>(j);
84
map_x.at<float>(j,i) = static_cast<float>(map_x.cols - i);
85
map_y.at<float>(j,i) = static_cast<float>(map_x.rows - j);
92
DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border_Mode, cv::Size, MatDepth, MatCn, Interpolation, BorderMode, RemapMode);
94
PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, Remap,
95
Combine(CUDA_TYPICAL_MAT_SIZES,
96
Values(CV_8U, CV_16U, CV_32F),
98
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
104
const cv::Size size = GET_PARAM(0);
105
const int depth = GET_PARAM(1);
106
const int channels = GET_PARAM(2);
107
const int interpolation = GET_PARAM(3);
108
const int borderMode = GET_PARAM(4);
109
const int remapMode = GET_PARAM(5);
111
const int type = CV_MAKE_TYPE(depth, channels);
113
cv::Mat src(size, type);
114
declare.in(src, WARMUP_RNG);
116
cv::Mat xmap(size, CV_32FC1);
117
cv::Mat ymap(size, CV_32FC1);
118
generateMap(xmap, ymap, remapMode);
122
const cv::cuda::GpuMat d_src(src);
123
const cv::cuda::GpuMat d_xmap(xmap);
124
const cv::cuda::GpuMat d_ymap(ymap);
125
cv::cuda::GpuMat dst;
127
TEST_CYCLE() cv::cuda::remap(d_src, dst, d_xmap, d_ymap, interpolation, borderMode);
129
CUDA_SANITY_CHECK(dst);
135
TEST_CYCLE() cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
137
CPU_SANITY_CHECK(dst);
141
//////////////////////////////////////////////////////////////////////
144
DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Scale, cv::Size, MatDepth, MatCn, Interpolation, double);
146
PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, Resize,
147
Combine(CUDA_TYPICAL_MAT_SIZES,
148
Values(CV_8U, CV_16U, CV_32F),
150
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
151
Values(0.5, 0.3, 2.0)))
155
const cv::Size size = GET_PARAM(0);
156
const int depth = GET_PARAM(1);
157
const int channels = GET_PARAM(2);
158
const int interpolation = GET_PARAM(3);
159
const double f = GET_PARAM(4);
161
const int type = CV_MAKE_TYPE(depth, channels);
163
cv::Mat src(size, type);
164
declare.in(src, WARMUP_RNG);
168
const cv::cuda::GpuMat d_src(src);
169
cv::cuda::GpuMat dst;
171
TEST_CYCLE() cv::cuda::resize(d_src, dst, cv::Size(), f, f, interpolation);
173
CUDA_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
179
TEST_CYCLE() cv::resize(src, dst, cv::Size(), f, f, interpolation);
181
CPU_SANITY_CHECK(dst);
185
//////////////////////////////////////////////////////////////////////
188
DEF_PARAM_TEST(Sz_Depth_Cn_Scale, cv::Size, MatDepth, MatCn, double);
190
PERF_TEST_P(Sz_Depth_Cn_Scale, ResizeArea,
191
Combine(CUDA_TYPICAL_MAT_SIZES,
192
Values(CV_8U, CV_16U, CV_32F),
194
Values(0.2, 0.1, 0.05)))
198
const cv::Size size = GET_PARAM(0);
199
const int depth = GET_PARAM(1);
200
const int channels = GET_PARAM(2);
201
const int interpolation = cv::INTER_AREA;
202
const double f = GET_PARAM(3);
204
const int type = CV_MAKE_TYPE(depth, channels);
206
cv::Mat src(size, type);
207
declare.in(src, WARMUP_RNG);
211
const cv::cuda::GpuMat d_src(src);
212
cv::cuda::GpuMat dst;
214
TEST_CYCLE() cv::cuda::resize(d_src, dst, cv::Size(), f, f, interpolation);
216
CUDA_SANITY_CHECK(dst);
222
TEST_CYCLE() cv::resize(src, dst, cv::Size(), f, f, interpolation);
224
CPU_SANITY_CHECK(dst);
228
//////////////////////////////////////////////////////////////////////
231
DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border, cv::Size, MatDepth, MatCn, Interpolation, BorderMode);
233
PERF_TEST_P(Sz_Depth_Cn_Inter_Border, WarpAffine,
234
Combine(CUDA_TYPICAL_MAT_SIZES,
235
Values(CV_8U, CV_16U, CV_32F),
237
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
242
const cv::Size size = GET_PARAM(0);
243
const int depth = GET_PARAM(1);
244
const int channels = GET_PARAM(2);
245
const int interpolation = GET_PARAM(3);
246
const int borderMode = GET_PARAM(4);
248
const int type = CV_MAKE_TYPE(depth, channels);
250
cv::Mat src(size, type);
251
declare.in(src, WARMUP_RNG);
253
const double aplha = CV_PI / 4;
254
const double mat[2 * 3] =
256
std::cos(aplha), -std::sin(aplha), static_cast<double>(src.cols) / 2.0,
257
std::sin(aplha), std::cos(aplha), 0
259
const cv::Mat M(2, 3, CV_64F, (void*) mat);
263
const cv::cuda::GpuMat d_src(src);
264
cv::cuda::GpuMat dst;
266
TEST_CYCLE() cv::cuda::warpAffine(d_src, dst, M, size, interpolation, borderMode);
268
CUDA_SANITY_CHECK(dst, 1);
274
TEST_CYCLE() cv::warpAffine(src, dst, M, size, interpolation, borderMode);
276
CPU_SANITY_CHECK(dst);
280
//////////////////////////////////////////////////////////////////////
283
PERF_TEST_P(Sz_Depth_Cn_Inter_Border, WarpPerspective,
284
Combine(CUDA_TYPICAL_MAT_SIZES,
285
Values(CV_8U, CV_16U, CV_32F),
287
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
292
const cv::Size size = GET_PARAM(0);
293
const int depth = GET_PARAM(1);
294
const int channels = GET_PARAM(2);
295
const int interpolation = GET_PARAM(3);
296
const int borderMode = GET_PARAM(4);
298
const int type = CV_MAKE_TYPE(depth, channels);
300
cv::Mat src(size, type);
301
declare.in(src, WARMUP_RNG);
303
const double aplha = CV_PI / 4;
304
double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), static_cast<double>(src.cols) / 2.0},
305
{std::sin(aplha), std::cos(aplha), 0},
307
const cv::Mat M(3, 3, CV_64F, (void*) mat);
311
const cv::cuda::GpuMat d_src(src);
312
cv::cuda::GpuMat dst;
314
TEST_CYCLE() cv::cuda::warpPerspective(d_src, dst, M, size, interpolation, borderMode);
316
CUDA_SANITY_CHECK(dst, 1);
322
TEST_CYCLE() cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
324
CPU_SANITY_CHECK(dst);
328
//////////////////////////////////////////////////////////////////////
331
DEF_PARAM_TEST(Sz_Depth_Cn_Inter, cv::Size, MatDepth, MatCn, Interpolation);
333
PERF_TEST_P(Sz_Depth_Cn_Inter, Rotate,
334
Combine(CUDA_TYPICAL_MAT_SIZES,
335
Values(CV_8U, CV_16U, CV_32F),
337
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))))
339
const cv::Size size = GET_PARAM(0);
340
const int depth = GET_PARAM(1);
341
const int channels = GET_PARAM(2);
342
const int interpolation = GET_PARAM(3);
344
const int type = CV_MAKE_TYPE(depth, channels);
346
cv::Mat src(size, type);
347
declare.in(src, WARMUP_RNG);
351
const cv::cuda::GpuMat d_src(src);
352
cv::cuda::GpuMat dst;
354
TEST_CYCLE() cv::cuda::rotate(d_src, dst, size, 30.0, 0, 0, interpolation);
356
CUDA_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
364
//////////////////////////////////////////////////////////////////////
367
PERF_TEST_P(Sz_Depth_Cn, PyrDown,
368
Combine(CUDA_TYPICAL_MAT_SIZES,
369
Values(CV_8U, CV_16U, CV_32F),
370
CUDA_CHANNELS_1_3_4))
372
const cv::Size size = GET_PARAM(0);
373
const int depth = GET_PARAM(1);
374
const int channels = GET_PARAM(2);
376
const int type = CV_MAKE_TYPE(depth, channels);
378
cv::Mat src(size, type);
379
declare.in(src, WARMUP_RNG);
383
const cv::cuda::GpuMat d_src(src);
384
cv::cuda::GpuMat dst;
386
TEST_CYCLE() cv::cuda::pyrDown(d_src, dst);
388
CUDA_SANITY_CHECK(dst);
394
TEST_CYCLE() cv::pyrDown(src, dst);
396
CPU_SANITY_CHECK(dst);
400
//////////////////////////////////////////////////////////////////////
403
PERF_TEST_P(Sz_Depth_Cn, PyrUp,
404
Combine(CUDA_TYPICAL_MAT_SIZES,
405
Values(CV_8U, CV_16U, CV_32F),
406
CUDA_CHANNELS_1_3_4))
408
const cv::Size size = GET_PARAM(0);
409
const int depth = GET_PARAM(1);
410
const int channels = GET_PARAM(2);
412
const int type = CV_MAKE_TYPE(depth, channels);
414
cv::Mat src(size, type);
415
declare.in(src, WARMUP_RNG);
419
const cv::cuda::GpuMat d_src(src);
420
cv::cuda::GpuMat dst;
422
TEST_CYCLE() cv::cuda::pyrUp(d_src, dst);
424
CUDA_SANITY_CHECK(dst);
430
TEST_CYCLE() cv::pyrUp(src, dst);
432
CPU_SANITY_CHECK(dst);