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
DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CvtColorInfo);
54
PERF_TEST_P(Sz_Depth_Code, CvtColor,
55
Combine(CUDA_TYPICAL_MAT_SIZES,
56
Values(CV_8U, CV_32F),
57
Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),
58
CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),
59
CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),
60
CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),
61
CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),
62
CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),
63
CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),
64
CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),
65
CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),
66
CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),
67
CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),
68
CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),
69
CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),
70
CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),
71
CvtColorInfo(3, 3, cv::COLOR_LBGR2Lab),
72
CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),
73
CvtColorInfo(3, 3, cv::COLOR_LBGR2Luv),
74
CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),
75
CvtColorInfo(3, 3, cv::COLOR_Lab2LBGR),
76
CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),
77
CvtColorInfo(3, 3, cv::COLOR_Luv2LRGB))))
79
const cv::Size size = GET_PARAM(0);
80
const int depth = GET_PARAM(1);
81
const CvtColorInfo info = GET_PARAM(2);
83
cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
84
cv::randu(src, 0, depth == CV_8U ? 255.0 : 1.0);
88
const cv::cuda::GpuMat d_src(src);
91
TEST_CYCLE() cv::cuda::cvtColor(d_src, dst, info.code, info.dcn);
93
CUDA_SANITY_CHECK(dst, 1e-4);
99
TEST_CYCLE() cv::cvtColor(src, dst, info.code, info.dcn);
101
CPU_SANITY_CHECK(dst);
105
PERF_TEST_P(Sz_Depth_Code, CvtColorBayer,
106
Combine(CUDA_TYPICAL_MAT_SIZES,
107
Values(CV_8U, CV_16U),
108
Values(CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR),
109
CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR),
110
CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR),
111
CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR),
113
CvtColorInfo(1, 1, cv::COLOR_BayerBG2GRAY),
114
CvtColorInfo(1, 1, cv::COLOR_BayerGB2GRAY),
115
CvtColorInfo(1, 1, cv::COLOR_BayerRG2GRAY),
116
CvtColorInfo(1, 1, cv::COLOR_BayerGR2GRAY))))
118
const cv::Size size = GET_PARAM(0);
119
const int depth = GET_PARAM(1);
120
const CvtColorInfo info = GET_PARAM(2);
122
cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
123
declare.in(src, WARMUP_RNG);
127
const cv::cuda::GpuMat d_src(src);
128
cv::cuda::GpuMat dst;
130
TEST_CYCLE() cv::cuda::cvtColor(d_src, dst, info.code, info.dcn);
132
CUDA_SANITY_CHECK(dst);
138
TEST_CYCLE() cv::cvtColor(src, dst, info.code, info.dcn);
140
CPU_SANITY_CHECK(dst);
144
//////////////////////////////////////////////////////////////////////
147
CV_ENUM(DemosaicingCode,
148
cv::COLOR_BayerBG2BGR, cv::COLOR_BayerGB2BGR, cv::COLOR_BayerRG2BGR, cv::COLOR_BayerGR2BGR,
149
cv::COLOR_BayerBG2GRAY, cv::COLOR_BayerGB2GRAY, cv::COLOR_BayerRG2GRAY, cv::COLOR_BayerGR2GRAY,
150
cv::cuda::COLOR_BayerBG2BGR_MHT, cv::cuda::COLOR_BayerGB2BGR_MHT, cv::cuda::COLOR_BayerRG2BGR_MHT, cv::cuda::COLOR_BayerGR2BGR_MHT,
151
cv::cuda::COLOR_BayerBG2GRAY_MHT, cv::cuda::COLOR_BayerGB2GRAY_MHT, cv::cuda::COLOR_BayerRG2GRAY_MHT, cv::cuda::COLOR_BayerGR2GRAY_MHT)
153
DEF_PARAM_TEST(Sz_Code, cv::Size, DemosaicingCode);
155
PERF_TEST_P(Sz_Code, Demosaicing,
156
Combine(CUDA_TYPICAL_MAT_SIZES,
157
DemosaicingCode::all()))
159
const cv::Size size = GET_PARAM(0);
160
const int code = GET_PARAM(1);
162
cv::Mat src(size, CV_8UC1);
163
declare.in(src, WARMUP_RNG);
167
const cv::cuda::GpuMat d_src(src);
168
cv::cuda::GpuMat dst;
170
TEST_CYCLE() cv::cuda::demosaicing(d_src, dst, code);
172
CUDA_SANITY_CHECK(dst);
176
if (code >= cv::COLOR_COLORCVT_MAX)
184
TEST_CYCLE() cv::cvtColor(src, dst, code);
186
CPU_SANITY_CHECK(dst);
191
//////////////////////////////////////////////////////////////////////
194
PERF_TEST_P(Sz, SwapChannels,
195
CUDA_TYPICAL_MAT_SIZES)
197
const cv::Size size = GetParam();
199
cv::Mat src(size, CV_8UC4);
200
declare.in(src, WARMUP_RNG);
202
const int dstOrder[] = {2, 1, 0, 3};
206
cv::cuda::GpuMat dst(src);
208
TEST_CYCLE() cv::cuda::swapChannels(dst, dstOrder);
210
CUDA_SANITY_CHECK(dst);
218
//////////////////////////////////////////////////////////////////////
221
CV_ENUM(AlphaOp, cv::cuda::ALPHA_OVER, cv::cuda::ALPHA_IN, cv::cuda::ALPHA_OUT, cv::cuda::ALPHA_ATOP, cv::cuda::ALPHA_XOR, cv::cuda::ALPHA_PLUS, cv::cuda::ALPHA_OVER_PREMUL, cv::cuda::ALPHA_IN_PREMUL, cv::cuda::ALPHA_OUT_PREMUL, cv::cuda::ALPHA_ATOP_PREMUL, cv::cuda::ALPHA_XOR_PREMUL, cv::cuda::ALPHA_PLUS_PREMUL, cv::cuda::ALPHA_PREMUL)
223
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp);
225
PERF_TEST_P(Sz_Type_Op, AlphaComp,
226
Combine(CUDA_TYPICAL_MAT_SIZES,
227
Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4),
230
const cv::Size size = GET_PARAM(0);
231
const int type = GET_PARAM(1);
232
const int alpha_op = GET_PARAM(2);
234
cv::Mat img1(size, type);
235
cv::Mat img2(size, type);
236
declare.in(img1, img2, WARMUP_RNG);
240
const cv::cuda::GpuMat d_img1(img1);
241
const cv::cuda::GpuMat d_img2(img2);
242
cv::cuda::GpuMat dst;
244
TEST_CYCLE() cv::cuda::alphaComp(d_img1, d_img2, dst, alpha_op);
246
// The function is a just wrapper for NPP. We can't control its results.
247
SANITY_CHECK_NOTHING();