parent
04ae46e21c
commit
f61597dce8
1 changed files with 231 additions and 0 deletions
@ -0,0 +1,231 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp" |
||||
#include "opencv2/ts/ocl_perf.hpp" |
||||
|
||||
#ifdef HAVE_OPENCL |
||||
|
||||
namespace cvtest { |
||||
namespace ocl { |
||||
|
||||
///////////// Blur ////////////////////////
|
||||
|
||||
typedef Size_MatType BlurFixture; |
||||
|
||||
OCL_PERF_TEST_P(BlurFixture, Blur, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params), ksize(3, 3); |
||||
const int type = get<1>(params), bordertype = BORDER_CONSTANT; |
||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type); |
||||
declare.in(src, WARMUP_RNG).out(dst); |
||||
|
||||
OCL_TEST_CYCLE() cv::blur(src, dst, ksize, Point(-1, -1), bordertype); |
||||
|
||||
SANITY_CHECK(dst, eps); |
||||
} |
||||
|
||||
///////////// Laplacian////////////////////////
|
||||
|
||||
typedef Size_MatType LaplacianFixture; |
||||
|
||||
OCL_PERF_TEST_P(LaplacianFixture, Laplacian, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params); |
||||
const int type = get<1>(params), ksize = 3; |
||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type); |
||||
declare.in(src, WARMUP_RNG).out(dst); |
||||
|
||||
OCL_TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize, 1); |
||||
|
||||
SANITY_CHECK(dst, eps); |
||||
} |
||||
|
||||
///////////// Erode ////////////////////
|
||||
|
||||
typedef Size_MatType ErodeFixture; |
||||
|
||||
OCL_PERF_TEST_P(ErodeFixture, Erode, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params); |
||||
const int type = get<1>(params), ksize = 3; |
||||
const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type); |
||||
declare.in(src, WARMUP_RNG).out(dst).in(ker); |
||||
|
||||
OCL_TEST_CYCLE() cv::erode(src, dst, ker); |
||||
|
||||
SANITY_CHECK(dst); |
||||
} |
||||
|
||||
///////////// Sobel ////////////////////////
|
||||
|
||||
typedef Size_MatType SobelFixture; |
||||
|
||||
OCL_PERF_TEST_P(SobelFixture, Sobel, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params); |
||||
const int type = get<1>(params), dx = 1, dy = 1; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type); |
||||
declare.in(src, WARMUP_RNG).out(dst); |
||||
|
||||
OCL_TEST_CYCLE() cv::Sobel(src, dst, -1, dx, dy); |
||||
|
||||
SANITY_CHECK(dst); |
||||
} |
||||
|
||||
///////////// Scharr ////////////////////////
|
||||
|
||||
typedef Size_MatType ScharrFixture; |
||||
|
||||
OCL_PERF_TEST_P(ScharrFixture, Scharr, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params); |
||||
const int type = get<1>(params), dx = 1, dy = 0; |
||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type); |
||||
declare.in(src, WARMUP_RNG).out(dst); |
||||
|
||||
OCL_TEST_CYCLE() cv::Scharr(src, dst, -1, dx, dy); |
||||
|
||||
SANITY_CHECK(dst, eps); |
||||
} |
||||
|
||||
///////////// GaussianBlur ////////////////////////
|
||||
|
||||
typedef Size_MatType GaussianBlurFixture; |
||||
|
||||
OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params); |
||||
const int type = get<1>(params), ksize = 7; |
||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 + DBL_EPSILON : 3e-4; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type); |
||||
declare.in(src, WARMUP_RNG).out(dst); |
||||
|
||||
OCL_TEST_CYCLE() cv::GaussianBlur(src, dst, Size(ksize, ksize), 0); |
||||
|
||||
SANITY_CHECK(dst, eps); |
||||
} |
||||
|
||||
///////////// Filter2D ////////////////////////
|
||||
|
||||
typedef Size_MatType Filter2DFixture; |
||||
|
||||
OCL_PERF_TEST_P(Filter2DFixture, Filter2D, |
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) |
||||
{ |
||||
const Size_MatType_t params = GetParam(); |
||||
const Size srcSize = get<0>(params); |
||||
const int type = get<1>(params), ksize = 3; |
||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type); |
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type), kernel(ksize, ksize, CV_32SC1); |
||||
declare.in(src, WARMUP_RNG).in(kernel).out(dst); |
||||
randu(kernel, -3.0, 3.0); |
||||
|
||||
OCL_TEST_CYCLE() cv::filter2D(src, dst, -1, kernel); |
||||
|
||||
SANITY_CHECK(dst, eps); |
||||
} |
||||
|
||||
///////////// Bilateral ////////////////////////
|
||||
|
||||
typedef TestBaseWithParam<Size> BilateralFixture; |
||||
|
||||
OCL_PERF_TEST_P(BilateralFixture, Bilateral, OCL_TEST_SIZES) |
||||
{ |
||||
const Size srcSize = GetParam(); |
||||
const int d = 7; |
||||
const double sigmacolor = 50.0, sigmaspace = 50.0; |
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1); |
||||
|
||||
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); |
||||
declare.in(src, WARMUP_RNG).out(dst); |
||||
|
||||
OCL_TEST_CYCLE() cv::bilateralFilter(src, dst, d, sigmacolor, sigmaspace); |
||||
|
||||
SANITY_CHECK(dst); |
||||
} |
||||
|
||||
} } // namespace cvtest::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
Loading…
Reference in new issue