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 PERF_TEST_P(Sz_Depth, HistEvenC1,
53 Combine(CUDA_TYPICAL_MAT_SIZES,
54 Values(CV_8U, CV_16U, CV_16S)))
56 const cv::Size size = GET_PARAM(0);
57 const int depth = GET_PARAM(1);
59 cv::Mat src(size, depth);
60 declare.in(src, WARMUP_RNG);
64 const cv::cuda::GpuMat d_src(src);
66 cv::cuda::GpuMat d_buf;
68 TEST_CYCLE() cv::cuda::histEven(d_src, dst, d_buf, 30, 0, 180);
70 CUDA_SANITY_CHECK(dst);
75 const float hranges[] = {0.0f, 180.0f};
76 const int histSize[] = {hbins};
77 const float* ranges[] = {hranges};
78 const int channels[] = {0};
82 TEST_CYCLE() cv::calcHist(&src, 1, channels, cv::Mat(), dst, 1, histSize, ranges);
84 CPU_SANITY_CHECK(dst);
88 //////////////////////////////////////////////////////////////////////
91 PERF_TEST_P(Sz_Depth, HistEvenC4,
92 Combine(CUDA_TYPICAL_MAT_SIZES,
93 Values(CV_8U, CV_16U, CV_16S)))
95 const cv::Size size = GET_PARAM(0);
96 const int depth = GET_PARAM(1);
98 cv::Mat src(size, CV_MAKE_TYPE(depth, 4));
99 declare.in(src, WARMUP_RNG);
101 int histSize[] = {30, 30, 30, 30};
102 int lowerLevel[] = {0, 0, 0, 0};
103 int upperLevel[] = {180, 180, 180, 180};
107 const cv::cuda::GpuMat d_src(src);
108 cv::cuda::GpuMat d_hist[4];
109 cv::cuda::GpuMat d_buf;
111 TEST_CYCLE() cv::cuda::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
113 cv::Mat cpu_hist0, cpu_hist1, cpu_hist2, cpu_hist3;
114 d_hist[0].download(cpu_hist0);
115 d_hist[1].download(cpu_hist1);
116 d_hist[2].download(cpu_hist2);
117 d_hist[3].download(cpu_hist3);
118 SANITY_CHECK(cpu_hist0);
119 SANITY_CHECK(cpu_hist1);
120 SANITY_CHECK(cpu_hist2);
121 SANITY_CHECK(cpu_hist3);
129 //////////////////////////////////////////////////////////////////////
132 PERF_TEST_P(Sz, CalcHist,
133 CUDA_TYPICAL_MAT_SIZES)
135 const cv::Size size = GetParam();
137 cv::Mat src(size, CV_8UC1);
138 declare.in(src, WARMUP_RNG);
142 const cv::cuda::GpuMat d_src(src);
143 cv::cuda::GpuMat dst;
145 TEST_CYCLE() cv::cuda::calcHist(d_src, dst);
147 CUDA_SANITY_CHECK(dst);
155 //////////////////////////////////////////////////////////////////////
158 PERF_TEST_P(Sz, EqualizeHist,
159 CUDA_TYPICAL_MAT_SIZES)
161 const cv::Size size = GetParam();
163 cv::Mat src(size, CV_8UC1);
164 declare.in(src, WARMUP_RNG);
168 const cv::cuda::GpuMat d_src(src);
169 cv::cuda::GpuMat dst;
170 cv::cuda::GpuMat d_buf;
172 TEST_CYCLE() cv::cuda::equalizeHist(d_src, dst, d_buf);
174 CUDA_SANITY_CHECK(dst);
180 TEST_CYCLE() cv::equalizeHist(src, dst);
182 CPU_SANITY_CHECK(dst);
186 //////////////////////////////////////////////////////////////////////
189 DEF_PARAM_TEST(Sz_ClipLimit, cv::Size, double);
191 PERF_TEST_P(Sz_ClipLimit, CLAHE,
192 Combine(CUDA_TYPICAL_MAT_SIZES,
195 const cv::Size size = GET_PARAM(0);
196 const double clipLimit = GET_PARAM(1);
198 cv::Mat src(size, CV_8UC1);
199 declare.in(src, WARMUP_RNG);
203 cv::Ptr<cv::cuda::CLAHE> clahe = cv::cuda::createCLAHE(clipLimit);
204 cv::cuda::GpuMat d_src(src);
205 cv::cuda::GpuMat dst;
207 TEST_CYCLE() clahe->apply(d_src, dst);
209 CUDA_SANITY_CHECK(dst);
213 cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit);
216 TEST_CYCLE() clahe->apply(src, dst);
218 CPU_SANITY_CHECK(dst);