mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 11:40:44 +08:00
added perf tests to some imgproc functions
This commit is contained in:
parent
e76d51511e
commit
04ae46e21c
202
modules/imgproc/perf/opencl/perf_imgproc.cpp
Normal file
202
modules/imgproc/perf/opencl/perf_imgproc.cpp
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
/*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 {
|
||||||
|
|
||||||
|
///////////// equalizeHist ////////////////////////
|
||||||
|
|
||||||
|
typedef TestBaseWithParam<Size> EqualizeHistFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES)
|
||||||
|
{
|
||||||
|
const Size srcSize = GetParam();
|
||||||
|
const double eps = 1;
|
||||||
|
|
||||||
|
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
OCL_TEST_CYCLE() cv::equalizeHist(src, dst);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst, eps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////// CopyMakeBorder //////////////////////
|
||||||
|
|
||||||
|
CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101)
|
||||||
|
|
||||||
|
typedef tuple<Size, MatType, Border> CopyMakeBorderParamType;
|
||||||
|
typedef TestBaseWithParam<CopyMakeBorderParamType> CopyMakeBorderFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder,
|
||||||
|
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, Border::all()))
|
||||||
|
{
|
||||||
|
const CopyMakeBorderParamType params = GetParam();
|
||||||
|
const Size srcSize = get<0>(params);
|
||||||
|
const int type = get<1>(params), borderType = get<2>(params);
|
||||||
|
|
||||||
|
UMat src(srcSize, type), dst;
|
||||||
|
const Size dstSize = srcSize + Size(12, 12);
|
||||||
|
dst.create(dstSize, type);
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
OCL_TEST_CYCLE() cv::copyMakeBorder(src, dst, 7, 5, 5, 7, borderType, cv::Scalar(1.0));
|
||||||
|
|
||||||
|
SANITY_CHECK(dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////// CornerMinEigenVal ////////////////////////
|
||||||
|
|
||||||
|
typedef Size_MatType CornerMinEigenValFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal,
|
||||||
|
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
||||||
|
{
|
||||||
|
const Size_MatType_t params = GetParam();
|
||||||
|
const Size srcSize = get<0>(params);
|
||||||
|
const int type = get<1>(params), borderType = BORDER_REFLECT;
|
||||||
|
const int blockSize = 7, apertureSize = 1 + 2 * 3;
|
||||||
|
|
||||||
|
UMat src(srcSize, type), dst(srcSize, CV_32FC1);
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
const int depth = CV_MAT_DEPTH(type);
|
||||||
|
const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE;
|
||||||
|
|
||||||
|
OCL_TEST_CYCLE() cv::cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst, 1e-6, errorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////// CornerHarris ////////////////////////
|
||||||
|
|
||||||
|
typedef Size_MatType CornerHarrisFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris,
|
||||||
|
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
|
||||||
|
{
|
||||||
|
const Size_MatType_t params = GetParam();
|
||||||
|
const Size srcSize = get<0>(params);
|
||||||
|
const int type = get<1>(params), borderType = BORDER_REFLECT;
|
||||||
|
|
||||||
|
UMat src(srcSize, type), dst(srcSize, CV_32FC1);
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
OCL_TEST_CYCLE() cv::cornerHarris(src, dst, 5, 7, 0.1, borderType);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst, 3e-5);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////// Integral ////////////////////////
|
||||||
|
|
||||||
|
typedef tuple<Size, MatDepth> IntegralParams;
|
||||||
|
typedef TestBaseWithParam<IntegralParams> IntegralFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32F, CV_64F)))
|
||||||
|
{
|
||||||
|
const IntegralParams params = GetParam();
|
||||||
|
const Size srcSize = get<0>(params);
|
||||||
|
const int ddepth = get<1>(params);
|
||||||
|
|
||||||
|
UMat src(srcSize, CV_8UC1), dst(srcSize, ddepth);
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
OCL_TEST_CYCLE() cv::integral(src, dst, ddepth);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////// Threshold ////////////////////////
|
||||||
|
|
||||||
|
CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO_INV)
|
||||||
|
|
||||||
|
typedef tuple<Size, MatType, ThreshType> ThreshParams;
|
||||||
|
typedef TestBaseWithParam<ThreshParams> ThreshFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(ThreshFixture, Threshold,
|
||||||
|
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ThreshType::all()))
|
||||||
|
{
|
||||||
|
const ThreshParams params = GetParam();
|
||||||
|
const Size srcSize = get<0>(params);
|
||||||
|
const int srcType = get<1>(params);
|
||||||
|
const int threshType = get<2>(params);
|
||||||
|
const double maxValue = 220.0, threshold = 50;
|
||||||
|
|
||||||
|
UMat src(srcSize, srcType), dst(srcSize, srcType);
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
OCL_TEST_CYCLE() cv::threshold(src, dst, threshold, maxValue, threshType);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////// CLAHE ////////////////////////
|
||||||
|
|
||||||
|
typedef TestBaseWithParam<Size> CLAHEFixture;
|
||||||
|
|
||||||
|
OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES)
|
||||||
|
{
|
||||||
|
const Size srcSize = GetParam();
|
||||||
|
|
||||||
|
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
|
||||||
|
const double clipLimit = 40.0;
|
||||||
|
declare.in(src, WARMUP_RNG).out(dst);
|
||||||
|
|
||||||
|
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit);
|
||||||
|
OCL_TEST_CYCLE() clahe->apply(src, dst);
|
||||||
|
|
||||||
|
SANITY_CHECK(dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
} } // namespace cvtest::ocl
|
||||||
|
|
||||||
|
#endif // HAVE_OPENCL
|
||||||
|
|
Loading…
Reference in New Issue
Block a user