Path: blob/master/modules/imgproc/perf/opencl/perf_pyramid.cpp
16344 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.13// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.14// Third party copyrights are property of their respective owners.15//16// @Authors17// Fangfang Bai, [email protected]18// Jin Ma, [email protected]19//20// Redistribution and use in source and binary forms, with or without modification,21// are permitted provided that the following conditions are met:22//23// * Redistribution's of source code must retain the above copyright notice,24// this list of conditions and the following disclaimer.25//26// * Redistribution's in binary form must reproduce the above copyright notice,27// this list of conditions and the following disclaimer in the documentation28// and/or other materials provided with the distribution.29//30// * The name of the copyright holders may not be used to endorse or promote products31// derived from this software without specific prior written permission.32//33// This software is provided by the copyright holders and contributors as is and34// any express or implied warranties, including, but not limited to, the implied35// warranties of merchantability and fitness for a particular purpose are disclaimed.36// In no event shall the Intel Corporation or contributors be liable for any direct,37// indirect, incidental, special, exemplary, or consequential damages38// (including, but not limited to, procurement of substitute goods or services;39// loss of use, data, or profits; or business interruption) however caused40// and on any theory of liability, whether in contract, strict liability,41// or tort (including negligence or otherwise) arising in any way out of42// the use of this software, even if advised of the possibility of such damage.43//44//M*/4546#include "../perf_precomp.hpp"47#include "opencv2/ts/ocl_perf.hpp"4849#ifdef HAVE_OPENCL5051namespace opencv_test {52namespace ocl {5354///////////// PyrDown //////////////////////5556typedef Size_MatType PyrDownFixture;5758OCL_PERF_TEST_P(PyrDownFixture, PyrDown,59::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))60{61const Size_MatType_t params = GetParam();62const Size srcSize = get<0>(params);63const int type = get<1>(params);64const Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1);65const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;6667checkDeviceMaxMemoryAllocSize(srcSize, type);68checkDeviceMaxMemoryAllocSize(dstSize, type);6970UMat src(srcSize, type), dst(dstSize, type);71declare.in(src, WARMUP_RNG).out(dst);7273OCL_TEST_CYCLE() cv::pyrDown(src, dst);7475SANITY_CHECK(dst, eps);76}7778///////////// PyrUp ////////////////////////7980typedef Size_MatType PyrUpFixture;8182OCL_PERF_TEST_P(PyrUpFixture, PyrUp,83::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))84{85const Size_MatType_t params = GetParam();86const Size srcSize = get<0>(params);87const int type = get<1>(params);88const Size dstSize(srcSize.height << 1, srcSize.width << 1);89const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;9091checkDeviceMaxMemoryAllocSize(srcSize, type);92checkDeviceMaxMemoryAllocSize(dstSize, type);9394UMat src(srcSize, type), dst(dstSize, type);95declare.in(src, WARMUP_RNG).out(dst);9697OCL_TEST_CYCLE() cv::pyrUp(src, dst);9899SANITY_CHECK(dst, eps);100}101102///////////// buildPyramid ////////////////////////103104typedef Size_MatType BuildPyramidFixture;105106OCL_PERF_TEST_P(BuildPyramidFixture, BuildPyramid,107::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))108{109const Size_MatType_t params = GetParam();110const Size srcSize = get<0>(params);111const int type = get<1>(params), maxLevel = 5;112const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;113114checkDeviceMaxMemoryAllocSize(srcSize, type);115116std::vector<UMat> dst(maxLevel);117UMat src(srcSize, type);118declare.in(src, WARMUP_RNG);119120OCL_TEST_CYCLE() cv::buildPyramid(src, dst, maxLevel);121122UMat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];123124SANITY_CHECK(dst0, eps);125SANITY_CHECK(dst1, eps);126SANITY_CHECK(dst2, eps);127SANITY_CHECK(dst3, eps);128SANITY_CHECK(dst4, eps);129}130131} } // namespace opencv_test::ocl132133#endif // HAVE_OPENCL134135136