1793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*M/////////////////////////////////////////////////////////////////////////////////////// 2793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 3793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 5793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// By downloading, copying, installing or using the software you agree to this license. 6793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// If you do not agree to this license, do not download, install, 7793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// copy or use the software. 8793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 9793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 10793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// License Agreement 11793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// For Open Source Computer Vision Library 12793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 13793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. 14793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. 15793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Third party copyrights are property of their respective owners. 16793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 17793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// @Authors 18793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Fangfang Bai, fangfang@multicorewareinc.com 19793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Jin Ma, jin@multicorewareinc.com 20793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 21793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Redistribution and use in source and binary forms, with or without modification, 22793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// are permitted provided that the following conditions are met: 23793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 24793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// * Redistribution's of source code must retain the above copyright notice, 25793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// this list of conditions and the following disclaimer. 26793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 27793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// * Redistribution's in binary form must reproduce the above copyright notice, 28793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// this list of conditions and the following disclaimer in the documentation 29793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// and/or other materials provided with the distribution. 30793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 31793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// * The name of the copyright holders may not be used to endorse or promote products 32793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// derived from this software without specific prior written permission. 33793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 34793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// This software is provided by the copyright holders and contributors as is and 35793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// any express or implied warranties, including, but not limited to, the implied 36793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// warranties of merchantability and fitness for a particular purpose are disclaimed. 37793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// In no event shall the Intel Corporation or contributors be liable for any direct, 38793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// indirect, incidental, special, exemplary, or consequential damages 39793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// (including, but not limited to, procurement of substitute goods or services; 40793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// loss of use, data, or profits; or business interruption) however caused 41793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// and on any theory of liability, whether in contract, strict liability, 42793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// or tort (including negligence or otherwise) arising in any way out of 43793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// the use of this software, even if advised of the possibility of such damage. 44793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 45793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler//M*/ 46793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 47793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "../perf_precomp.hpp" 48793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "opencv2/ts/ocl_perf.hpp" 49793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 50793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#ifdef HAVE_OPENCL 51793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 52793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslernamespace cvtest { 53793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslernamespace ocl { 54793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 55793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler///////////// PyrDown ////////////////////// 56793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 57793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef Size_MatType PyrDownFixture; 58793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 59793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerOCL_PERF_TEST_P(PyrDownFixture, PyrDown, 60793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) 61793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 62793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size_MatType_t params = GetParam(); 63793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size srcSize = get<0>(params); 64793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const int type = get<1>(params); 65793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1); 66793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; 67793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 68793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler checkDeviceMaxMemoryAllocSize(srcSize, type); 69793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler checkDeviceMaxMemoryAllocSize(dstSize, type); 70793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 71793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler UMat src(srcSize, type), dst(dstSize, type); 72793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler declare.in(src, WARMUP_RNG).out(dst); 73793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 74793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler OCL_TEST_CYCLE() cv::pyrDown(src, dst); 75793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 76793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst, eps); 77793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 78793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 79793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler///////////// PyrUp //////////////////////// 80793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 81793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef Size_MatType PyrUpFixture; 82793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 83793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerOCL_PERF_TEST_P(PyrUpFixture, PyrUp, 84793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) 85793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 86793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size_MatType_t params = GetParam(); 87793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size srcSize = get<0>(params); 88793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const int type = get<1>(params); 89793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size dstSize(srcSize.height << 1, srcSize.width << 1); 90793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; 91793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 92793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler checkDeviceMaxMemoryAllocSize(srcSize, type); 93793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler checkDeviceMaxMemoryAllocSize(dstSize, type); 94793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 95793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler UMat src(srcSize, type), dst(dstSize, type); 96793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler declare.in(src, WARMUP_RNG).out(dst); 97793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 98793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler OCL_TEST_CYCLE() cv::pyrUp(src, dst); 99793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 100793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst, eps); 101793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 102793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 103793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler///////////// buildPyramid //////////////////////// 104793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 105793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef Size_MatType BuildPyramidFixture; 106793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 107793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerOCL_PERF_TEST_P(BuildPyramidFixture, BuildPyramid, 108793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) 109793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 110793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size_MatType_t params = GetParam(); 111793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const Size srcSize = get<0>(params); 112793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const int type = get<1>(params), maxLevel = 5; 113793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; 114793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 115793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler checkDeviceMaxMemoryAllocSize(srcSize, type); 116793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 117793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler std::vector<UMat> dst(maxLevel); 118793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler UMat src(srcSize, type); 119793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler declare.in(src, WARMUP_RNG); 120793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 121793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler OCL_TEST_CYCLE() cv::buildPyramid(src, dst, maxLevel); 122793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 123793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler UMat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4]; 124793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 125793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst0, eps); 126793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst1, eps); 127793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst2, eps); 128793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst3, eps); 129793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler SANITY_CHECK(dst4, eps); 130793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 131793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 132793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} } // namespace cvtest::ocl 133793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 134793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif // HAVE_OPENCL 135