feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake

1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试
2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程
3.重整权利声明文件,重整代码工程,确保最小化侵权风险

Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake
Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
wangzhengyang
2022-05-10 09:54:44 +08:00
parent ecdd171c6f
commit 718c41634f
10018 changed files with 3593797 additions and 186748 deletions

View File

@ -0,0 +1,137 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace opencv_test {
namespace ocl {
///////////// 3 channels Vs 4 ////////////////////////
enum
{
Pure = 0, Split, Convert
};
CV_ENUM(Modes, Pure, Split, Convert)
typedef tuple <Size, MatType, Modes> _3vs4Params;
typedef TestBaseWithParam<_3vs4Params> _3vs4_Fixture;
OCL_PERF_TEST_P(_3vs4_Fixture, Resize,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC3, CV_32FC3), Modes::all()))
{
_3vs4Params params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), depth = CV_MAT_DEPTH(type);
const int mode = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
if (mode == Pure)
{
OCL_TEST_CYCLE() resize(src, dst, Size(), 0.5, 0.5, INTER_LINEAR_EXACT);
}
else if (mode == Split)
{
std::vector<UMat> srcs(3), dsts(3);
for (int i = 0; i < 3; ++i)
{
dsts[i] = UMat(srcSize, depth);
srcs[i] = UMat(srcSize, depth);
}
OCL_TEST_CYCLE()
{
split(src, srcs);
for (size_t i = 0; i < srcs.size(); ++i)
resize(srcs[i], dsts[i], Size(), 0.5, 0.5, INTER_LINEAR_EXACT);
merge(dsts, dst);
}
}
else if (mode == Convert)
{
int type4 = CV_MAKE_TYPE(depth, 4);
UMat src4(srcSize, type4), dst4(srcSize, type4);
OCL_TEST_CYCLE()
{
cvtColor(src, src4, COLOR_RGB2RGBA);
resize(src4, dst4, Size(), 0.5, 0.5, INTER_LINEAR_EXACT);
cvtColor(dst4, dst, COLOR_RGBA2RGB);
}
}
SANITY_CHECK_NOTHING();
}
OCL_PERF_TEST_P(_3vs4_Fixture, Subtract,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC3, CV_32FC3), Modes::all()))
{
_3vs4Params params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), depth = CV_MAT_DEPTH(type);
const int mode = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
Scalar s(14);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
if (mode == Pure)
{
OCL_TEST_CYCLE() subtract(src, s, dst);
}
else if (mode == Split)
{
std::vector<UMat> srcs(3), dsts(3);
for (int i = 0; i < 3; ++i)
{
dsts[i] = UMat(srcSize, depth);
srcs[i] = UMat(srcSize, depth);
}
OCL_TEST_CYCLE()
{
split(src, srcs);
for (size_t i = 0; i < srcs.size(); ++i)
subtract(srcs[i], s, dsts[i]);
merge(dsts, dst);
}
}
else if (mode == Convert)
{
int type4 = CV_MAKE_TYPE(depth, 4);
UMat src4(srcSize, type4), dst4(srcSize, type4);
OCL_TEST_CYCLE()
{
cvtColor(src, src4, COLOR_RGB2RGBA);
subtract(src4, s, dst4);
cvtColor(dst4, dst, COLOR_RGBA2RGB);
}
}
SANITY_CHECK_NOTHING();
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,140 @@
/*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
// Nathan, liujun@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 opencv_test {
namespace ocl {
/////////////////////////////////// Accumulate ///////////////////////////////////
typedef Size_MatType AccumulateFixture;
OCL_PERF_TEST_P(AccumulateFixture, Accumulate,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
checkDeviceMaxMemoryAllocSize(srcSize, dstType);
UMat src(srcSize, srcType), dst(srcSize, dstType);
declare.in(src, dst, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::accumulate(src, dst);
SANITY_CHECK_NOTHING();
}
/////////////////////////////////// AccumulateSquare ///////////////////////////////////
typedef Size_MatType AccumulateSquareFixture;
OCL_PERF_TEST_P(AccumulateSquareFixture, AccumulateSquare,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
checkDeviceMaxMemoryAllocSize(srcSize, dstType);
UMat src(srcSize, srcType), dst(srcSize, dstType);
declare.in(src, dst, WARMUP_RNG);
OCL_TEST_CYCLE() cv::accumulateSquare(src, dst);
SANITY_CHECK_NOTHING();
}
/////////////////////////////////// AccumulateProduct ///////////////////////////////////
typedef Size_MatType AccumulateProductFixture;
OCL_PERF_TEST_P(AccumulateProductFixture, AccumulateProduct,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
checkDeviceMaxMemoryAllocSize(srcSize, dstType);
UMat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, dstType);
declare.in(src1, src2, dst, WARMUP_RNG);
OCL_TEST_CYCLE() cv::accumulateProduct(src1, src2, dst);
SANITY_CHECK_NOTHING();
}
/////////////////////////////////// AccumulateWeighted ///////////////////////////////////
typedef Size_MatType AccumulateWeightedFixture;
OCL_PERF_TEST_P(AccumulateWeightedFixture, AccumulateWeighted,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
checkDeviceMaxMemoryAllocSize(srcSize, dstType);
UMat src(srcSize, srcType), dst(srcSize, dstType);
declare.in(src, dst, WARMUP_RNG);
OCL_TEST_CYCLE() cv::accumulateWeighted(src, dst, 2.0);
SANITY_CHECK_NOTHING();
}
} } // namespace opencv_test::ocl
#endif

View File

@ -0,0 +1,82 @@
/*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 opencv_test {
namespace ocl {
///////////// BlendLinear ////////////////////////
typedef Size_MatType BlendLinearFixture;
OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int srcType = get<1>(params);
const double eps = CV_MAT_DEPTH(srcType) <= CV_32S ? 1.0 : 0.2;
checkDeviceMaxMemoryAllocSize(srcSize, srcType);
UMat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, srcType);
UMat weights1(srcSize, CV_32FC1), weights2(srcSize, CV_32FC1);
declare.in(src1, src2, WARMUP_RNG).in(weights1, weights2, WARMUP_READ).out(dst);
randu(weights1, 0, 1);
randu(weights2, 0, 1);
OCL_TEST_CYCLE() cv::blendLinear(src1, src2, weights1, weights2, dst);
SANITY_CHECK(dst, eps);
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,113 @@
/*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 opencv_test {
namespace ocl {
///////////// cvtColor////////////////////////
CV_ENUM(ConversionTypes, COLOR_RGB2GRAY, COLOR_RGB2BGR, COLOR_RGB2YUV, COLOR_YUV2RGB, COLOR_RGB2YCrCb,
COLOR_YCrCb2RGB, COLOR_RGB2XYZ, COLOR_XYZ2RGB, COLOR_RGB2HSV, COLOR_HSV2RGB, COLOR_RGB2HLS,
COLOR_HLS2RGB, COLOR_BGR5652BGR, COLOR_BGR2BGR565, COLOR_RGBA2mRGBA, COLOR_mRGBA2RGBA,
COLOR_RGB2Lab, COLOR_Lab2BGR, COLOR_RGB2Luv, COLOR_Luv2LBGR, COLOR_YUV2RGB_NV12, COLOR_YUV2RGB_IYUV,
COLOR_YUV2GRAY_420, COLOR_RGB2YUV_IYUV, COLOR_YUV2RGB_YUY2, COLOR_YUV2GRAY_YUY2)
typedef tuple<Size, tuple<ConversionTypes, int, int> > CvtColorParams;
typedef TestBaseWithParam<CvtColorParams> CvtColorFixture;
OCL_PERF_TEST_P(CvtColorFixture, CvtColor, testing::Combine(
OCL_TEST_SIZES,
testing::Values(
make_tuple(ConversionTypes(COLOR_RGB2GRAY), 3, 1),
make_tuple(ConversionTypes(COLOR_RGB2BGR), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2YUV), 3, 3),
make_tuple(ConversionTypes(COLOR_YUV2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2YCrCb), 3, 3),
make_tuple(ConversionTypes(COLOR_YCrCb2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2XYZ), 3, 3),
make_tuple(ConversionTypes(COLOR_XYZ2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2HSV), 3, 3),
make_tuple(ConversionTypes(COLOR_HSV2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2HLS), 3, 3),
make_tuple(ConversionTypes(COLOR_HLS2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_BGR5652BGR), 2, 3),
make_tuple(ConversionTypes(COLOR_BGR2BGR565), 3, 2),
make_tuple(ConversionTypes(COLOR_RGBA2mRGBA), 4, 4),
make_tuple(ConversionTypes(COLOR_mRGBA2RGBA), 4, 4),
make_tuple(ConversionTypes(COLOR_RGB2Lab), 3, 3),
make_tuple(ConversionTypes(COLOR_Lab2BGR), 3, 4),
make_tuple(ConversionTypes(COLOR_RGB2Luv), 3, 3),
make_tuple(ConversionTypes(COLOR_Luv2LBGR), 3, 4),
make_tuple(ConversionTypes(COLOR_YUV2RGB_NV12), 1, 3),
make_tuple(ConversionTypes(COLOR_YUV2RGB_IYUV), 1, 3),
make_tuple(ConversionTypes(COLOR_YUV2GRAY_420), 1, 1),
make_tuple(ConversionTypes(COLOR_RGB2YUV_IYUV), 3, 1),
make_tuple(ConversionTypes(COLOR_YUV2RGB_YUY2), 2, 3),
make_tuple(ConversionTypes(COLOR_YUV2GRAY_YUY2), 2, 1)
)))
{
CvtColorParams params = GetParam();
const Size srcSize = get<0>(params);
const tuple<int, int, int> conversionParams = get<1>(params);
const int code = get<0>(conversionParams), scn = get<1>(conversionParams),
dcn = get<2>(conversionParams);
UMat src(srcSize, CV_8UC(scn)), dst(srcSize, CV_8UC(scn));
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::cvtColor(src, dst, code, dcn);
SANITY_CHECK(dst, 1);
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,415 @@
/*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 opencv_test {
namespace ocl {
typedef tuple<Size, MatType, int> FilterParams;
typedef TestBaseWithParam<FilterParams> FilterFixture;
///////////// Blur ////////////////////////
typedef FilterFixture BlurFixture;
OCL_PERF_TEST_P(BlurFixture, Blur,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(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, Size(ksize, ksize), Point(-1, -1), bordertype);
SANITY_CHECK(dst, eps);
}
///////////// SqrBoxFilter ////////////////////////
typedef tuple<Size, MatType, Size> SqrBoxFilterParams;
typedef TestBaseWithParam<SqrBoxFilterParams> SqrBoxFilterFixture;
OCL_PERF_TEST_P(SqrBoxFilterFixture, SqrBoxFilter,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4),
OCL_PERF_ENUM(Size(3, 3), Size(20, 3), Size(3, 20), Size(20, 20))))
{
const SqrBoxFilterParams params = GetParam();
const Size srcSize = get<0>(params), ksize = get<2>(params);
const int type = get<1>(params), depth = CV_MAT_DEPTH(type),
ddepth = depth == CV_8U ? CV_32S : CV_32F;
const double eps = ddepth == CV_32S ? 0 : 5e-5;
checkDeviceMaxMemoryAllocSize(srcSize, CV_MAKE_TYPE(ddepth, CV_MAT_CN(type)));
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::sqrBoxFilter(src, dst, ddepth, ksize, Point(-1, -1), false);
SANITY_CHECK(dst, eps);
}
///////////// Laplacian////////////////////////
typedef FilterFixture LaplacianFixture;
OCL_PERF_TEST_P(LaplacianFixture, Laplacian,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 2e-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 FilterFixture ErodeFixture;
OCL_PERF_TEST_P(ErodeFixture, Erode,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
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);
}
///////////// Dilate ////////////////////
typedef FilterFixture DilateFixture;
OCL_PERF_TEST_P(DilateFixture, Dilate,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
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::dilate(src, dst, ker);
SANITY_CHECK(dst);
}
///////////// MorphologyEx ////////////////////////
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
typedef tuple<Size, MatType, MorphOp, int> MorphologyExParams;
typedef TestBaseWithParam<MorphologyExParams> MorphologyExFixture;
OCL_PERF_TEST_P(MorphologyExFixture, MorphologyEx,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, MorphOp::all(), OCL_PERF_ENUM(3, 5)))
{
const MorphologyExParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), op = get<2>(params), ksize = get<3>(params);
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::morphologyEx(src, dst, op, 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, 1e-6);
}
///////////// 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 FilterFixture OCL_GaussianBlurFixture;
PERF_TEST_P_(OCL_GaussianBlurFixture, GaussianBlur)
{
const FilterParams& params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
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), 1, 1, cv::BORDER_CONSTANT);
SANITY_CHECK_NOTHING();
}
INSTANTIATE_TEST_CASE_P(/*nothing*/, OCL_GaussianBlurFixture,
::testing::Combine(
OCL_TEST_SIZES,
OCL_TEST_TYPES,
OCL_PERF_ENUM(3, 5, 7)
)
);
INSTANTIATE_TEST_CASE_P(SIFT, OCL_GaussianBlurFixture,
::testing::Combine(
::testing::Values(sz1080p),
::testing::Values(CV_32FC1),
OCL_PERF_ENUM(11, 13, 17, 21, 27)
)
);
INSTANTIATE_TEST_CASE_P(DISABLED_FULL, OCL_GaussianBlurFixture,
::testing::Combine(
::testing::Values(sz1080p),
::testing::Values(
CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4,
CV_8SC1, CV_8SC2, CV_8SC3, CV_8SC4,
CV_16UC1, CV_16UC2, CV_16UC3, CV_16UC4,
CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4,
CV_32SC1, CV_32SC2, CV_32SC3, CV_32SC4,
CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4,
CV_64FC1, CV_64FC2, CV_64FC3, CV_64FC4
),
OCL_PERF_ENUM(3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29)
)
);
///////////// Filter2D ////////////////////////
typedef FilterFixture Filter2DFixture;
OCL_PERF_TEST_P(Filter2DFixture, Filter2D,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5)))
{
const FilterParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
Mat 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);
}
///////////// SepFilter2D /////////////
typedef FilterFixture OCL_SepFilter2D;
PERF_TEST_P_(OCL_SepFilter2D, SepFilter2D)
{
const FilterParams& params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
Mat kernelX(1, ksize, CV_32FC1);
randu(kernelX, -3.0, 3.0);
Mat kernelY(1, ksize, CV_32FC1);
randu(kernelY, -3.0, 3.0);
OCL_TEST_CYCLE() cv::sepFilter2D(src, dst, -1, kernelX, kernelY, cv::Point(-1, -1), 1.0f, cv::BORDER_CONSTANT);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P_(OCL_SepFilter2D, SepFilter2D_BitExact)
{
const FilterParams& params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), ksize = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
Mat kernelX(1, ksize, CV_32SC1);
randu(kernelX, -16.0, 16.0);
kernelX.convertTo(kernelX, CV_32FC1, 1/16.0f, 0);
Mat kernelY(1, ksize, CV_32SC1);
randu(kernelY, -16.0, 16.0);
kernelY.convertTo(kernelY, CV_32FC1, 1/16.0f, 0);
OCL_TEST_CYCLE() cv::sepFilter2D(src, dst, -1, kernelX, kernelY, cv::Point(-1, -1), 1.0f, cv::BORDER_CONSTANT);
SANITY_CHECK_NOTHING();
}
INSTANTIATE_TEST_CASE_P(/*nothing*/, OCL_SepFilter2D,
::testing::Combine(
::testing::Values(sz1080p),
OCL_TEST_TYPES,
OCL_PERF_ENUM(3, 5, 7, 9, 11)
)
);
///////////// 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);
}
///////////// MedianBlur ////////////////////////
typedef tuple<Size, int> MedianBlurParams;
typedef TestBaseWithParam<MedianBlurParams> MedianBlurFixture;
OCL_PERF_TEST_P(MedianBlurFixture, Bilateral, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(3, 5)))
{
MedianBlurParams params = GetParam();
const Size srcSize = get<0>(params);
const int ksize = get<1>(params);
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::medianBlur(src, dst, ksize);
SANITY_CHECK(dst);
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,116 @@
///////////////////////////////////////////////////////////////////////////////////////
//
// 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, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
//
// 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"
#include <sstream>
#ifdef HAVE_OPENCL
namespace opencv_test {
namespace ocl {
//////////////////////////// GoodFeaturesToTrack //////////////////////////
typedef tuple<String, double, bool> GoodFeaturesToTrackParams;
typedef TestBaseWithParam<GoodFeaturesToTrackParams> GoodFeaturesToTrackFixture;
OCL_PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
::testing::Combine(OCL_PERF_ENUM(String("gpu/opticalflow/rubberwhale1.png")),
OCL_PERF_ENUM(0.0, 3.0), Bool()))
{
GoodFeaturesToTrackParams params = GetParam();
const String fileName = get<0>(params);
const double minDistance = get<1>(params), qualityLevel = 0.01;
const bool harrisDetector = get<2>(params);
const int maxCorners = 1000;
Mat img = imread(getDataPath(fileName), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "could not load " << fileName;
checkDeviceMaxMemoryAllocSize(img.size(), img.type());
UMat src(img.size(), img.type()), dst(1, maxCorners, CV_32FC2);
img.copyTo(src);
declare.in(src, WARMUP_READ).out(dst);
OCL_TEST_CYCLE() cv::goodFeaturesToTrack(src, dst, maxCorners, qualityLevel,
minDistance, noArray(), 3, 3, harrisDetector, 0.04);
SANITY_CHECK(dst);
}
OCL_PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrackWithQuality,
::testing::Combine(OCL_PERF_ENUM(String("gpu/opticalflow/rubberwhale1.png")),
OCL_PERF_ENUM(3.0), Bool()))
{
GoodFeaturesToTrackParams params = GetParam();
const String fileName = get<0>(params);
const double minDistance = get<1>(params), qualityLevel = 0.01;
const bool harrisDetector = get<2>(params);
const int maxCorners = 1000;
Mat img = imread(getDataPath(fileName), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "could not load " << fileName;
checkDeviceMaxMemoryAllocSize(img.size(), img.type());
UMat src(img.size(), img.type()), dst(1, maxCorners, CV_32FC2);
img.copyTo(src);
std::vector<float> cornersQuality;
declare.in(src, WARMUP_READ).out(dst);
OCL_TEST_CYCLE() cv::goodFeaturesToTrack(src, dst, maxCorners, qualityLevel, minDistance,
noArray(), cornersQuality, 3, 3, harrisDetector, 0.04);
SANITY_CHECK(dst);
SANITY_CHECK(cornersQuality, 1e-6);
}
} } // namespace opencv_test::ocl
#endif

View File

@ -0,0 +1,91 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace opencv_test {
namespace ocl {
///////////// HoughLines //////////////////////
struct Vec2fComparator
{
bool operator()(const Vec2f& a, const Vec2f b) const
{
if(a[0] != b[0]) return a[0] < b[0];
else return a[1] < b[1];
}
};
typedef tuple<Size, double, double> ImageSize_RhoStep_ThetaStep_t;
typedef TestBaseWithParam<ImageSize_RhoStep_ThetaStep_t> HoughLinesFixture;
OCL_PERF_TEST_P(HoughLinesFixture, HoughLines, Combine(OCL_TEST_SIZES,
Values( 0.1, 1 ),
Values( CV_PI / 180.0, 0.1 )))
{
const Size srcSize = get<0>(GetParam());
double rhoStep = get<1>(GetParam());
double thetaStep = get<2>(GetParam());
int threshold = 250;
UMat usrc(srcSize, CV_8UC1), lines(1, 1, CV_32FC2);
Mat src(srcSize, CV_8UC1);
src.setTo(Scalar::all(0));
line(src, Point(0, 100), Point(src.cols, 100), Scalar::all(255), 1);
line(src, Point(0, 200), Point(src.cols, 200), Scalar::all(255), 1);
line(src, Point(0, 400), Point(src.cols, 400), Scalar::all(255), 1);
line(src, Point(100, 0), Point(100, src.rows), Scalar::all(255), 1);
line(src, Point(200, 0), Point(200, src.rows), Scalar::all(255), 1);
line(src, Point(400, 0), Point(400, src.rows), Scalar::all(255), 1);
src.copyTo(usrc);
declare.in(usrc).out(lines);
OCL_TEST_CYCLE() cv::HoughLines(usrc, lines, rhoStep, thetaStep, threshold);
Mat result;
lines.copyTo(result);
std::sort(result.begin<Vec2f>(), result.end<Vec2f>(), Vec2fComparator());
SANITY_CHECK(result, 1e-6);
}
///////////// HoughLinesP /////////////////////
typedef tuple<string, double, double> Image_RhoStep_ThetaStep_t;
typedef TestBaseWithParam<Image_RhoStep_ThetaStep_t> HoughLinesPFixture;
OCL_PERF_TEST_P(HoughLinesPFixture, HoughLinesP, Combine(Values("cv/shared/pic5.png", "stitching/a1.png"),
Values( 0.1, 1 ),
Values( CV_PI / 180.0, 0.1 )))
{
string filename = get<0>(GetParam());
double rhoStep = get<1>(GetParam());
double thetaStep = get<2>(GetParam());
int threshold = 100;
double minLineLength = 50, maxGap = 5;
Mat image = imread(getDataPath(filename), IMREAD_GRAYSCALE);
Canny(image, image, 50, 200, 3);
UMat usrc, lines(1, 1, CV_32SC4);
image.copyTo(usrc);
declare.in(usrc).out(lines);
OCL_TEST_CYCLE() cv::HoughLinesP(usrc, lines, rhoStep, thetaStep, threshold, minLineLength, maxGap);
EXPECT_NE((int) lines.total(), 0);
SANITY_CHECK_NOTHING();
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,336 @@
/*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"
namespace opencv_test {
namespace ocl {
///////////// equalizeHist ////////////////////////
typedef TestBaseWithParam<Size> EqualizeHistFixture;
OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
const double eps = 1;
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
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);
}
///////////// calcHist ////////////////////////
typedef TestBaseWithParam<Size> CalcHistFixture;
OCL_PERF_TEST_P(CalcHistFixture, CalcHist, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
const std::vector<int> channels(1, 0);
std::vector<float> ranges(2);
std::vector<int> histSize(1, 256);
ranges[0] = 0;
ranges[1] = 256;
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
UMat src(srcSize, CV_8UC1), hist(256, 1, CV_32FC1);
declare.in(src, WARMUP_RNG).out(hist);
OCL_TEST_CYCLE() cv::calcHist(std::vector<UMat>(1, src), channels, noArray(), hist, histSize, ranges, false);
SANITY_CHECK(hist);
}
///////////// calcHist ////////////////////////
typedef TestBaseWithParam<Size> CalcBackProjFixture;
OCL_PERF_TEST_P(CalcBackProjFixture, CalcBackProj, OCL_TEST_SIZES)
{
const Size srcSize = GetParam();
const std::vector<int> channels(1, 0);
std::vector<float> ranges(2);
std::vector<int> histSize(1, 256);
ranges[0] = 0;
ranges[1] = 256;
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
UMat src(srcSize, CV_8UC1), hist(256, 1, CV_32FC1), dst(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG).out(hist);
cv::calcHist(std::vector<UMat>(1, src), channels, noArray(), hist, histSize, ranges, false);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::calcBackProject(std::vector<UMat>(1,src), channels, hist, dst, ranges, 1);
SANITY_CHECK_NOTHING();
}
/////////// 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_134, Border::all()))
{
const CopyMakeBorderParamType params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), borderType = get<2>(params);
checkDeviceMaxMemoryAllocSize(srcSize, type);
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;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
#ifdef HAVE_OPENCL
bool strictCheck = !ocl::useOpenCL() || ocl::Device::getDefault().isIntel();
#else
bool strictCheck = true;
#endif
// using native_* OpenCL functions on non-intel devices may lose accuracy
if (strictCheck)
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
else
SANITY_CHECK(dst, 0.1, ERROR_RELATIVE);
}
///////////// 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;
checkDeviceMaxMemoryAllocSize(srcSize, type);
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, 5e-6, ERROR_RELATIVE);
}
///////////// PreCornerDetect ////////////////////////
typedef Size_MatType PreCornerDetectFixture;
OCL_PERF_TEST_P(PreCornerDetectFixture, PreCornerDetect,
::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;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::preCornerDetect(src, dst, 3, borderType);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
///////////// 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_32S, CV_32F)))
{
const IntegralParams params = GetParam();
const Size srcSize = get<0>(params);
const int ddepth = get<1>(params);
checkDeviceMaxMemoryAllocSize(srcSize, ddepth);
UMat src(srcSize, CV_8UC1), dst(srcSize + Size(1, 1), ddepth);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::integral(src, dst, ddepth);
SANITY_CHECK(dst, 2e-6, ERROR_RELATIVE);
}
OCL_PERF_TEST_P(IntegralFixture, Integral2, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32S, CV_32F)))
{
const IntegralParams params = GetParam();
const Size srcSize = get<0>(params);
const int ddepth = get<1>(params);
checkDeviceMaxMemoryAllocSize(srcSize, ddepth);
UMat src(srcSize, CV_8UC1), sum(srcSize + Size(1, 1), ddepth), sqsum(srcSize + Size(1, 1), CV_32F);
declare.in(src, WARMUP_RNG).out(sum, sqsum);
OCL_TEST_CYCLE() cv::integral(src, sum, sqsum, ddepth, CV_32F);
SANITY_CHECK(sum, 2e-4, ERROR_RELATIVE);
SANITY_CHECK(sqsum, 5e-5, 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;
checkDeviceMaxMemoryAllocSize(srcSize, srcType);
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();
checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1);
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);
}
///////////// Canny ////////////////////////
typedef tuple<Size, int, bool> CannyParams;
typedef TestBaseWithParam<CannyParams> CannyFixture;
OCL_PERF_TEST_P(CannyFixture, Canny, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(3, 5), Bool()))
{
const CannyParams& params = GetParam();
cv::Size imgSize = get<0>(params);
int apertureSize = get<1>(params);
bool L2Grad = get<2>(params);
Mat _img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE);
ASSERT_TRUE(!_img.empty()) << "can't open aloe-L.png";
UMat img;
cv::resize(_img, img, imgSize, 0, 0, INTER_LINEAR_EXACT);
UMat edges(img.size(), CV_8UC1);
declare.in(img).out(edges);
PERF_SAMPLE_BEGIN();
cv::Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad);
PERF_SAMPLE_END();
SANITY_CHECK_NOTHING();
}
} } // namespace opencv_test::ocl

View File

@ -0,0 +1,237 @@
/*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 opencv_test {
namespace ocl {
///////////// WarpAffine ////////////////////////
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
typedef tuple<Size, MatType, InterType> WarpAffineParams;
typedef TestBaseWithParam<WarpAffineParams> WarpAffineFixture;
OCL_PERF_TEST_P(WarpAffineFixture, WarpAffine,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, InterType::all()))
{
static const double coeffs[2][3] =
{
{ cos(CV_PI / 6), -sin(CV_PI / 6), 100.0 },
{ sin(CV_PI / 6), cos(CV_PI / 6) , -100.0 }
};
Mat M(2, 3, CV_64F, (void *)coeffs);
const WarpAffineParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : interpolation == INTER_CUBIC ? 2e-3 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::warpAffine(src, dst, M, srcSize, interpolation);
SANITY_CHECK(dst, eps);
}
///////////// WarpPerspective ////////////////////////
typedef WarpAffineParams WarpPerspectiveParams;
typedef TestBaseWithParam<WarpPerspectiveParams> WarpPerspectiveFixture;
OCL_PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134,
OCL_PERF_ENUM(InterType(INTER_NEAREST), InterType(INTER_LINEAR))))
{
static const double coeffs[3][3] =
{
{cos(CV_PI / 6), -sin(CV_PI / 6), 100.0},
{sin(CV_PI / 6), cos(CV_PI / 6), -100.0},
{0.0, 0.0, 1.0}
};
Mat M(3, 3, CV_64F, (void *)coeffs);
const WarpPerspectiveParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::warpPerspective(src, dst, M, srcSize, interpolation);
SANITY_CHECK(dst, eps);
}
///////////// Resize ////////////////////////
typedef tuple<Size, MatType, InterType, double> ResizeParams;
typedef TestBaseWithParam<ResizeParams> ResizeFixture;
OCL_PERF_TEST_P(ResizeFixture, Resize,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134,
OCL_PERF_ENUM(InterType(INTER_NEAREST), InterType(INTER_LINEAR)),
::testing::Values(0.5, 2.0)))
{
const ResizeParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interType = get<2>(params);
double scale = get<3>(params);
const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale));
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::resize(src, dst, Size(), scale, scale, interType);
SANITY_CHECK(dst, eps);
}
typedef tuple<Size, MatType, double> ResizeAreaParams;
typedef TestBaseWithParam<ResizeAreaParams> ResizeAreaFixture;
OCL_PERF_TEST_P(ResizeAreaFixture, Resize,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134, ::testing::Values(0.3, 0.5, 0.6)))
{
const ResizeAreaParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
double scale = get<2>(params);
const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale));
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::resize(src, dst, Size(), scale, scale, cv::INTER_AREA);
SANITY_CHECK(dst, eps);
}
typedef ResizeAreaParams ResizeLinearExactParams;
typedef TestBaseWithParam<ResizeLinearExactParams> ResizeLinearExactFixture;
OCL_PERF_TEST_P(ResizeLinearExactFixture, Resize,
::testing::Combine(OCL_TEST_SIZES, ::testing::Values(CV_8UC1, CV_8UC3, CV_8UC4), ::testing::Values(0.5, 2.0)))
{
const ResizeAreaParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
double scale = get<2>(params);
const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale));
const double eps = 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::resize(src, dst, Size(), scale, scale, cv::INTER_LINEAR_EXACT);
SANITY_CHECK(dst, eps);
}
///////////// Remap ////////////////////////
typedef tuple<Size, MatType, InterType> RemapParams;
typedef TestBaseWithParam<RemapParams> RemapFixture;
OCL_PERF_TEST_P(RemapFixture, Remap,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134,
OCL_PERF_ENUM(InterType(INTER_NEAREST), InterType(INTER_LINEAR))))
{
const RemapParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), interpolation = get<2>(params), borderMode = BORDER_CONSTANT;
//const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4;
checkDeviceMaxMemoryAllocSize(srcSize, type);
UMat src(srcSize, type), dst(srcSize, type);
UMat xmap(srcSize, CV_32FC1), ymap(srcSize, CV_32FC1);
{
Mat _xmap = xmap.getMat(ACCESS_WRITE), _ymap = ymap.getMat(ACCESS_WRITE);
for (int i = 0; i < srcSize.height; ++i)
{
float * const xmap_row = _xmap.ptr<float>(i);
float * const ymap_row = _ymap.ptr<float>(i);
for (int j = 0; j < srcSize.width; ++j)
{
xmap_row[j] = (j - srcSize.width * 0.5f) * 0.75f + srcSize.width * 0.5f;
ymap_row[j] = (i - srcSize.height * 0.5f) * 0.75f + srcSize.height * 0.5f;
}
}
}
declare.in(src, WARMUP_RNG).in(xmap, ymap, WARMUP_READ).out(dst);
OCL_TEST_CYCLE() cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
SANITY_CHECK_NOTHING();
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,88 @@
#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
namespace opencv_test {
namespace ocl {
CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
typedef tuple<Size, Size, MethodType, MatType> ImgSize_TmplSize_Method_MatType_t;
typedef TestBaseWithParam<ImgSize_TmplSize_Method_MatType_t> ImgSize_TmplSize_Method_MatType;
OCL_PERF_TEST_P(ImgSize_TmplSize_Method_MatType, MatchTemplate,
::testing::Combine(
testing::Values(cv::Size(640, 480), cv::Size(1280, 1024)),
testing::Values(cv::Size(11, 11), cv::Size(16, 16), cv::Size(41, 41)),
MethodType::all(),
testing::Values(CV_8UC1, CV_8UC3, CV_32FC1, CV_32FC3)
)
)
{
const ImgSize_TmplSize_Method_MatType_t params = GetParam();
const Size imgSz = get<0>(params), tmplSz = get<1>(params);
const int method = get<2>(params);
int type = get<3>(GetParam());
UMat img(imgSz, type), tmpl(tmplSz, type);
UMat result(imgSz - tmplSz + Size(1, 1), CV_32F);
declare.in(img, tmpl, WARMUP_RNG).out(result);
OCL_TEST_CYCLE() matchTemplate(img, tmpl, result, method);
bool isNormed =
method == TM_CCORR_NORMED ||
method == TM_SQDIFF_NORMED ||
method == TM_CCOEFF_NORMED;
double eps = isNormed ? 3e-2
: 255 * 255 * tmpl.total() * 1e-4;
SANITY_CHECK(result, eps, ERROR_RELATIVE);
}
/////////// matchTemplate (performance tests from 2.4) ////////////////////////
typedef Size_MatType CV_TM_CCORRFixture;
OCL_PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
::testing::Combine(::testing::Values(Size(1000, 1000), Size(2000, 2000)),
OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params), templSize(5, 5);
const int type = get<1>(params);
UMat src(srcSize, type), templ(templSize, type);
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
UMat dst(dstSize, CV_32F);
declare.in(src, templ, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR);
SANITY_CHECK(dst, 1e-4);
}
typedef TestBaseWithParam<Size> CV_TM_CCORR_NORMEDFixture;
OCL_PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate,
::testing::Values(Size(1000, 1000), Size(2000, 2000), Size(4000, 4000)))
{
const Size srcSize = GetParam(), templSize(5, 5);
UMat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1);
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
UMat dst(dstSize, CV_8UC1);
declare.in(src, templ, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR_NORMED);
SANITY_CHECK(dst, 3e-2);
}
} } // namespace
#endif // HAVE_OPENCL

View File

@ -0,0 +1,78 @@
/*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 opencv_test {
namespace ocl {
///////////// Moments ////////////////////////
typedef tuple<Size, bool> MomentsParams;
typedef TestBaseWithParam<MomentsParams> MomentsFixture;
OCL_PERF_TEST_P(MomentsFixture, Moments,
::testing::Combine(OCL_TEST_SIZES, ::testing::Bool()))
{
const MomentsParams params = GetParam();
const Size srcSize = get<0>(params);
const bool binaryImage = get<1>(params);
cv::Moments m;
UMat src(srcSize, CV_8UC1);
declare.in(src, WARMUP_RNG);
OCL_TEST_CYCLE() m = cv::moments(src, binaryImage);
SANITY_CHECK_MOMENTS(m, 1e-6, ERROR_RELATIVE);
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,134 @@
/*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 opencv_test {
namespace ocl {
///////////// PyrDown //////////////////////
typedef Size_MatType PyrDownFixture;
OCL_PERF_TEST_P(PyrDownFixture, PyrDown,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::pyrDown(src, dst);
SANITY_CHECK(dst, eps);
}
///////////// PyrUp ////////////////////////
typedef Size_MatType PyrUpFixture;
OCL_PERF_TEST_P(PyrUpFixture, PyrUp,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const Size dstSize(srcSize.height << 1, srcSize.width << 1);
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
checkDeviceMaxMemoryAllocSize(dstSize, type);
UMat src(srcSize, type), dst(dstSize, type);
declare.in(src, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::pyrUp(src, dst);
SANITY_CHECK(dst, eps);
}
///////////// buildPyramid ////////////////////////
typedef Size_MatType BuildPyramidFixture;
OCL_PERF_TEST_P(BuildPyramidFixture, BuildPyramid,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params), maxLevel = 5;
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
checkDeviceMaxMemoryAllocSize(srcSize, type);
std::vector<UMat> dst(maxLevel);
UMat src(srcSize, type);
declare.in(src, WARMUP_RNG);
OCL_TEST_CYCLE() cv::buildPyramid(src, dst, maxLevel);
UMat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];
SANITY_CHECK(dst0, eps);
SANITY_CHECK(dst1, eps);
SANITY_CHECK(dst2, eps);
SANITY_CHECK(dst3, eps);
SANITY_CHECK(dst4, eps);
}
} } // namespace opencv_test::ocl
#endif // HAVE_OPENCL

View File

@ -0,0 +1,106 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef Size_MatType Accumulate;
#define MAT_TYPES_ACCUMLATE CV_8UC1, CV_16UC1, CV_32FC1
#define MAT_TYPES_ACCUMLATE_C MAT_TYPES_ACCUMLATE, CV_8UC3, CV_16UC3, CV_32FC3
#define MAT_TYPES_ACCUMLATE_D MAT_TYPES_ACCUMLATE, CV_64FC1
#define MAT_TYPES_ACCUMLATE_D_C MAT_TYPES_ACCUMLATE_C, CV_64FC1, CV_64FC1
#define PERF_ACCUMULATE_INIT(_FLTC) \
const Size srcSize = get<0>(GetParam()); \
const int srcType = get<1>(GetParam()); \
const int dstType = _FLTC(CV_MAT_CN(srcType)); \
Mat src1(srcSize, srcType), dst(srcSize, dstType); \
declare.in(src1, dst, WARMUP_RNG).out(dst);
#define PERF_ACCUMULATE_MASK_INIT(_FLTC) \
PERF_ACCUMULATE_INIT(_FLTC) \
Mat mask(srcSize, CV_8UC1); \
declare.in(mask, WARMUP_RNG);
#define PERF_TEST_P_ACCUMULATE(_NAME, _TYPES, _INIT, _FUN) \
PERF_TEST_P(Accumulate, _NAME, \
testing::Combine( \
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD), \
testing::Values(_TYPES) \
) \
) \
{ \
_INIT \
TEST_CYCLE() _FUN; \
SANITY_CHECK_NOTHING(); \
}
/////////////////////////////////// Accumulate ///////////////////////////////////
PERF_TEST_P_ACCUMULATE(Accumulate, MAT_TYPES_ACCUMLATE,
PERF_ACCUMULATE_INIT(CV_32FC), accumulate(src1, dst))
PERF_TEST_P_ACCUMULATE(AccumulateMask, MAT_TYPES_ACCUMLATE_C,
PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulate(src1, dst, mask))
PERF_TEST_P_ACCUMULATE(AccumulateDouble, MAT_TYPES_ACCUMLATE_D,
PERF_ACCUMULATE_INIT(CV_64FC), accumulate(src1, dst))
PERF_TEST_P_ACCUMULATE(AccumulateDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
PERF_ACCUMULATE_MASK_INIT(CV_64FC), accumulate(src1, dst, mask))
///////////////////////////// AccumulateSquare ///////////////////////////////////
PERF_TEST_P_ACCUMULATE(Square, MAT_TYPES_ACCUMLATE,
PERF_ACCUMULATE_INIT(CV_32FC), accumulateSquare(src1, dst))
PERF_TEST_P_ACCUMULATE(SquareMask, MAT_TYPES_ACCUMLATE_C,
PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulateSquare(src1, dst, mask))
PERF_TEST_P_ACCUMULATE(SquareDouble, MAT_TYPES_ACCUMLATE_D,
PERF_ACCUMULATE_INIT(CV_64FC), accumulateSquare(src1, dst))
PERF_TEST_P_ACCUMULATE(SquareDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
PERF_ACCUMULATE_MASK_INIT(CV_64FC), accumulateSquare(src1, dst, mask))
///////////////////////////// AccumulateProduct ///////////////////////////////////
#define PERF_ACCUMULATE_INIT_2(_FLTC) \
PERF_ACCUMULATE_INIT(_FLTC) \
Mat src2(srcSize, srcType); \
declare.in(src2);
#define PERF_ACCUMULATE_MASK_INIT_2(_FLTC) \
PERF_ACCUMULATE_MASK_INIT(_FLTC) \
Mat src2(srcSize, srcType); \
declare.in(src2);
PERF_TEST_P_ACCUMULATE(Product, MAT_TYPES_ACCUMLATE,
PERF_ACCUMULATE_INIT_2(CV_32FC), accumulateProduct(src1, src2, dst))
PERF_TEST_P_ACCUMULATE(ProductMask, MAT_TYPES_ACCUMLATE_C,
PERF_ACCUMULATE_MASK_INIT_2(CV_32FC), accumulateProduct(src1, src2, dst, mask))
PERF_TEST_P_ACCUMULATE(ProductDouble, MAT_TYPES_ACCUMLATE_D,
PERF_ACCUMULATE_INIT_2(CV_64FC), accumulateProduct(src1, src2, dst))
PERF_TEST_P_ACCUMULATE(ProductDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
PERF_ACCUMULATE_MASK_INIT_2(CV_64FC), accumulateProduct(src1, src2, dst, mask))
///////////////////////////// AccumulateWeighted ///////////////////////////////////
PERF_TEST_P_ACCUMULATE(Weighted, MAT_TYPES_ACCUMLATE,
PERF_ACCUMULATE_INIT(CV_32FC), accumulateWeighted(src1, dst, 0.123))
PERF_TEST_P_ACCUMULATE(WeightedMask, MAT_TYPES_ACCUMLATE_C,
PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulateWeighted(src1, dst, 0.123, mask))
PERF_TEST_P_ACCUMULATE(WeightedDouble, MAT_TYPES_ACCUMLATE_D,
PERF_ACCUMULATE_INIT(CV_64FC), accumulateWeighted(src1, dst, 0.123456))
PERF_TEST_P_ACCUMULATE(WeightedDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
PERF_ACCUMULATE_MASK_INIT(CV_64FC), accumulateWeighted(src1, dst, 0.123456, mask))
} // namespace

View File

@ -0,0 +1,38 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(Mat_Type, CV_8UC1, CV_8UC3, CV_32FC1, CV_32FC3)
typedef TestBaseWithParam< tuple<Size, int, Mat_Type> > TestBilateralFilter;
PERF_TEST_P( TestBilateralFilter, BilateralFilter,
Combine(
Values( szVGA, sz1080p ), // image size
Values( 3, 5 ), // d
Mat_Type::all() // image type
)
)
{
Size sz;
int d, type;
const double sigmaColor = 1., sigmaSpace = 1.;
sz = get<0>(GetParam());
d = get<1>(GetParam());
type = get<2>(GetParam());
Mat src(sz, type);
Mat dst(sz, type);
declare.in(src, WARMUP_RNG).out(dst).time(20);
TEST_CYCLE() bilateralFilter(src, dst, d, sigmaColor, sigmaSpace, BORDER_DEFAULT);
SANITY_CHECK(dst, .01, ERROR_RELATIVE);
}
} // namespace

View File

@ -0,0 +1,256 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<Size, MatType, int> Size_MatType_kSize_t;
typedef perf::TestBaseWithParam<Size_MatType_kSize_t> Size_MatType_kSize;
PERF_TEST_P(Size_MatType_kSize, medianBlur,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
testing::Values(3, 5)
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
int ksize = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
if (CV_MAT_DEPTH(type) > CV_16S || CV_MAT_CN(type) > 1)
declare.time(15);
TEST_CYCLE() medianBlur(src, dst, ksize);
SANITY_CHECK(dst);
}
CV_ENUM(BorderType3x3, BORDER_REPLICATE, BORDER_CONSTANT)
CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT101)
typedef tuple<Size, MatType, BorderType3x3> Size_MatType_BorderType3x3_t;
typedef perf::TestBaseWithParam<Size_MatType_BorderType3x3_t> Size_MatType_BorderType3x3;
typedef tuple<Size, MatType, BorderType> Size_MatType_BorderType_t;
typedef perf::TestBaseWithParam<Size_MatType_BorderType_t> Size_MatType_BorderType;
typedef tuple<Size, int, BorderType3x3> Size_ksize_BorderType_t;
typedef perf::TestBaseWithParam<Size_ksize_BorderType_t> Size_ksize_BorderType;
PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType3x3 btype = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() GaussianBlur(src, dst, Size(3,3), 0, 0, btype);
SANITY_CHECK(dst, 1);
}
PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType3x3 btype = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() blur(src, dst, Size(3,3), Point(-1,-1), btype);
SANITY_CHECK(dst, 1);
}
PERF_TEST_P(Size_MatType_BorderType, blur16x16,
testing::Combine(
testing::Values(szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
BorderType::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType btype = get<2>(GetParam());
double eps = 1e-3;
eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() blur(src, dst, Size(16,16), Point(-1,-1), btype);
SANITY_CHECK(dst, eps);
}
PERF_TEST_P(Size_MatType_BorderType3x3, box3x3,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType3x3 btype = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() boxFilter(src, dst, -1, Size(3,3), Point(-1,-1), false, btype);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
PERF_TEST_P(Size_ksize_BorderType, box_CV8U_CV16U,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(3, 5, 15),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int ksize = get<1>(GetParam());
BorderType3x3 btype = get<2>(GetParam());
Mat src(size, CV_8UC1);
Mat dst(size, CV_16UC1);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() boxFilter(src, dst, CV_16UC1, Size(ksize, ksize), Point(-1,-1), false, btype);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
PERF_TEST_P(Size_MatType_BorderType3x3, box3x3_inplace,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC3),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType3x3 btype = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
while(next())
{
src.copyTo(dst);
startTimer();
boxFilter(dst, dst, -1, Size(3,3), Point(-1,-1), false, btype);
stopTimer();
}
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5,
testing::Combine(
testing::Values(szODD, szQVGA, szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
BorderType::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType btype = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() GaussianBlur(src, dst, Size(5,5), 0, 0, btype);
SANITY_CHECK(dst, 1);
}
PERF_TEST_P(Size_MatType_BorderType, blur5x5,
testing::Combine(
testing::Values(szVGA, sz720p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1, CV_32FC3),
BorderType::all()
)
)
{
Size size = get<0>(GetParam());
int type = get<1>(GetParam());
BorderType btype = get<2>(GetParam());
Mat src(size, type);
Mat dst(size, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() blur(src, dst, Size(5,5), Point(-1,-1), btype);
SANITY_CHECK(dst, 1);
}
///////////// BlendLinear ////////////////////////
PERF_TEST_P(Size_MatType, BlendLinear,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, sz2160p),
testing::Values(CV_8UC1, CV_32FC1, CV_8UC3, CV_32FC3, CV_8UC4, CV_32FC4)
)
)
{
const Size srcSize = get<0>(GetParam());
const int srcType = get<1>(GetParam());
Mat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, srcType);
Mat weights1(srcSize, CV_32FC1), weights2(srcSize, CV_32FC1);
declare.in(src1, src2, WARMUP_RNG).in(weights1, weights2, WARMUP_READ).out(dst);
randu(weights1, 0, 1);
randu(weights2, 0, 1);
TEST_CYCLE() blendLinear(src1, src2, weights1, weights2, dst);
SANITY_CHECK_NOTHING();
}
} // namespace

View File

@ -0,0 +1,40 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<string, int, bool, tuple<double, double> > Img_Aperture_L2_thresholds_t;
typedef perf::TestBaseWithParam<Img_Aperture_L2_thresholds_t> Img_Aperture_L2_thresholds;
PERF_TEST_P(Img_Aperture_L2_thresholds, canny,
testing::Combine(
testing::Values( "cv/shared/lena.png", "stitching/b1.png", "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png" ),
testing::Values( 3, 5 ),
testing::Bool(),
testing::Values( make_tuple(50.0, 100.0), make_tuple(0.0, 50.0), make_tuple(100.0, 120.0) )
)
)
{
string filename = getDataPath(get<0>(GetParam()));
int aperture = get<1>(GetParam());
bool useL2 = get<2>(GetParam());
double thresh_low = get<0>(get<3>(GetParam()));
double thresh_high = get<1>(get<3>(GetParam()));
Mat img = imread(filename, IMREAD_GRAYSCALE);
if (img.empty())
FAIL() << "Unable to load source image " << filename;
Mat edges(img.size(), img.type());
declare.in(img).out(edges);
PERF_SAMPLE_BEGIN();
Canny(img, edges, thresh_low, thresh_high, aperture, useL2);
PERF_SAMPLE_END();
SANITY_CHECK(edges);
}
} // namespace

View File

@ -0,0 +1,109 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test { namespace {
CV_ENUM(RetrMode, RETR_EXTERNAL, RETR_LIST, RETR_CCOMP, RETR_TREE)
CV_ENUM(ApproxMode, CHAIN_APPROX_NONE, CHAIN_APPROX_SIMPLE, CHAIN_APPROX_TC89_L1, CHAIN_APPROX_TC89_KCOS)
typedef TestBaseWithParam< tuple<Size, RetrMode, ApproxMode, int> > TestFindContours;
PERF_TEST_P(TestFindContours, findContours,
Combine(
Values( szVGA, sz1080p ), // image size
RetrMode::all(), // retrieval mode
ApproxMode::all(), // approximation method
Values( 32, 128 ) // blob count
)
)
{
Size img_size = get<0>(GetParam());
int retr_mode = get<1>(GetParam());
int approx_method = get<2>(GetParam());
int blob_count = get<3>(GetParam());
RNG rng;
Mat img = Mat::zeros(img_size, CV_8UC1);
for(int i = 0; i < blob_count; i++ )
{
Point center;
center.x = (unsigned)rng % (img.cols-2);
center.y = (unsigned)rng % (img.rows-2);
Size axes;
axes.width = ((unsigned)rng % 49 + 2)/2;
axes.height = ((unsigned)rng % 49 + 2)/2;
double angle = (unsigned)rng % 180;
int brightness = (unsigned)rng % 2;
// keep the border clear
ellipse( img(Rect(1,1,img.cols-2,img.rows-2)), Point(center), Size(axes), angle, 0., 360., Scalar(brightness), -1);
}
vector< vector<Point> > contours;
TEST_CYCLE() findContours( img, contours, retr_mode, approx_method );
SANITY_CHECK_NOTHING();
}
typedef TestBaseWithParam< tuple<Size, ApproxMode, int> > TestFindContoursFF;
PERF_TEST_P(TestFindContoursFF, findContours,
Combine(
Values(szVGA, sz1080p), // image size
ApproxMode::all(), // approximation method
Values(32, 128) // blob count
)
)
{
Size img_size = get<0>(GetParam());
int approx_method = get<1>(GetParam());
int blob_count = get<2>(GetParam());
RNG rng;
Mat img = Mat::zeros(img_size, CV_32SC1);
for (int i = 0; i < blob_count; i++)
{
Point center;
center.x = (unsigned)rng % (img.cols - 2);
center.y = (unsigned)rng % (img.rows - 2);
Size axes;
axes.width = ((unsigned)rng % 49 + 2) / 2;
axes.height = ((unsigned)rng % 49 + 2) / 2;
double angle = (unsigned)rng % 180;
int brightness = (unsigned)rng % 2;
// keep the border clear
ellipse(img(Rect(1, 1, img.cols - 2, img.rows - 2)), Point(center), Size(axes), angle, 0., 360., Scalar(brightness), -1);
}
vector< vector<Point> > contours;
TEST_CYCLE() findContours(img, contours, RETR_FLOODFILL, approx_method);
SANITY_CHECK_NOTHING();
}
typedef TestBaseWithParam< tuple<MatDepth, int> > TestBoundingRect;
PERF_TEST_P(TestBoundingRect, BoundingRect,
Combine(
testing::Values(CV_32S, CV_32F), // points type
Values(400, 511, 1000, 10000, 100000) // points count
)
)
{
int ptType = get<0>(GetParam());
int n = get<1>(GetParam());
Mat pts(n, 2, ptType);
declare.in(pts, WARMUP_RNG);
cv::Rect rect;
TEST_CYCLE() rect = boundingRect(pts);
SANITY_CHECK_NOTHING();
}
} } // namespace

View File

@ -0,0 +1,93 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101)
typedef tuple<string, int, int, double, BorderType> Img_BlockSize_ApertureSize_k_BorderType_t;
typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_k_BorderType_t> Img_BlockSize_ApertureSize_k_BorderType;
PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
testing::Combine(
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
testing::Values( 3, 5 ),
testing::Values( 3, 5 ),
testing::Values( 0.04, 0.1 ),
BorderType::all()
)
)
{
string filename = getDataPath(get<0>(GetParam()));
int blockSize = get<1>(GetParam());
int apertureSize = get<2>(GetParam());
double k = get<3>(GetParam());
BorderType borderType = get<4>(GetParam());
Mat src = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
Mat dst;
TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType);
SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
}
typedef tuple<string, int, int, BorderType> Img_BlockSize_ApertureSize_BorderType_t;
typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_BorderType_t> Img_BlockSize_ApertureSize_BorderType;
PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs,
testing::Combine(
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
testing::Values( 3, 5 ),
testing::Values( 3, 5 ),
BorderType::all()
)
)
{
string filename = getDataPath(get<0>(GetParam()));
int blockSize = get<1>(GetParam());
int apertureSize = get<2>(GetParam());
BorderType borderType = get<3>(GetParam());
Mat src = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
Mat dst;
TEST_CYCLE() cornerEigenValsAndVecs(src, dst, blockSize, apertureSize, borderType);
Mat l1;
extractChannel(dst, l1, 0);
SANITY_CHECK(l1, 2e-5, ERROR_RELATIVE);
}
PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal,
testing::Combine(
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
testing::Values( 3, 5 ),
testing::Values( 3, 5 ),
BorderType::all()
)
)
{
string filename = getDataPath(get<0>(GetParam()));
int blockSize = get<1>(GetParam());
int apertureSize = get<2>(GetParam());
BorderType borderType = get<3>(GetParam());
Mat src = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
Mat dst;
TEST_CYCLE() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
}
} // namespace

View File

@ -0,0 +1,499 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
//extra color conversions supported implicitly
enum
{
CX_BGRA2HLS = COLOR_COLORCVT_MAX + COLOR_BGR2HLS,
CX_BGRA2HLS_FULL = COLOR_COLORCVT_MAX + COLOR_BGR2HLS_FULL,
CX_BGRA2HSV = COLOR_COLORCVT_MAX + COLOR_BGR2HSV,
CX_BGRA2HSV_FULL = COLOR_COLORCVT_MAX + COLOR_BGR2HSV_FULL,
CX_BGRA2Lab = COLOR_COLORCVT_MAX + COLOR_BGR2Lab,
CX_BGRA2Luv = COLOR_COLORCVT_MAX + COLOR_BGR2Luv,
CX_BGRA2XYZ = COLOR_COLORCVT_MAX + COLOR_BGR2XYZ,
CX_BGRA2YCrCb = COLOR_COLORCVT_MAX + COLOR_BGR2YCrCb,
CX_BGRA2YUV = COLOR_COLORCVT_MAX + COLOR_BGR2YUV,
CX_HLS2BGRA = COLOR_COLORCVT_MAX + COLOR_HLS2BGR,
CX_HLS2BGRA_FULL = COLOR_COLORCVT_MAX + COLOR_HLS2BGR_FULL,
CX_HLS2RGBA = COLOR_COLORCVT_MAX + COLOR_HLS2RGB,
CX_HLS2RGBA_FULL = COLOR_COLORCVT_MAX + COLOR_HLS2RGB_FULL,
CX_HSV2BGRA = COLOR_COLORCVT_MAX + COLOR_HSV2BGR,
CX_HSV2BGRA_FULL = COLOR_COLORCVT_MAX + COLOR_HSV2BGR_FULL,
CX_HSV2RGBA = COLOR_COLORCVT_MAX + COLOR_HSV2RGB,
CX_HSV2RGBA_FULL = COLOR_COLORCVT_MAX + COLOR_HSV2RGB_FULL,
CX_Lab2BGRA = COLOR_COLORCVT_MAX + COLOR_Lab2BGR,
CX_Lab2LBGRA = COLOR_COLORCVT_MAX + COLOR_Lab2LBGR,
CX_Lab2LRGBA = COLOR_COLORCVT_MAX + COLOR_Lab2LRGB,
CX_Lab2RGBA = COLOR_COLORCVT_MAX + COLOR_Lab2RGB,
CX_LBGRA2Lab = COLOR_COLORCVT_MAX + COLOR_LBGR2Lab,
CX_LBGRA2Luv = COLOR_COLORCVT_MAX + COLOR_LBGR2Luv,
CX_LRGBA2Lab = COLOR_COLORCVT_MAX + COLOR_LRGB2Lab,
CX_LRGBA2Luv = COLOR_COLORCVT_MAX + COLOR_LRGB2Luv,
CX_Luv2BGRA = COLOR_COLORCVT_MAX + COLOR_Luv2BGR,
CX_Luv2LBGRA = COLOR_COLORCVT_MAX + COLOR_Luv2LBGR,
CX_Luv2LRGBA = COLOR_COLORCVT_MAX + COLOR_Luv2LRGB,
CX_Luv2RGBA = COLOR_COLORCVT_MAX + COLOR_Luv2RGB,
CX_RGBA2HLS = COLOR_COLORCVT_MAX + COLOR_RGB2HLS,
CX_RGBA2HLS_FULL = COLOR_COLORCVT_MAX + COLOR_RGB2HLS_FULL,
CX_RGBA2HSV = COLOR_COLORCVT_MAX + COLOR_RGB2HSV,
CX_RGBA2HSV_FULL = COLOR_COLORCVT_MAX + COLOR_RGB2HSV_FULL,
CX_RGBA2Lab = COLOR_COLORCVT_MAX + COLOR_RGB2Lab,
CX_RGBA2Luv = COLOR_COLORCVT_MAX + COLOR_RGB2Luv,
CX_RGBA2XYZ = COLOR_COLORCVT_MAX + COLOR_RGB2XYZ,
CX_RGBA2YCrCb = COLOR_COLORCVT_MAX + COLOR_RGB2YCrCb,
CX_RGBA2YUV = COLOR_COLORCVT_MAX + COLOR_RGB2YUV,
CX_XYZ2BGRA = COLOR_COLORCVT_MAX + COLOR_XYZ2BGR,
CX_XYZ2RGBA = COLOR_COLORCVT_MAX + COLOR_XYZ2RGB,
CX_YCrCb2BGRA = COLOR_COLORCVT_MAX + COLOR_YCrCb2BGR,
CX_YCrCb2RGBA = COLOR_COLORCVT_MAX + COLOR_YCrCb2RGB,
CX_YUV2BGRA = COLOR_COLORCVT_MAX + COLOR_YUV2BGR,
CX_YUV2RGBA = COLOR_COLORCVT_MAX + COLOR_YUV2RGB
};
CV_ENUM(CvtMode,
COLOR_BGR2BGR555, COLOR_BGR2BGR565, COLOR_BGR2BGRA, COLOR_BGR2GRAY,
COLOR_BGR2HLS, COLOR_BGR2HLS_FULL, COLOR_BGR2HSV, COLOR_BGR2HSV_FULL,
COLOR_BGR2Lab, COLOR_BGR2Luv, COLOR_BGR2RGB, COLOR_BGR2RGBA, COLOR_BGR2XYZ,
COLOR_BGR2YCrCb, COLOR_BGR2YUV, COLOR_BGR5552BGR, COLOR_BGR5552BGRA,
COLOR_BGR5552GRAY, COLOR_BGR5552RGB, COLOR_BGR5552RGBA, COLOR_BGR5652BGR,
COLOR_BGR5652BGRA, COLOR_BGR5652GRAY, COLOR_BGR5652RGB, COLOR_BGR5652RGBA,
COLOR_BGRA2BGR, COLOR_BGRA2BGR555, COLOR_BGRA2BGR565, COLOR_BGRA2GRAY, COLOR_BGRA2RGBA,
CX_BGRA2HLS, CX_BGRA2HLS_FULL, CX_BGRA2HSV, CX_BGRA2HSV_FULL,
CX_BGRA2Lab, CX_BGRA2Luv, CX_BGRA2XYZ,
CX_BGRA2YCrCb, CX_BGRA2YUV,
COLOR_GRAY2BGR, COLOR_GRAY2BGR555, COLOR_GRAY2BGR565, COLOR_GRAY2BGRA,
COLOR_HLS2BGR, COLOR_HLS2BGR_FULL, COLOR_HLS2RGB, COLOR_HLS2RGB_FULL,
CX_HLS2BGRA, CX_HLS2BGRA_FULL, CX_HLS2RGBA, CX_HLS2RGBA_FULL,
COLOR_HSV2BGR, COLOR_HSV2BGR_FULL, COLOR_HSV2RGB, COLOR_HSV2RGB_FULL,
CX_HSV2BGRA, CX_HSV2BGRA_FULL, CX_HSV2RGBA, CX_HSV2RGBA_FULL,
COLOR_Lab2BGR, COLOR_Lab2LBGR, COLOR_Lab2LRGB, COLOR_Lab2RGB,
CX_Lab2BGRA, CX_Lab2LBGRA, CX_Lab2LRGBA, CX_Lab2RGBA,
COLOR_LBGR2Lab, COLOR_LBGR2Luv, COLOR_LRGB2Lab, COLOR_LRGB2Luv,
CX_LBGRA2Lab, CX_LBGRA2Luv, CX_LRGBA2Lab, CX_LRGBA2Luv,
COLOR_Luv2BGR, COLOR_Luv2LBGR, COLOR_Luv2LRGB, COLOR_Luv2RGB,
CX_Luv2BGRA, CX_Luv2LBGRA, CX_Luv2LRGBA, CX_Luv2RGBA,
COLOR_RGB2BGR555, COLOR_RGB2BGR565, COLOR_RGB2GRAY,
COLOR_RGB2HLS, COLOR_RGB2HLS_FULL, COLOR_RGB2HSV, COLOR_RGB2HSV_FULL,
COLOR_RGB2Lab, COLOR_RGB2Luv, COLOR_RGB2XYZ, COLOR_RGB2YCrCb, COLOR_RGB2YUV,
COLOR_RGBA2BGR, COLOR_RGBA2BGR555, COLOR_RGBA2BGR565, COLOR_RGBA2GRAY,
CX_RGBA2HLS, CX_RGBA2HLS_FULL, CX_RGBA2HSV, CX_RGBA2HSV_FULL,
CX_RGBA2Lab, CX_RGBA2Luv, CX_RGBA2XYZ,
CX_RGBA2YCrCb, CX_RGBA2YUV,
COLOR_XYZ2BGR, COLOR_XYZ2RGB, CX_XYZ2BGRA, CX_XYZ2RGBA,
COLOR_YCrCb2BGR, COLOR_YCrCb2RGB, CX_YCrCb2BGRA, CX_YCrCb2RGBA,
COLOR_YUV2BGR, COLOR_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA
)
CV_ENUM(CvtMode16U,
COLOR_BGR2BGRA, COLOR_BGR2GRAY,
COLOR_BGR2RGB, COLOR_BGR2RGBA, COLOR_BGR2XYZ,
COLOR_BGR2YCrCb, COLOR_BGR2YUV,
COLOR_BGRA2BGR, COLOR_BGRA2GRAY, COLOR_BGRA2RGBA,
CX_BGRA2XYZ,
CX_BGRA2YCrCb, CX_BGRA2YUV,
COLOR_GRAY2BGR, COLOR_GRAY2BGRA,
COLOR_RGB2GRAY,
COLOR_RGB2XYZ, COLOR_RGB2YCrCb, COLOR_RGB2YUV,
COLOR_RGBA2BGR, COLOR_RGBA2GRAY,
CX_RGBA2XYZ,
CX_RGBA2YCrCb, CX_RGBA2YUV,
COLOR_XYZ2BGR, COLOR_XYZ2RGB, CX_XYZ2BGRA, CX_XYZ2RGBA,
COLOR_YCrCb2BGR, COLOR_YCrCb2RGB, CX_YCrCb2BGRA, CX_YCrCb2RGBA,
COLOR_YUV2BGR, COLOR_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA
)
CV_ENUM(CvtMode32F,
COLOR_BGR2BGRA, COLOR_BGR2GRAY,
COLOR_BGR2HLS, COLOR_BGR2HLS_FULL, COLOR_BGR2HSV, COLOR_BGR2HSV_FULL,
COLOR_BGR2Lab, COLOR_BGR2Luv, COLOR_BGR2RGB, COLOR_BGR2RGBA, COLOR_BGR2XYZ,
COLOR_BGR2YCrCb, COLOR_BGR2YUV,
COLOR_BGRA2BGR, COLOR_BGRA2GRAY, COLOR_BGRA2RGBA,
CX_BGRA2HLS, CX_BGRA2HLS_FULL, CX_BGRA2HSV, CX_BGRA2HSV_FULL,
CX_BGRA2Lab, CX_BGRA2Luv, CX_BGRA2XYZ,
CX_BGRA2YCrCb, CX_BGRA2YUV,
COLOR_GRAY2BGR, COLOR_GRAY2BGRA,
COLOR_HLS2BGR, COLOR_HLS2BGR_FULL, COLOR_HLS2RGB, COLOR_HLS2RGB_FULL,
CX_HLS2BGRA, CX_HLS2BGRA_FULL, CX_HLS2RGBA, CX_HLS2RGBA_FULL,
COLOR_HSV2BGR, COLOR_HSV2BGR_FULL, COLOR_HSV2RGB, COLOR_HSV2RGB_FULL,
CX_HSV2BGRA, CX_HSV2BGRA_FULL, CX_HSV2RGBA, CX_HSV2RGBA_FULL,
COLOR_Lab2BGR, COLOR_Lab2LBGR, COLOR_Lab2LRGB, COLOR_Lab2RGB,
CX_Lab2BGRA, CX_Lab2LBGRA, CX_Lab2LRGBA, CX_Lab2RGBA,
COLOR_LBGR2Lab, COLOR_LBGR2Luv, COLOR_LRGB2Lab, COLOR_LRGB2Luv,
CX_LBGRA2Lab, CX_LBGRA2Luv, CX_LRGBA2Lab, CX_LRGBA2Luv,
COLOR_Luv2BGR, COLOR_Luv2LBGR, COLOR_Luv2LRGB, COLOR_Luv2RGB,
CX_Luv2BGRA, CX_Luv2LBGRA, CX_Luv2LRGBA, CX_Luv2RGBA,
COLOR_RGB2GRAY,
COLOR_RGB2HLS, COLOR_RGB2HLS_FULL, COLOR_RGB2HSV, COLOR_RGB2HSV_FULL,
COLOR_RGB2Lab, COLOR_RGB2Luv, COLOR_RGB2XYZ, COLOR_RGB2YCrCb, COLOR_RGB2YUV,
COLOR_RGBA2BGR, COLOR_RGBA2GRAY,
CX_RGBA2HLS, CX_RGBA2HLS_FULL, CX_RGBA2HSV, CX_RGBA2HSV_FULL,
CX_RGBA2Lab, CX_RGBA2Luv, CX_RGBA2XYZ,
CX_RGBA2YCrCb, CX_RGBA2YUV,
COLOR_XYZ2BGR, COLOR_XYZ2RGB, CX_XYZ2BGRA, CX_XYZ2RGBA,
COLOR_YCrCb2BGR, COLOR_YCrCb2RGB, CX_YCrCb2BGRA, CX_YCrCb2RGBA,
COLOR_YUV2BGR, COLOR_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA
)
CV_ENUM(CvtModeBayer,
COLOR_BayerBG2BGR, COLOR_BayerBG2BGRA, COLOR_BayerBG2BGR_VNG, COLOR_BayerBG2GRAY,
COLOR_BayerGB2BGR, COLOR_BayerGB2BGRA, COLOR_BayerGB2BGR_VNG, COLOR_BayerGB2GRAY,
COLOR_BayerGR2BGR, COLOR_BayerGR2BGRA, COLOR_BayerGR2BGR_VNG, COLOR_BayerGR2GRAY,
COLOR_BayerRG2BGR, COLOR_BayerRG2BGRA, COLOR_BayerRG2BGR_VNG, COLOR_BayerRG2GRAY
)
CV_ENUM(CvtMode2, COLOR_YUV2BGR_NV12, COLOR_YUV2BGRA_NV12, COLOR_YUV2RGB_NV12, COLOR_YUV2RGBA_NV12, COLOR_YUV2BGR_NV21, COLOR_YUV2BGRA_NV21, COLOR_YUV2RGB_NV21, COLOR_YUV2RGBA_NV21,
COLOR_YUV2BGR_YV12, COLOR_YUV2BGRA_YV12, COLOR_YUV2RGB_YV12, COLOR_YUV2RGBA_YV12, COLOR_YUV2BGR_IYUV, COLOR_YUV2BGRA_IYUV, COLOR_YUV2RGB_IYUV, COLOR_YUV2RGBA_IYUV,
COLOR_YUV2GRAY_420, COLOR_YUV2RGB_UYVY, COLOR_YUV2BGR_UYVY, COLOR_YUV2RGBA_UYVY, COLOR_YUV2BGRA_UYVY, COLOR_YUV2RGB_YUY2, COLOR_YUV2BGR_YUY2, COLOR_YUV2RGB_YVYU,
COLOR_YUV2BGR_YVYU, COLOR_YUV2RGBA_YUY2, COLOR_YUV2BGRA_YUY2, COLOR_YUV2RGBA_YVYU, COLOR_YUV2BGRA_YVYU)
CV_ENUM(CvtMode3, COLOR_RGB2YUV_IYUV, COLOR_BGR2YUV_IYUV, COLOR_RGBA2YUV_IYUV, COLOR_BGRA2YUV_IYUV,
COLOR_RGB2YUV_YV12, COLOR_BGR2YUV_YV12, COLOR_RGBA2YUV_YV12, COLOR_BGRA2YUV_YV12)
struct ChPair
{
ChPair(int _scn, int _dcn): scn(_scn), dcn(_dcn) {}
int scn, dcn;
};
static ChPair getConversionInfo(int cvtMode)
{
switch(cvtMode)
{
case COLOR_BayerBG2GRAY: case COLOR_BayerGB2GRAY:
case COLOR_BayerGR2GRAY: case COLOR_BayerRG2GRAY:
case COLOR_YUV2GRAY_420:
return ChPair(1,1);
case COLOR_GRAY2BGR555: case COLOR_GRAY2BGR565:
return ChPair(1,2);
case COLOR_BayerBG2BGR: case COLOR_BayerBG2BGR_VNG:
case COLOR_BayerGB2BGR: case COLOR_BayerGB2BGR_VNG:
case COLOR_BayerGR2BGR: case COLOR_BayerGR2BGR_VNG:
case COLOR_BayerRG2BGR: case COLOR_BayerRG2BGR_VNG:
case COLOR_GRAY2BGR:
case COLOR_YUV2BGR_NV12: case COLOR_YUV2RGB_NV12:
case COLOR_YUV2BGR_NV21: case COLOR_YUV2RGB_NV21:
case COLOR_YUV2BGR_YV12: case COLOR_YUV2RGB_YV12:
case COLOR_YUV2BGR_IYUV: case COLOR_YUV2RGB_IYUV:
return ChPair(1,3);
case COLOR_GRAY2BGRA:
case COLOR_YUV2BGRA_NV12: case COLOR_YUV2RGBA_NV12:
case COLOR_YUV2BGRA_NV21: case COLOR_YUV2RGBA_NV21:
case COLOR_YUV2BGRA_YV12: case COLOR_YUV2RGBA_YV12:
case COLOR_YUV2BGRA_IYUV: case COLOR_YUV2RGBA_IYUV:
case COLOR_BayerBG2BGRA: case COLOR_BayerGB2BGRA:
case COLOR_BayerGR2BGRA: case COLOR_BayerRG2BGRA:
return ChPair(1,4);
case COLOR_BGR5552GRAY: case COLOR_BGR5652GRAY:
return ChPair(2,1);
case COLOR_BGR5552BGR: case COLOR_BGR5552RGB:
case COLOR_BGR5652BGR: case COLOR_BGR5652RGB:
case COLOR_YUV2RGB_UYVY: case COLOR_YUV2BGR_UYVY:
case COLOR_YUV2RGB_YUY2: case COLOR_YUV2BGR_YUY2:
case COLOR_YUV2RGB_YVYU: case COLOR_YUV2BGR_YVYU:
return ChPair(2,3);
case COLOR_BGR5552BGRA: case COLOR_BGR5552RGBA:
case COLOR_BGR5652BGRA: case COLOR_BGR5652RGBA:
case COLOR_YUV2RGBA_UYVY: case COLOR_YUV2BGRA_UYVY:
case COLOR_YUV2RGBA_YUY2: case COLOR_YUV2BGRA_YUY2:
case COLOR_YUV2RGBA_YVYU: case COLOR_YUV2BGRA_YVYU:
return ChPair(2,4);
case COLOR_BGR2GRAY: case COLOR_RGB2GRAY:
case COLOR_RGB2YUV_IYUV: case COLOR_RGB2YUV_YV12:
case COLOR_BGR2YUV_IYUV: case COLOR_BGR2YUV_YV12:
return ChPair(3,1);
case COLOR_BGR2BGR555: case COLOR_BGR2BGR565:
case COLOR_RGB2BGR555: case COLOR_RGB2BGR565:
return ChPair(3,2);
case COLOR_BGR2HLS: case COLOR_BGR2HLS_FULL:
case COLOR_BGR2HSV: case COLOR_BGR2HSV_FULL:
case COLOR_BGR2Lab: case COLOR_BGR2Luv:
case COLOR_BGR2RGB: case COLOR_BGR2XYZ:
case COLOR_BGR2YCrCb: case COLOR_BGR2YUV:
case COLOR_HLS2BGR: case COLOR_HLS2BGR_FULL:
case COLOR_HLS2RGB: case COLOR_HLS2RGB_FULL:
case COLOR_HSV2BGR: case COLOR_HSV2BGR_FULL:
case COLOR_HSV2RGB: case COLOR_HSV2RGB_FULL:
case COLOR_Lab2BGR: case COLOR_Lab2LBGR:
case COLOR_Lab2LRGB: case COLOR_Lab2RGB:
case COLOR_LBGR2Lab: case COLOR_LBGR2Luv:
case COLOR_LRGB2Lab: case COLOR_LRGB2Luv:
case COLOR_Luv2BGR: case COLOR_Luv2LBGR:
case COLOR_Luv2LRGB: case COLOR_Luv2RGB:
case COLOR_RGB2HLS: case COLOR_RGB2HLS_FULL:
case COLOR_RGB2HSV: case COLOR_RGB2HSV_FULL:
case COLOR_RGB2Lab: case COLOR_RGB2Luv:
case COLOR_RGB2XYZ: case COLOR_RGB2YCrCb:
case COLOR_RGB2YUV: case COLOR_XYZ2BGR:
case COLOR_XYZ2RGB: case COLOR_YCrCb2BGR:
case COLOR_YCrCb2RGB: case COLOR_YUV2BGR:
case COLOR_YUV2RGB:
return ChPair(3,3);
case COLOR_BGR2BGRA: case COLOR_BGR2RGBA:
case CX_HLS2BGRA: case CX_HLS2BGRA_FULL:
case CX_HLS2RGBA: case CX_HLS2RGBA_FULL:
case CX_HSV2BGRA: case CX_HSV2BGRA_FULL:
case CX_HSV2RGBA: case CX_HSV2RGBA_FULL:
case CX_Lab2BGRA: case CX_Lab2LBGRA:
case CX_Lab2LRGBA: case CX_Lab2RGBA:
case CX_Luv2BGRA: case CX_Luv2LBGRA:
case CX_Luv2LRGBA: case CX_Luv2RGBA:
case CX_XYZ2BGRA: case CX_XYZ2RGBA:
case CX_YCrCb2BGRA: case CX_YCrCb2RGBA:
case CX_YUV2BGRA: case CX_YUV2RGBA:
return ChPair(3,4);
case COLOR_BGRA2GRAY: case COLOR_RGBA2GRAY:
case COLOR_RGBA2YUV_IYUV: case COLOR_RGBA2YUV_YV12:
case COLOR_BGRA2YUV_IYUV: case COLOR_BGRA2YUV_YV12:
return ChPair(4,1);
case COLOR_BGRA2BGR555: case COLOR_BGRA2BGR565:
case COLOR_RGBA2BGR555: case COLOR_RGBA2BGR565:
return ChPair(4,2);
case COLOR_BGRA2BGR: case CX_BGRA2HLS:
case CX_BGRA2HLS_FULL: case CX_BGRA2HSV:
case CX_BGRA2HSV_FULL: case CX_BGRA2Lab:
case CX_BGRA2Luv: case CX_BGRA2XYZ:
case CX_BGRA2YCrCb: case CX_BGRA2YUV:
case CX_LBGRA2Lab: case CX_LBGRA2Luv:
case CX_LRGBA2Lab: case CX_LRGBA2Luv:
case COLOR_RGBA2BGR: case CX_RGBA2HLS:
case CX_RGBA2HLS_FULL: case CX_RGBA2HSV:
case CX_RGBA2HSV_FULL: case CX_RGBA2Lab:
case CX_RGBA2Luv: case CX_RGBA2XYZ:
case CX_RGBA2YCrCb: case CX_RGBA2YUV:
return ChPair(4,3);
case COLOR_BGRA2RGBA:
return ChPair(4,4);
default:
ADD_FAILURE() << "Unknown conversion type";
break;
};
return ChPair(0,0);
}
typedef tuple<Size, CvtMode> Size_CvtMode_t;
typedef perf::TestBaseWithParam<Size_CvtMode_t> Size_CvtMode;
PERF_TEST_P(Size_CvtMode, cvtColor8u,
testing::Combine(
testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p),
CvtMode::all()
)
)
{
Size sz = get<0>(GetParam());
int _mode = get<1>(GetParam()), mode = _mode;
ChPair ch = getConversionInfo(mode);
mode %= COLOR_COLORCVT_MAX;
Mat src(sz, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.time(100);
declare.in(src, WARMUP_RNG).out(dst);
int runs = sz.width <= 320 ? 100 : 5;
TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn);
#if defined(__APPLE__) && defined(HAVE_IPP)
SANITY_CHECK(dst, _mode == CX_BGRA2HLS_FULL ? 2 : 1);
#elif defined(_MSC_VER) && _MSC_VER >= 1900 /* MSVC 14 */
if (_mode == CX_Luv2BGRA)
SANITY_CHECK_NOTHING();
else
SANITY_CHECK(dst, 1);
#else
SANITY_CHECK(dst, 1);
#endif
}
typedef tuple<Size, CvtMode16U> Size_CvtMode16U_t;
typedef perf::TestBaseWithParam<Size_CvtMode16U_t> Size_CvtMode16U;
PERF_TEST_P(Size_CvtMode16U, DISABLED_cvtColor_16u,
testing::Combine(
testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p),
CvtMode16U::all()
)
)
{
Size sz = get<0>(GetParam());
int _mode = get<1>(GetParam()), mode = _mode;
ChPair ch = getConversionInfo(mode);
mode %= COLOR_COLORCVT_MAX;
Mat src(sz, CV_16UC(ch.scn));
Mat dst(sz, CV_16UC(ch.scn));
declare.time(100);
declare.in(src, WARMUP_RNG).out(dst);
int runs = sz.width <= 320 ? 100 : 5;
TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}
typedef tuple<Size, CvtMode32F> Size_CvtMode32F_t;
typedef perf::TestBaseWithParam<Size_CvtMode32F_t> Size_CvtMode32F;
PERF_TEST_P(Size_CvtMode32F, DISABLED_cvtColor_32f,
testing::Combine(
testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p),
CvtMode32F::all()
)
)
{
Size sz = get<0>(GetParam());
int _mode = get<1>(GetParam()), mode = _mode;
ChPair ch = getConversionInfo(mode);
mode %= COLOR_COLORCVT_MAX;
Mat src(sz, CV_32FC(ch.scn));
Mat dst(sz, CV_32FC(ch.scn));
declare.time(100);
declare.in(src, WARMUP_RNG).out(dst);
int runs = sz.width <= 320 ? 100 : 5;
TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK_NOTHING();
}
typedef tuple<Size, CvtModeBayer> Size_CvtMode_Bayer_t;
typedef perf::TestBaseWithParam<Size_CvtMode_Bayer_t> Size_CvtMode_Bayer;
PERF_TEST_P(Size_CvtMode_Bayer, cvtColorBayer8u,
testing::Combine(
testing::Values(::perf::szODD, ::perf::szVGA),
CvtModeBayer::all()
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
mode %= COLOR_COLORCVT_MAX;
Mat src(sz, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.time(100);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK_NOTHING();
}
typedef tuple<Size, CvtMode2> Size_CvtMode2_t;
typedef perf::TestBaseWithParam<Size_CvtMode2_t> Size_CvtMode2;
PERF_TEST_P(Size_CvtMode2, cvtColorYUV420,
testing::Combine(
testing::Values(szVGA, sz1080p, Size(130, 60)),
CvtMode2::all()
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
Mat src(sz.height + sz.height / 2, sz.width, CV_8UC(ch.scn));
Mat dst(sz, CV_8UC(ch.dcn));
declare.in(src, WARMUP_RNG).out(dst);
int runs = (sz.width <= 640) ? 8 : 1;
TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}
typedef tuple<Size, CvtMode3> Size_CvtMode3_t;
typedef perf::TestBaseWithParam<Size_CvtMode3_t> Size_CvtMode3;
PERF_TEST_P(Size_CvtMode3, cvtColorRGB2YUV420p,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
CvtMode3::all()
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
ChPair ch = getConversionInfo(mode);
Mat src(sz, CV_8UC(ch.scn));
Mat dst(sz.height + sz.height / 2, sz.width, CV_8UC(ch.dcn));
declare.time(100);
declare.in(src, WARMUP_RNG).out(dst);
int runs = (sz.width <= 640) ? 10 : 1;
TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1);
}
CV_ENUM(EdgeAwareBayerMode, COLOR_BayerBG2BGR_EA, COLOR_BayerGB2BGR_EA, COLOR_BayerRG2BGR_EA, COLOR_BayerGR2BGR_EA)
typedef tuple<Size, EdgeAwareBayerMode> EdgeAwareParams;
typedef perf::TestBaseWithParam<EdgeAwareParams> EdgeAwareDemosaicingTest;
PERF_TEST_P(EdgeAwareDemosaicingTest, demosaicingEA,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)),
EdgeAwareBayerMode::all()
)
)
{
Size sz = get<0>(GetParam());
int mode = get<1>(GetParam());
Mat src(sz, CV_8UC1);
Mat dst(sz, CV_8UC3);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cvtColor(src, dst, mode, 3);
SANITY_CHECK(dst, 1);
}
} // namespace

View File

@ -0,0 +1,79 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(DistanceType, DIST_L1, DIST_L2 , DIST_C)
CV_ENUM(MaskSize, DIST_MASK_3, DIST_MASK_5, DIST_MASK_PRECISE)
CV_ENUM(DstType, CV_8U, CV_32F)
CV_ENUM(LabelType, DIST_LABEL_CCOMP, DIST_LABEL_PIXEL)
typedef tuple<Size, DistanceType, MaskSize, DstType> SrcSize_DistType_MaskSize_DstType;
typedef tuple<Size, DistanceType, MaskSize, LabelType> SrcSize_DistType_MaskSize_LabelType;
typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_DstType> DistanceTransform_Test;
typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_LabelType> DistanceTransform_NeedLabels_Test;
PERF_TEST_P(DistanceTransform_Test, distanceTransform,
testing::Combine(
testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)),
DistanceType::all(),
MaskSize::all(),
DstType::all()
)
)
{
Size srcSize = get<0>(GetParam());
int distanceType = get<1>(GetParam());
int maskSize = get<2>(GetParam());
int dstType = get<3>(GetParam());
Mat src(srcSize, CV_8U);
Mat dst(srcSize, dstType);
declare
.in(src, WARMUP_RNG)
.out(dst, WARMUP_RNG)
.time(30);
TEST_CYCLE() distanceTransform( src, dst, distanceType, maskSize, dstType);
double eps = 2e-4;
SANITY_CHECK(dst, eps);
}
PERF_TEST_P(DistanceTransform_NeedLabels_Test, distanceTransform_NeedLabels,
testing::Combine(
testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)),
DistanceType::all(),
MaskSize::all(),
LabelType::all()
)
)
{
Size srcSize = get<0>(GetParam());
int distanceType = get<1>(GetParam());
int maskSize = get<2>(GetParam());
int labelType = get<3>(GetParam());
Mat src(srcSize, CV_8U);
Mat label(srcSize, CV_32S);
Mat dst(srcSize, CV_32F);
declare
.in(src, WARMUP_RNG)
.out(label, WARMUP_RNG)
.out(dst, WARMUP_RNG)
.time(30);
TEST_CYCLE() distanceTransform( src, dst, label, distanceType, maskSize, labelType);
double eps = 2e-4;
SANITY_CHECK(label, eps);
SANITY_CHECK(dst, eps);
}
} // namespace

View File

@ -0,0 +1,100 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101)
typedef TestBaseWithParam< tuple<Size, int, BorderMode> > TestFilter2d;
typedef TestBaseWithParam< tuple<string, int> > Image_KernelSize;
PERF_TEST_P( TestFilter2d, Filter2d,
Combine(
Values( Size(320, 240), sz1080p ),
Values( 3, 5 ),
BorderMode::all()
)
)
{
Size sz;
int borderMode, kSize;
sz = get<0>(GetParam());
kSize = get<1>(GetParam());
borderMode = get<2>(GetParam());
Mat src(sz, CV_8UC4);
Mat dst(sz, CV_8UC4);
Mat kernel(kSize, kSize, CV_32FC1);
randu(kernel, -3, 10);
double s = fabs( sum(kernel)[0] );
if(s > 1e-3) kernel /= s;
declare.in(src, WARMUP_RNG).out(dst).time(20);
TEST_CYCLE() cv::filter2D(src, dst, CV_8UC4, kernel, Point(1, 1), 0., borderMode);
SANITY_CHECK(dst, 1);
}
PERF_TEST_P(TestFilter2d, DISABLED_Filter2d_ovx,
Combine(
Values(Size(320, 240), sz1080p),
Values(3, 5),
Values(BORDER_CONSTANT, BORDER_REPLICATE)
)
)
{
Size sz;
int borderMode, kSize;
sz = get<0>(GetParam());
kSize = get<1>(GetParam());
borderMode = get<2>(GetParam());
Mat src(sz, CV_8UC1);
Mat dst(sz, CV_16SC1);
Mat kernel(kSize, kSize, CV_16SC1);
randu(kernel, -3, 10);
declare.in(src, WARMUP_RNG).out(dst).time(20);
TEST_CYCLE() cv::filter2D(src, dst, CV_16SC1, kernel, Point(kSize / 2, kSize / 2), 0., borderMode);
SANITY_CHECK(dst, 1);
}
PERF_TEST_P( Image_KernelSize, GaborFilter2d,
Combine(
Values("stitching/a1.png", "cv/shared/pic5.png"),
Values(16, 32, 64) )
)
{
string fileName = getDataPath(get<0>(GetParam()));
Mat sourceImage = imread(fileName, IMREAD_GRAYSCALE);
if( sourceImage.empty() )
{
FAIL() << "Unable to load source image" << fileName;
}
int kernelSize = get<1>(GetParam());
double sigma = 4;
double lambda = 11;
double theta = 47;
double gamma = 0.5;
Mat gaborKernel = getGaborKernel(Size(kernelSize, kernelSize), sigma, theta, lambda, gamma);
Mat filteredImage;
declare.in(sourceImage);
TEST_CYCLE()
{
cv::filter2D(sourceImage, filteredImage, CV_32F, gaborKernel);
}
SANITY_CHECK(filteredImage, 1e-6, ERROR_RELATIVE);
}
} // namespace

View File

@ -0,0 +1,70 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<string, Point, int, int, int, int> Size_Source_Fl_t;
typedef perf::TestBaseWithParam<Size_Source_Fl_t> Size_Source_Fl;
PERF_TEST_P(Size_Source_Fl, floodFill1, Combine(
testing::Values("cv/shared/fruits.png", "cv/optflow/RubberWhale1.png"), //images
testing::Values(Point(120, 82), Point(200, 140)), //seed points
testing::Values(4,8), //connectivity
testing::Values((int)IMREAD_COLOR, (int)IMREAD_GRAYSCALE), //color image, or not
testing::Values(0, 1, 2), //use fixed(1), gradient (2) or simple(0) mode
testing::Values((int)CV_8U, (int)CV_32F, (int)CV_32S) //image depth
))
{
//test given image(s)
string filename = getDataPath(get<0>(GetParam()));
Point pseed;
pseed = get<1>(GetParam());
int connectivity = get<2>(GetParam());
int colorType = get<3>(GetParam());
int modeType = get<4>(GetParam());
int imdepth = get<5>(GetParam());
Mat image0 = imread(filename, colorType);
Scalar newval, loVal, upVal;
if (modeType == 0)
{
loVal = Scalar(0, 0, 0);
upVal = Scalar(0, 0, 0);
}
else
{
loVal = Scalar(4, 4, 4);
upVal = Scalar(20, 20, 20);
}
int newMaskVal = 255; //base mask for floodfill type
int flags = connectivity + (newMaskVal << 8) + (modeType == 1 ? FLOODFILL_FIXED_RANGE : 0);
int b = 152;//(unsigned)theRNG() & 255;
int g = 136;//(unsigned)theRNG() & 255;
int r = 53;//(unsigned)theRNG() & 255;
newval = (colorType == IMREAD_COLOR) ? Scalar(b, g, r) : Scalar(r*0.299 + g*0.587 + b*0.114);
Rect outputRect = Rect();
Mat source = Mat();
for (; next(); )
{
image0.convertTo(source, imdepth);
startTimer();
cv::floodFill(source, pseed, newval, &outputRect, loVal, upVal, flags);
stopTimer();
}
EXPECT_EQ(image0.cols, source.cols);
EXPECT_EQ(image0.rows, source.rows);
SANITY_CHECK_NOTHING();
}
} // namespace

View File

@ -0,0 +1,77 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<string, int, double, int, int, bool> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris_t;
typedef perf::TestBaseWithParam<Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris_t> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris;
PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris, goodFeaturesToTrack,
testing::Combine(
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
testing::Values( 100, 500 ),
testing::Values( 0.1, 0.01 ),
testing::Values( 3, 5 ),
testing::Values( 3, 5 ),
testing::Bool()
)
)
{
string filename = getDataPath(get<0>(GetParam()));
int maxCorners = get<1>(GetParam());
double qualityLevel = get<2>(GetParam());
int blockSize = get<3>(GetParam());
int gradientSize = get<4>(GetParam());
bool useHarrisDetector = get<5>(GetParam());
Mat image = imread(filename, IMREAD_GRAYSCALE);
if (image.empty())
FAIL() << "Unable to load source image" << filename;
std::vector<Point2f> corners;
double minDistance = 1;
TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(), blockSize, gradientSize, useHarrisDetector);
if (corners.size() > 50)
corners.erase(corners.begin() + 50, corners.end());
SANITY_CHECK(corners);
}
PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris, goodFeaturesToTrackWithQuality,
testing::Combine(
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
testing::Values( 50 ),
testing::Values( 0.01 ),
testing::Values( 3 ),
testing::Values( 3 ),
testing::Bool()
)
)
{
string filename = getDataPath(get<0>(GetParam()));
int maxCorners = get<1>(GetParam());
double qualityLevel = get<2>(GetParam());
int blockSize = get<3>(GetParam());
int gradientSize = get<4>(GetParam());
bool useHarrisDetector = get<5>(GetParam());
double minDistance = 1;
Mat image = imread(filename, IMREAD_GRAYSCALE);
if (image.empty())
FAIL() << "Unable to load source image" << filename;
std::vector<Point2f> corners;
std::vector<float> cornersQuality;
TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(),
cornersQuality, blockSize, gradientSize, useHarrisDetector);
SANITY_CHECK(corners);
SANITY_CHECK(cornersQuality, 1e-6);
}
} // namespace

View File

@ -0,0 +1,168 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<Size, MatType> Size_Source_t;
typedef TestBaseWithParam<Size_Source_t> Size_Source;
typedef TestBaseWithParam<Size> TestMatSize;
static const float rangeHight = 256.0f;
static const float rangeLow = 0.0f;
PERF_TEST_P(Size_Source, calcHist1d,
testing::Combine(testing::Values(sz3MP, sz5MP),
testing::Values(CV_8U, CV_16U, CV_32F) )
)
{
Size size = get<0>(GetParam());
MatType type = get<1>(GetParam());
Mat source(size.height, size.width, type);
Mat hist;
int channels [] = {0};
int histSize [] = {256};
int dims = 1;
int numberOfImages = 1;
const float range[] = {rangeLow, rangeHight};
const float* ranges[] = {range};
randu(source, rangeLow, rangeHight);
declare.in(source);
TEST_CYCLE_MULTIRUN(3)
{
calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges);
}
SANITY_CHECK(hist);
}
PERF_TEST_P(Size_Source, calcHist2d,
testing::Combine(testing::Values(sz3MP, sz5MP),
testing::Values(CV_8UC2, CV_16UC2, CV_32FC2) )
)
{
Size size = get<0>(GetParam());
MatType type = get<1>(GetParam());
Mat source(size.height, size.width, type);
Mat hist;
int channels [] = {0, 1};
int histSize [] = {256, 256};
int dims = 2;
int numberOfImages = 1;
const float r[] = {rangeLow, rangeHight};
const float* ranges[] = {r, r};
randu(source, rangeLow, rangeHight);
declare.in(source);
TEST_CYCLE()
{
calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges);
}
SANITY_CHECK(hist);
}
PERF_TEST_P(Size_Source, calcHist3d,
testing::Combine(testing::Values(sz3MP, sz5MP),
testing::Values(CV_8UC3, CV_16UC3, CV_32FC3) )
)
{
Size size = get<0>(GetParam());
MatType type = get<1>(GetParam());
Mat hist;
int channels [] = {0, 1, 2};
int histSize [] = {32, 32, 32};
int dims = 3;
int numberOfImages = 1;
Mat source(size.height, size.width, type);
const float r[] = {rangeLow, rangeHight};
const float* ranges[] = {r, r, r};
randu(source, rangeLow, rangeHight);
declare.in(source);
TEST_CYCLE()
{
calcHist(&source, numberOfImages, channels, Mat(), hist, dims, histSize, ranges);
}
SANITY_CHECK(hist);
}
#define MatSize TestMatSize
PERF_TEST_P(MatSize, equalizeHist,
testing::Values(TYPICAL_MAT_SIZES)
)
{
Size size = GetParam();
Mat source(size.height, size.width, CV_8U);
Mat destination;
declare.in(source, WARMUP_RNG);
TEST_CYCLE()
{
equalizeHist(source, destination);
}
SANITY_CHECK(destination);
}
#undef MatSize
typedef TestBaseWithParam< tuple<int, int> > Dim_Cmpmethod;
PERF_TEST_P(Dim_Cmpmethod, compareHist,
testing::Combine(testing::Values(1, 3),
testing::Values(HISTCMP_CORREL, HISTCMP_CHISQR, HISTCMP_INTERSECT, HISTCMP_BHATTACHARYYA, HISTCMP_CHISQR_ALT, HISTCMP_KL_DIV))
)
{
int dims = get<0>(GetParam());
int method = get<1>(GetParam());
int histSize[] = { 2048, 128, 64 };
Mat hist1(dims, histSize, CV_32FC1);
Mat hist2(dims, histSize, CV_32FC1);
randu(hist1, 0, 256);
randu(hist2, 0, 256);
declare.in(hist1.reshape(1, 256), hist2.reshape(1, 256));
TEST_CYCLE()
{
compareHist(hist1, hist2, method);
}
SANITY_CHECK_NOTHING();
}
typedef tuple<Size, double, MatType> Sz_ClipLimit_t;
typedef TestBaseWithParam<Sz_ClipLimit_t> Sz_ClipLimit;
PERF_TEST_P(Sz_ClipLimit, CLAHE,
testing::Combine(testing::Values(::perf::szVGA, ::perf::sz720p, ::perf::sz1080p),
testing::Values(0.0, 40.0),
testing::Values(MatType(CV_8UC1), MatType(CV_16UC1)))
)
{
const Size size = get<0>(GetParam());
const double clipLimit = get<1>(GetParam());
const int type = get<2>(GetParam());
Mat src(size, type);
declare.in(src, WARMUP_RNG);
Ptr<CLAHE> clahe = createCLAHE(clipLimit);
Mat dst;
TEST_CYCLE() clahe->apply(src, dst);
SANITY_CHECK(dst);
}
} // namespace

View File

@ -0,0 +1,85 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
#include "opencv2/imgproc/types_c.h"
namespace opencv_test {
PERF_TEST(PerfHoughCircles, Basic)
{
string filename = getDataPath("cv/imgproc/stuff.jpg");
const double dp = 1.0;
double minDist = 20;
double edgeThreshold = 20;
double accumThreshold = 30;
int minRadius = 20;
int maxRadius = 200;
Mat img = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
GaussianBlur(img, img, Size(9, 9), 2, 2);
vector<Vec3f> circles;
declare.in(img);
TEST_CYCLE()
{
HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
}
SANITY_CHECK_NOTHING();
}
PERF_TEST(PerfHoughCircles2, ManySmallCircles)
{
string filename = getDataPath("cv/imgproc/beads.jpg");
const double dp = 1.0;
double minDist = 10;
double edgeThreshold = 90;
double accumThreshold = 11;
int minRadius = 7;
int maxRadius = 18;
Mat img = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
vector<Vec3f> circles;
declare.in(img);
TEST_CYCLE()
{
HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
}
SANITY_CHECK_NOTHING();
}
PERF_TEST(PerfHoughCircles4f, Basic)
{
string filename = getDataPath("cv/imgproc/stuff.jpg");
const double dp = 1.0;
double minDist = 20;
double edgeThreshold = 20;
double accumThreshold = 30;
int minRadius = 20;
int maxRadius = 200;
Mat img = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
GaussianBlur(img, img, Size(9, 9), 2, 2);
vector<Vec4f> circles;
declare.in(img);
TEST_CYCLE()
{
HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
}
SANITY_CHECK_NOTHING();
}
} // namespace

View File

@ -0,0 +1,115 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<string, double, double, double> Image_RhoStep_ThetaStep_Threshold_t;
typedef perf::TestBaseWithParam<Image_RhoStep_ThetaStep_Threshold_t> Image_RhoStep_ThetaStep_Threshold;
PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
testing::Combine(
testing::Values( "cv/shared/pic5.png", "stitching/a1.png" ),
testing::Values( 1, 10 ),
testing::Values( 0.01, 0.1 ),
testing::Values( 0.5, 1.1 )
)
)
{
string filename = getDataPath(get<0>(GetParam()));
double rhoStep = get<1>(GetParam());
double thetaStep = get<2>(GetParam());
double threshold_ratio = get<3>(GetParam());
Mat image = imread(filename, IMREAD_GRAYSCALE);
if (image.empty())
FAIL() << "Unable to load source image" << filename;
Canny(image, image, 32, 128);
// add some synthetic lines:
line(image, Point(0, 0), Point(image.cols, image.rows), Scalar::all(255), 3);
line(image, Point(image.cols, 0), Point(image.cols/2, image.rows), Scalar::all(255), 3);
vector<Vec2f> lines;
declare.time(60);
int hough_threshold = (int)(std::min(image.cols, image.rows) * threshold_ratio);
TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, hough_threshold);
printf("%dx%d: %d lines\n", image.cols, image.rows, (int)lines.size());
if (threshold_ratio < 1.0)
{
EXPECT_GE(lines.size(), 2u);
}
EXPECT_LT(lines.size(), 3000u);
#if 0
cv::cvtColor(image,image,cv::COLOR_GRAY2BGR);
for( size_t i = 0; i < lines.size(); i++ )
{
float rho = lines[i][0], theta = lines[i][1];
Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + 1000*(-b));
pt1.y = cvRound(y0 + 1000*(a));
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
line(image, pt1, pt2, Scalar(0,0,255), 1, cv::LINE_AA);
}
cv::imshow("result", image);
cv::waitKey();
#endif
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines3f,
testing::Combine(
testing::Values( "cv/shared/pic5.png", "stitching/a1.png" ),
testing::Values( 1, 10 ),
testing::Values( 0.01, 0.1 ),
testing::Values( 0.5, 1.1 )
)
)
{
string filename = getDataPath(get<0>(GetParam()));
double rhoStep = get<1>(GetParam());
double thetaStep = get<2>(GetParam());
double threshold_ratio = get<3>(GetParam());
Mat image = imread(filename, IMREAD_GRAYSCALE);
if (image.empty())
FAIL() << "Unable to load source image" << filename;
Canny(image, image, 32, 128);
// add some synthetic lines:
line(image, Point(0, 0), Point(image.cols, image.rows), Scalar::all(255), 3);
line(image, Point(image.cols, 0), Point(image.cols/2, image.rows), Scalar::all(255), 3);
vector<Vec3f> lines;
declare.time(60);
int hough_threshold = (int)(std::min(image.cols, image.rows) * threshold_ratio);
TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, hough_threshold);
printf("%dx%d: %d lines\n", image.cols, image.rows, (int)lines.size());
if (threshold_ratio < 1.0)
{
EXPECT_GE(lines.size(), 2u);
}
EXPECT_LT(lines.size(), 3000u);
SANITY_CHECK_NOTHING();
}
} // namespace

View File

@ -0,0 +1,139 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
enum PerfSqMatDepth{
DEPTH_32S_32S = 0,
DEPTH_32S_32F,
DEPTH_32S_64F,
DEPTH_32F_32F,
DEPTH_32F_64F,
DEPTH_64F_64F};
CV_ENUM(IntegralOutputDepths, DEPTH_32S_32S, DEPTH_32S_32F, DEPTH_32S_64F, DEPTH_32F_32F, DEPTH_32F_64F, DEPTH_64F_64F);
static int extraOutputDepths[6][2] = {{CV_32S, CV_32S}, {CV_32S, CV_32F}, {CV_32S, CV_64F}, {CV_32F, CV_32F}, {CV_32F, CV_64F}, {CV_64F, CV_64F}};
typedef tuple<Size, MatType, MatDepth> Size_MatType_OutMatDepth_t;
typedef perf::TestBaseWithParam<Size_MatType_OutMatDepth_t> Size_MatType_OutMatDepth;
typedef tuple<Size, MatType, IntegralOutputDepths> Size_MatType_OutMatDepthArray_t;
typedef perf::TestBaseWithParam<Size_MatType_OutMatDepthArray_t> Size_MatType_OutMatDepthArray;
PERF_TEST_P(Size_MatType_OutMatDepth, integral,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4),
testing::Values(CV_32S, CV_32F, CV_64F)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int sdepth = get<2>(GetParam());
Mat src(sz, matType);
Mat sum(sz, sdepth);
declare.in(src, WARMUP_RNG).out(sum);
if (sdepth == CV_32F)
src *= (1 << 23) / (double)(sz.area() * 256); // FP32 calculations are not accurate (mantissa is 23-bit)
TEST_CYCLE() integral(src, sum, sdepth);
Mat src_roi; src(Rect(src.cols - 4, src.rows - 4, 4, 4)).convertTo(src_roi, sdepth);
Mat restored_src_roi =
sum(Rect(sum.cols - 4, sum.rows - 4, 4, 4)) + sum(Rect(sum.cols - 5, sum.rows - 5, 4, 4)) -
sum(Rect(sum.cols - 4, sum.rows - 5, 4, 4)) - sum(Rect(sum.cols - 5, sum.rows - 4, 4, 4));
EXPECT_EQ(0, cvtest::norm(restored_src_roi, src_roi, NORM_INF))
<< src_roi << endl << restored_src_roi << endl
<< sum(Rect(sum.cols - 4, sum.rows - 4, 4, 4));
if (sdepth == CV_32F)
SANITY_CHECK_NOTHING();
else
SANITY_CHECK(sum, 1e-6);
}
PERF_TEST_P(Size_MatType_OutMatDepth, integral_sqsum,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4),
testing::Values(CV_32S, CV_32F, CV_64F)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int sdepth = get<2>(GetParam());
Mat src(sz, matType);
Mat sum(sz, sdepth);
Mat sqsum(sz, sdepth);
declare.in(src, WARMUP_RNG).out(sum, sqsum);
declare.time(100);
TEST_CYCLE() integral(src, sum, sqsum, sdepth);
SANITY_CHECK(sum, 1e-6);
SANITY_CHECK(sqsum, 1e-6);
}
PERF_TEST_P(Size_MatType_OutMatDepthArray, DISABLED_integral_sqsum_full,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4),
testing::Values(DEPTH_32S_32S, DEPTH_32S_32F, DEPTH_32S_64F, DEPTH_32F_32F, DEPTH_32F_64F, DEPTH_64F_64F)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int *outputDepths = (int *)extraOutputDepths[get<2>(GetParam())];
int sdepth = outputDepths[0];
int sqdepth = outputDepths[1];
Mat src(sz, matType);
Mat sum(sz, sdepth);
Mat sqsum(sz, sqdepth);
declare.in(src, WARMUP_RNG).out(sum, sqsum);
declare.time(100);
TEST_CYCLE() integral(src, sum, sqsum, sdepth, sqdepth);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P( Size_MatType_OutMatDepth, integral_sqsum_tilted,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values( CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4 ),
testing::Values( CV_32S, CV_32F, CV_64F )
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int sdepth = get<2>(GetParam());
Mat src(sz, matType);
Mat sum(sz, sdepth);
Mat sqsum(sz, sdepth);
Mat tilted(sz, sdepth);
declare.in(src, WARMUP_RNG).out(sum, sqsum, tilted);
declare.time(100);
TEST_CYCLE() integral(src, sum, sqsum, tilted, sdepth);
SANITY_CHECK(sum, 1e-6);
SANITY_CHECK(sqsum, 1e-6);
SANITY_CHECK(tilted, 1e-6, tilted.depth() > CV_32S ? ERROR_RELATIVE : ERROR_ABSOLUTE);
}
} // namespace

View File

@ -0,0 +1,10 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
#if defined(HAVE_HPX)
#include <hpx/hpx_main.hpp>
#endif
CV_PERF_TEST_MAIN(imgproc)

View File

@ -0,0 +1,84 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
typedef tuple<Size, Size, MethodType> ImgSize_TmplSize_Method_t;
typedef perf::TestBaseWithParam<ImgSize_TmplSize_Method_t> ImgSize_TmplSize_Method;
PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateSmall,
testing::Combine(
testing::Values(szSmall128, cv::Size(320, 240),
cv::Size(640, 480), cv::Size(800, 600),
cv::Size(1024, 768), cv::Size(1280, 1024)),
testing::Values(cv::Size(12, 12), cv::Size(28, 9),
cv::Size(8, 30), cv::Size(16, 16)),
MethodType::all()
)
)
{
Size imgSz = get<0>(GetParam());
Size tmplSz = get<1>(GetParam());
int method = get<2>(GetParam());
Mat img(imgSz, CV_8UC1);
Mat tmpl(tmplSz, CV_8UC1);
Mat result(imgSz - tmplSz + Size(1,1), CV_32F);
declare
.in(img, WARMUP_RNG)
.in(tmpl, WARMUP_RNG)
.out(result)
.time(30);
TEST_CYCLE() matchTemplate(img, tmpl, result, method);
bool isNormed =
method == TM_CCORR_NORMED ||
method == TM_SQDIFF_NORMED ||
method == TM_CCOEFF_NORMED;
double eps = isNormed ? 1e-5
: 255 * 255 * tmpl.total() * 1e-6;
SANITY_CHECK(result, eps);
}
PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateBig,
testing::Combine(
testing::Values(cv::Size(1280, 1024)),
testing::Values(cv::Size(1260, 1000), cv::Size(1261, 1013)),
MethodType::all()
)
)
{
Size imgSz = get<0>(GetParam());
Size tmplSz = get<1>(GetParam());
int method = get<2>(GetParam());
Mat img(imgSz, CV_8UC1);
Mat tmpl(tmplSz, CV_8UC1);
Mat result(imgSz - tmplSz + Size(1,1), CV_32F);
declare
.in(img, WARMUP_RNG)
.in(tmpl, WARMUP_RNG)
.out(result)
.time(30);
TEST_CYCLE() matchTemplate(img, tmpl, result, method);
bool isNormed =
method == TM_CCORR_NORMED ||
method == TM_SQDIFF_NORMED ||
method == TM_CCOEFF_NORMED;
double eps = isNormed ? 1e-6
: 255.0 * 255.0 * (double)tmpl.total() * 1e-6;
SANITY_CHECK(result, eps);
}
} // namespace

View File

@ -0,0 +1,41 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<Size, MatDepth, bool> MomentsParams_t;
typedef perf::TestBaseWithParam<MomentsParams_t> MomentsFixture_val;
PERF_TEST_P(MomentsFixture_val, Moments1,
::testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_16U, CV_16S, CV_32F, CV_64F),
testing::Bool()))
{
const MomentsParams_t params = GetParam();
const Size srcSize = get<0>(params);
const MatDepth srcDepth = get<1>(params);
const bool binaryImage = get<2>(params);
cv::Moments m;
Mat src(srcSize, srcDepth);
declare.in(src, WARMUP_RNG);
TEST_CYCLE() m = cv::moments(src, binaryImage);
int len = (int)sizeof(cv::Moments) / sizeof(double);
cv::Mat mat(1, len, CV_64F, (void*)&m);
//adding 1 to moments to avoid accidental tests fail on values close to 0
mat += 1;
SANITY_CHECK_MOMENTS(m, 2e-4, ERROR_RELATIVE);
}
} // namespace

View File

@ -0,0 +1,42 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
#define TYPICAL_MAT_TYPES_MORPH CV_8UC1, CV_8UC4
#define TYPICAL_MATS_MORPH testing::Combine(SZ_ALL_GA, testing::Values(TYPICAL_MAT_TYPES_MORPH))
PERF_TEST_P(Size_MatType, erode, TYPICAL_MATS_MORPH)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
Mat src(sz, type);
Mat dst(sz, type);
declare.in(src, WARMUP_RNG).out(dst);
int runs = (sz.width <= 320) ? 15 : 1;
TEST_CYCLE_MULTIRUN(runs) erode(src, dst, noArray());
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType, dilate, TYPICAL_MATS_MORPH)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
Mat src(sz, type);
Mat dst(sz, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() dilate(src, dst, noArray());
SANITY_CHECK(dst);
}
} // namespace

View File

@ -0,0 +1,22 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef TestBaseWithParam<Size > CreateHanningWindowFixture;
PERF_TEST_P( CreateHanningWindowFixture, CreateHanningWindow, Values(szVGA, sz1080p))
{
const Size size = GetParam();
Mat dst(size, CV_32FC1);
declare.in(dst, WARMUP_RNG).out(dst);
TEST_CYCLE() cv::createHanningWindow(dst, size, CV_32FC1);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
} // namespace

View File

@ -0,0 +1,14 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef __OPENCV_PERF_PRECOMP_HPP__
#define __OPENCV_PERF_PRECOMP_HPP__
#include "opencv2/ts.hpp"
#include "opencv2/imgproc.hpp"
namespace opencv_test {
using namespace perf;
} // namespace
#endif

View File

@ -0,0 +1,98 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
Mat src(sz, matType);
Mat dst((sz.height + 1)/2, (sz.width + 1)/2, matType);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() pyrDown(src, dst);
SANITY_CHECK(dst, eps, error_type);
}
PERF_TEST_P(Size_MatType, DISABLED_pyrDown_ovx, testing::Combine(
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
Mat src(sz, matType);
Mat dst((sz.height + 1) / 2, (sz.width + 1) / 2, matType);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() pyrDown(src, dst, cv::Size(), BORDER_REPLICATE);
SANITY_CHECK(dst, eps, error_type);
}
PERF_TEST_P(Size_MatType, pyrUp, testing::Combine(
testing::Values(sz720p, szVGA, szQVGA, szODD),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
Mat src(sz, matType);
Mat dst(sz.height*2, sz.width*2, matType);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() pyrUp(src, dst);
SANITY_CHECK(dst, eps, error_type);
}
PERF_TEST_P(Size_MatType, buildPyramid, testing::Combine(
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int maxLevel = 5;
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
Mat src(sz, matType);
std::vector<Mat> dst(maxLevel);
declare.in(src, WARMUP_RNG);
TEST_CYCLE() buildPyramid(src, dst, maxLevel);
Mat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];
SANITY_CHECK(dst0, eps, error_type);
SANITY_CHECK(dst1, eps, error_type);
SANITY_CHECK(dst2, eps, error_type);
SANITY_CHECK(dst3, eps, error_type);
SANITY_CHECK(dst4, eps, error_type);
}
} // namespace

View File

@ -0,0 +1,70 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4)
typedef TestBaseWithParam< tuple<Size, MatType, MatType, InterType> > TestRemap;
PERF_TEST_P( TestRemap, Remap,
Combine(
Values( szVGA, sz1080p ),
Values( CV_16UC1, CV_16SC1, CV_32FC1 ),
Values( CV_16SC2, CV_32FC1, CV_32FC2 ),
InterType::all()
)
)
{
Size sz;
int src_type, map1_type, inter_type;
sz = get<0>(GetParam());
src_type = get<1>(GetParam());
map1_type = get<2>(GetParam());
inter_type = get<3>(GetParam());
Mat src(sz, src_type), dst(sz, src_type), map1(sz, map1_type), map2;
if (map1_type == CV_32FC1)
map2.create(sz, CV_32FC1);
else if (inter_type != INTER_NEAREST && map1_type == CV_16SC2)
{
map2.create(sz, CV_16UC1);
map2 = Scalar::all(0);
}
RNG rng;
rng.fill(src, RNG::UNIFORM, 0, 256);
for (int j = 0; j < map1.rows; ++j)
for (int i = 0; i < map1.cols; ++i)
switch (map1_type)
{
case CV_32FC1:
map1.at<float>(j, i) = static_cast<float>(src.cols - i - 1);
map2.at<float>(j, i) = static_cast<float>(j);
break;
case CV_32FC2:
map1.at<Vec2f>(j, i)[0] = static_cast<float>(src.cols - i - 1);
map1.at<Vec2f>(j, i)[1] = static_cast<float>(j);
break;
case CV_16SC2:
map1.at<Vec2s>(j, i)[0] = static_cast<short>(src.cols - i - 1);
map1.at<Vec2s>(j, i)[1] = static_cast<short>(j);
break;
default:
CV_Assert(0);
}
declare.in(src, WARMUP_RNG).out(dst).time(20);
int runs = (sz.width <= 640) ? 3 : 1;
TEST_CYCLE_MULTIRUN(runs) remap(src, dst, map1, map2, inter_type);
SANITY_CHECK(dst);
}
} // namespace

View File

@ -0,0 +1,283 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<MatType, Size, Size> MatInfo_Size_Size_t;
typedef TestBaseWithParam<MatInfo_Size_Size_t> MatInfo_Size_Size;
typedef tuple<Size,Size> Size_Size_t;
typedef tuple<MatType, Size_Size_t> MatInfo_SizePair_t;
typedef TestBaseWithParam<MatInfo_SizePair_t> MatInfo_SizePair;
#define MATTYPE_NE_VALUES CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, \
CV_16UC1, CV_16UC2, CV_16UC3, CV_16UC4, \
CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4
// For gradient-ish testing of the other matrix formats
template<typename T>
static void fillFPGradient(Mat& img)
{
const int ch = img.channels();
int r, c, i;
for(r=0; r<img.rows; r++)
{
for(c=0; c<img.cols; c++)
{
T vals[] = {(T)r, (T)c, (T)(r*c), (T)(r*c/(r+c+1))};
T *p = (T*)img.ptr(r, c);
for(i=0; i<ch; i++) p[i] = (T)vals[i];
}
}
}
PERF_TEST_P(MatInfo_Size_Size, resizeUpLinear,
testing::Values(
MatInfo_Size_Size_t(CV_8UC1, szVGA, szqHD),
MatInfo_Size_Size_t(CV_8UC2, szVGA, szqHD),
MatInfo_Size_Size_t(CV_8UC3, szVGA, szqHD),
MatInfo_Size_Size_t(CV_8UC4, szVGA, szqHD),
MatInfo_Size_Size_t(CV_8UC1, szVGA, sz720p),
MatInfo_Size_Size_t(CV_8UC2, szVGA, sz720p),
MatInfo_Size_Size_t(CV_8UC3, szVGA, sz720p),
MatInfo_Size_Size_t(CV_8UC4, szVGA, sz720p)
)
)
{
int matType = get<0>(GetParam());
Size from = get<1>(GetParam());
Size to = get<2>(GetParam());
cv::Mat src(from, matType), dst(to, matType);
cvtest::fillGradient(src);
declare.in(src).out(dst);
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR_EXACT);
#ifdef __ANDROID__
SANITY_CHECK(dst, 5);
#else
SANITY_CHECK(dst, 1 + 1e-6);
#endif
}
PERF_TEST_P(MatInfo_SizePair, resizeUpLinearNonExact,
testing::Combine
(
testing::Values( MATTYPE_NE_VALUES ),
testing::Values( Size_Size_t(szVGA, szqHD), Size_Size_t(szVGA, sz720p) )
)
)
{
int matType = get<0>(GetParam());
Size_Size_t sizes = get<1>(GetParam());
Size from = get<0>(sizes);
Size to = get<1>(sizes);
cv::Mat src(from, matType), dst(to, matType);
switch(src.depth())
{
case CV_8U: cvtest::fillGradient(src); break;
case CV_16U: fillFPGradient<ushort>(src); break;
case CV_32F: fillFPGradient<float>(src); break;
}
declare.in(src).out(dst);
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear,
testing::Values(
MatInfo_Size_Size_t(CV_8UC1, szVGA, szQVGA),
MatInfo_Size_Size_t(CV_8UC2, szVGA, szQVGA),
MatInfo_Size_Size_t(CV_8UC3, szVGA, szQVGA),
MatInfo_Size_Size_t(CV_8UC4, szVGA, szQVGA),
MatInfo_Size_Size_t(CV_8UC1, szqHD, szVGA),
MatInfo_Size_Size_t(CV_8UC2, szqHD, szVGA),
MatInfo_Size_Size_t(CV_8UC3, szqHD, szVGA),
MatInfo_Size_Size_t(CV_8UC4, szqHD, szVGA),
MatInfo_Size_Size_t(CV_8UC1, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
MatInfo_Size_Size_t(CV_8UC2, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
MatInfo_Size_Size_t(CV_8UC3, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
MatInfo_Size_Size_t(CV_8UC4, sz720p, Size(120 * sz720p.width / sz720p.height, 120)),//face detection min_face_size = 20%
MatInfo_Size_Size_t(CV_8UC1, sz720p, szVGA),
MatInfo_Size_Size_t(CV_8UC2, sz720p, szVGA),
MatInfo_Size_Size_t(CV_8UC3, sz720p, szVGA),
MatInfo_Size_Size_t(CV_8UC4, sz720p, szVGA),
MatInfo_Size_Size_t(CV_8UC1, sz720p, szQVGA),
MatInfo_Size_Size_t(CV_8UC2, sz720p, szQVGA),
MatInfo_Size_Size_t(CV_8UC3, sz720p, szQVGA),
MatInfo_Size_Size_t(CV_8UC4, sz720p, szQVGA)
)
)
{
int matType = get<0>(GetParam());
Size from = get<1>(GetParam());
Size to = get<2>(GetParam());
cv::Mat src(from, matType), dst(to, matType);
cvtest::fillGradient(src);
declare.in(src).out(dst);
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR_EXACT);
#ifdef __ANDROID__
SANITY_CHECK(dst, 5);
#else
SANITY_CHECK(dst, 1 + 1e-6);
#endif
}
PERF_TEST_P(MatInfo_SizePair, resizeDownLinearNonExact,
testing::Combine
(
testing::Values( MATTYPE_NE_VALUES ),
testing::Values
(
Size_Size_t(szVGA, szQVGA),
Size_Size_t(szqHD, szVGA),
Size_Size_t(sz720p, Size(120 * sz720p.width / sz720p.height, 120)),
Size_Size_t(sz720p, szVGA),
Size_Size_t(sz720p, szQVGA)
)
)
)
{
int matType = get<0>(GetParam());
Size_Size_t sizes = get<1>(GetParam());
Size from = get<0>(sizes);
Size to = get<1>(sizes);
cv::Mat src(from, matType), dst(to, matType);
switch(src.depth())
{
case CV_8U: cvtest::fillGradient(src); break;
case CV_16U: fillFPGradient<ushort>(src); break;
case CV_32F: fillFPGradient<float>(src); break;
}
declare.in(src).out(dst);
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to, 0, 0, INTER_LINEAR);
SANITY_CHECK_NOTHING();
}
typedef tuple<MatType, Size, int> MatInfo_Size_Scale_t;
typedef TestBaseWithParam<MatInfo_Size_Scale_t> MatInfo_Size_Scale;
PERF_TEST_P(MatInfo_Size_Scale, ResizeAreaFast,
testing::Combine(
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4),
testing::Values(szVGA, szqHD, sz720p, sz1080p),
testing::Values(2)
)
)
{
int matType = get<0>(GetParam());
Size from = get<1>(GetParam());
int scale = get<2>(GetParam());
from.width = (from.width/scale)*scale;
from.height = (from.height/scale)*scale;
cv::Mat src(from, matType);
cv::Mat dst(from.height / scale, from.width / scale, matType);
declare.in(src, WARMUP_RNG).out(dst);
int runs = 15;
TEST_CYCLE_MULTIRUN(runs) resize(src, dst, dst.size(), 0, 0, INTER_AREA);
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
SANITY_CHECK(dst, 1);
}
typedef TestBaseWithParam<tuple<MatType, Size, double> > MatInfo_Size_Scale_Area;
PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea,
testing::Combine(
testing::Values(CV_8UC1, CV_8UC4),
testing::Values(szVGA, szqHD, sz720p),
testing::Values(2.4, 3.4, 1.3)
)
)
{
int matType = get<0>(GetParam());
Size from = get<1>(GetParam());
double scale = get<2>(GetParam());
cv::Mat src(from, matType);
Size to(cvRound(from.width * scale), cvRound(from.height * scale));
cv::Mat dst(to, matType);
declare.in(src, WARMUP_RNG).out(dst);
declare.time(100);
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_AREA);
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
SANITY_CHECK(dst, 1);
}
typedef MatInfo_Size_Scale_Area MatInfo_Size_Scale_NN;
PERF_TEST_P(MatInfo_Size_Scale_NN, ResizeNN,
testing::Combine(
testing::Values(CV_8UC1, CV_8UC2, CV_8UC4),
testing::Values(szVGA, szqHD, sz720p, sz1080p, sz2160p),
testing::Values(2.4, 3.4, 1.3)
)
)
{
int matType = get<0>(GetParam());
Size from = get<1>(GetParam());
double scale = get<2>(GetParam());
cv::Mat src(from, matType);
Size to(cvRound(from.width * scale), cvRound(from.height * scale));
cv::Mat dst(to, matType);
declare.in(src, WARMUP_RNG).out(dst);
declare.time(100);
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_NEAREST);
EXPECT_GT(countNonZero(dst.reshape(1)), 0);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(MatInfo_Size_Scale_NN, ResizeNNExact,
testing::Combine(
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4),
testing::Values(sz720p, sz1080p),
testing::Values(0.25, 0.5, 2.0)
)
)
{
int matType = get<0>(GetParam());
Size from = get<1>(GetParam());
double scale = get<2>(GetParam());
cv::Mat src(from, matType);
Size to(cvRound(from.width * scale), cvRound(from.height * scale));
cv::Mat dst(to, matType);
declare.in(src, WARMUP_RNG).out(dst);
declare.time(100);
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_NEAREST_EXACT);
EXPECT_GT(countNonZero(dst.reshape(1)), 0);
SANITY_CHECK_NOTHING();
}
} // namespace

View File

@ -0,0 +1,245 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
#define FILTER_SRC_SIZES szODD, szQVGA, szVGA
CV_ENUM(BorderType3x3, BORDER_REPLICATE, BORDER_CONSTANT)
CV_ENUM(BorderType3x3ROI, BORDER_DEFAULT, BORDER_REPLICATE|BORDER_ISOLATED, BORDER_CONSTANT|BORDER_ISOLATED)
CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT101)
CV_ENUM(BorderTypeROI, BORDER_DEFAULT, BORDER_REPLICATE|BORDER_ISOLATED, BORDER_CONSTANT|BORDER_ISOLATED, BORDER_REFLECT|BORDER_ISOLATED, BORDER_REFLECT101|BORDER_ISOLATED)
typedef tuple<Size, MatType, tuple<int, int>, BorderType3x3> Size_MatType_dx_dy_Border3x3_t;
typedef perf::TestBaseWithParam<Size_MatType_dx_dy_Border3x3_t> Size_MatType_dx_dy_Border3x3;
typedef tuple<Size, MatType, tuple<int, int>, BorderType3x3ROI> Size_MatType_dx_dy_Border3x3ROI_t;
typedef perf::TestBaseWithParam<Size_MatType_dx_dy_Border3x3ROI_t> Size_MatType_dx_dy_Border3x3ROI;
typedef tuple<Size, MatType, tuple<int, int>, BorderType> Size_MatType_dx_dy_Border5x5_t;
typedef perf::TestBaseWithParam<Size_MatType_dx_dy_Border5x5_t> Size_MatType_dx_dy_Border5x5;
typedef tuple<Size, MatType, tuple<int, int>, BorderTypeROI> Size_MatType_dx_dy_Border5x5ROI_t;
typedef perf::TestBaseWithParam<Size_MatType_dx_dy_Border5x5ROI_t> Size_MatType_dx_dy_Border5x5ROI;
/**************** Sobel ********************/
PERF_TEST_P(Size_MatType_dx_dy_Border3x3, sobelFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0), make_tuple(2, 2)),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType3x3 border = get<3>(GetParam());
Mat src(size, CV_8U);
Mat dst(size, ddepth);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() Sobel(src, dst, ddepth, dx, dy, 3, 1, 0, border);
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, sobelFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0), make_tuple(2, 2)),
BorderType3x3ROI::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType3x3ROI border = get<3>(GetParam());
Mat src(size.height + 10, size.width + 10, CV_8U);
Mat dst(size, ddepth);
warmup(src, WARMUP_RNG);
src = src(Range(5, 5 + size.height), Range(5, 5 + size.width));
declare.in(src).out(dst);
TEST_CYCLE() Sobel(src, dst, ddepth, dx, dy, 3, 1, 0, border);
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType_dx_dy_Border5x5, sobelFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0)),
BorderType::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType border = get<3>(GetParam());
Mat src(size, CV_8U);
Mat dst(size, ddepth);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() Sobel(src, dst, ddepth, dx, dy, 5, 1, 0, border);
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType_dx_dy_Border5x5ROI, sobelFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0)),
BorderTypeROI::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderTypeROI border = get<3>(GetParam());
Mat src(size.height + 10, size.width + 10, CV_8U);
Mat dst(size, ddepth);
warmup(src, WARMUP_RNG);
src = src(Range(5, 5 + size.height), Range(5, 5 + size.width));
declare.in(src).out(dst);
TEST_CYCLE() Sobel(src, dst, ddepth, dx, dy, 5, 1, 0, border);
SANITY_CHECK(dst);
}
/**************** Scharr ********************/
PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType3x3 border = get<3>(GetParam());
Mat src(size, CV_8U);
Mat dst(size, ddepth);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() Scharr(src, dst, ddepth, dx, dy, 1, 0, border);
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
BorderType3x3ROI::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType3x3ROI border = get<3>(GetParam());
Mat src(size.height + 10, size.width + 10, CV_8U);
Mat dst(size, ddepth);
warmup(src, WARMUP_RNG);
src = src(Range(5, 5 + size.height), Range(5, 5 + size.width));
declare.in(src).out(dst);
TEST_CYCLE() Scharr(src, dst, ddepth, dx, dy, 1, 0, border);
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrViaSobelFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
BorderType3x3::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType3x3 border = get<3>(GetParam());
Mat src(size, CV_8U);
Mat dst(size, ddepth);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() Sobel(src, dst, ddepth, dx, dy, -1, 1, 0, border);
SANITY_CHECK(dst);
}
PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrViaSobelFilter,
testing::Combine(
testing::Values(FILTER_SRC_SIZES),
testing::Values(CV_16S, CV_32F),
testing::Values(make_tuple(0, 1), make_tuple(1, 0)),
BorderType3x3ROI::all()
)
)
{
Size size = get<0>(GetParam());
int ddepth = get<1>(GetParam());
int dx = get<0>(get<2>(GetParam()));
int dy = get<1>(get<2>(GetParam()));
BorderType3x3ROI border = get<3>(GetParam());
Mat src(size.height + 10, size.width + 10, CV_8U);
Mat dst(size, ddepth);
warmup(src, WARMUP_RNG);
src = src(Range(5, 5 + size.height), Range(5, 5 + size.width));
declare.in(src).out(dst);
TEST_CYCLE() Sobel(src, dst, ddepth, dx, dy, -1, 1, 0, border);
SANITY_CHECK(dst);
}
} // namespace

View File

@ -0,0 +1,35 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
typedef tuple<Size, int, int> Size_Ksize_BorderType_t;
typedef perf::TestBaseWithParam<Size_Ksize_BorderType_t> Size_Ksize_BorderType;
PERF_TEST_P( Size_Ksize_BorderType, spatialGradient,
Combine(
SZ_ALL_HD,
Values( 3 ),
Values( BORDER_DEFAULT, BORDER_REPLICATE )
)
)
{
Size size = get<0>(GetParam());
int ksize = get<1>(GetParam());
int borderType = get<2>(GetParam());
Mat src(size, CV_8UC1);
Mat dx(size, CV_16SC1);
Mat dy(size, CV_16SC1);
declare.in(src, WARMUP_RNG).out(dx, dy);
TEST_CYCLE() spatialGradient(src, dx, dy, ksize, borderType);
SANITY_CHECK(dx);
SANITY_CHECK(dy);
}
} // namespace

View File

@ -0,0 +1,96 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
typedef tuple<Size, MatType, ThreshType> Size_MatType_ThreshType_t;
typedef perf::TestBaseWithParam<Size_MatType_ThreshType_t> Size_MatType_ThreshType;
PERF_TEST_P(Size_MatType_ThreshType, threshold,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16SC1, CV_32FC1, CV_64FC1),
ThreshType::all()
)
)
{
Size sz = get<0>(GetParam());
int type = get<1>(GetParam());
ThreshType threshType = get<2>(GetParam());
Mat src(sz, type);
Mat dst(sz, type);
double thresh = theRNG().uniform(1, 254);
double maxval = theRNG().uniform(1, 254);
declare.in(src, WARMUP_RNG).out(dst);
int runs = (sz.width <= 640) ? 40 : 1;
TEST_CYCLE_MULTIRUN(runs) cv::threshold(src, dst, thresh, maxval, threshType);
SANITY_CHECK(dst);
}
typedef perf::TestBaseWithParam<Size> Size_Only;
PERF_TEST_P(Size_Only, threshold_otsu, testing::Values(TYPICAL_MAT_SIZES))
{
Size sz = GetParam();
Mat src(sz, CV_8UC1);
Mat dst(sz, CV_8UC1);
double maxval = theRNG().uniform(1, 254);
declare.in(src, WARMUP_RNG).out(dst);
int runs = 15;
TEST_CYCLE_MULTIRUN(runs) cv::threshold(src, dst, 0, maxval, THRESH_BINARY|THRESH_OTSU);
SANITY_CHECK(dst);
}
CV_ENUM(AdaptThreshType, THRESH_BINARY, THRESH_BINARY_INV)
CV_ENUM(AdaptThreshMethod, ADAPTIVE_THRESH_MEAN_C, ADAPTIVE_THRESH_GAUSSIAN_C)
typedef tuple<Size, AdaptThreshType, AdaptThreshMethod, int, double> Size_AdaptThreshType_AdaptThreshMethod_BlockSize_Delta_t;
typedef perf::TestBaseWithParam<Size_AdaptThreshType_AdaptThreshMethod_BlockSize_Delta_t> Size_AdaptThreshType_AdaptThreshMethod_BlockSize_Delta;
PERF_TEST_P(Size_AdaptThreshType_AdaptThreshMethod_BlockSize_Delta, adaptiveThreshold,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
AdaptThreshType::all(),
AdaptThreshMethod::all(),
testing::Values(3, 5),
testing::Values(0.0, 10.0)
)
)
{
Size sz = get<0>(GetParam());
AdaptThreshType adaptThreshType = get<1>(GetParam());
AdaptThreshMethod adaptThreshMethod = get<2>(GetParam());
int blockSize = get<3>(GetParam());
double C = get<4>(GetParam());
double maxValue = theRNG().uniform(1, 254);
int type = CV_8UC1;
Mat src_full(cv::Size(sz.width + 2, sz.height + 2), type);
Mat src = src_full(cv::Rect(1, 1, sz.width, sz.height));
Mat dst(sz, type);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() cv::adaptiveThreshold(src, dst, maxValue, adaptThreshMethod, adaptThreshType, blockSize, C);
SANITY_CHECK(dst);
}
} // namespace

View File

@ -0,0 +1,312 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE)
CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR)
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH)
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode> > TestWarpAffine;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode> > TestWarpPerspective;
typedef TestBaseWithParam< tuple<Size, InterType, BorderMode, MatType> > TestWarpPerspectiveNear_t;
typedef TestBaseWithParam< tuple<MatType, Size, InterType, BorderMode, RemapMode> > TestRemap;
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode );
PERF_TEST_P( TestWarpAffine, WarpAffine,
Combine(
Values( szVGA, sz720p, sz1080p ),
InterType::all(),
BorderMode::all()
)
)
{
Size sz, szSrc(512, 512);
int borderMode, interType;
sz = get<0>(GetParam());
interType = get<1>(GetParam());
borderMode = get<2>(GetParam());
Scalar borderColor = Scalar::all(150);
Mat src(szSrc,CV_8UC4), dst(sz, CV_8UC4);
cvtest::fillGradient(src);
if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
Mat warpMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
declare.in(src).out(dst);
TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, borderColor );
#ifdef __ANDROID__
SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
PERF_TEST_P(TestWarpAffine, DISABLED_WarpAffine_ovx,
Combine(
Values(szVGA, sz720p, sz1080p),
InterType::all(),
BorderMode::all()
)
)
{
Size sz, szSrc(512, 512);
int borderMode, interType;
sz = get<0>(GetParam());
interType = get<1>(GetParam());
borderMode = get<2>(GetParam());
Scalar borderColor = Scalar::all(150);
Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
cvtest::fillGradient(src);
if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
Mat warpMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
declare.in(src).out(dst);
TEST_CYCLE() warpAffine(src, dst, warpMat, sz, interType, borderMode, borderColor);
#ifdef __ANDROID__
SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
Combine(
Values( szVGA, sz720p, sz1080p ),
InterType::all(),
BorderMode::all()
)
)
{
Size sz, szSrc(512, 512);
int borderMode, interType;
sz = get<0>(GetParam());
interType = get<1>(GetParam());
borderMode = get<2>(GetParam());
Scalar borderColor = Scalar::all(150);
Mat src(szSrc,CV_8UC4), dst(sz, CV_8UC4);
cvtest::fillGradient(src);
if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
Mat rotMat = getRotationMatrix2D(Point2f(src.cols/2.f, src.rows/2.f), 30., 2.2);
Mat warpMat(3, 3, CV_64FC1);
for(int r=0; r<2; r++)
for(int c=0; c<3; c++)
warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
warpMat.at<double>(2, 0) = .3/sz.width;
warpMat.at<double>(2, 1) = .3/sz.height;
warpMat.at<double>(2, 2) = 1;
declare.in(src).out(dst);
TEST_CYCLE() warpPerspective( src, dst, warpMat, sz, interType, borderMode, borderColor );
#ifdef __ANDROID__
SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
PERF_TEST_P(TestWarpPerspective, DISABLED_WarpPerspective_ovx,
Combine(
Values(szVGA, sz720p, sz1080p),
InterType::all(),
BorderMode::all()
)
)
{
Size sz, szSrc(512, 512);
int borderMode, interType;
sz = get<0>(GetParam());
interType = get<1>(GetParam());
borderMode = get<2>(GetParam());
Scalar borderColor = Scalar::all(150);
Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
cvtest::fillGradient(src);
if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
Mat rotMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
Mat warpMat(3, 3, CV_64FC1);
for (int r = 0; r<2; r++)
for (int c = 0; c<3; c++)
warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
warpMat.at<double>(2, 0) = .3 / sz.width;
warpMat.at<double>(2, 1) = .3 / sz.height;
warpMat.at<double>(2, 2) = 1;
declare.in(src).out(dst);
TEST_CYCLE() warpPerspective(src, dst, warpMat, sz, interType, borderMode, borderColor);
#ifdef __ANDROID__
SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Combine(
Values( Size(640,480), Size(1920,1080), Size(2592,1944) ),
InterType::all(),
BorderMode::all(),
Values( CV_8UC1, CV_8UC4 )
)
)
{
Size size;
int borderMode, interType, type;
size = get<0>(GetParam());
interType = get<1>(GetParam());
borderMode = get<2>(GetParam());
type = get<3>(GetParam());
Scalar borderColor = Scalar::all(150);
Mat src(size, type), dst(size, type);
cvtest::fillGradient(src);
if(borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
int shift = static_cast<int>(src.cols*0.04);
Mat srcVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, 0),
Vec2f(static_cast<float>(size.width-1), 0),
Vec2f(static_cast<float>(size.width-1), static_cast<float>(size.height-1)),
Vec2f(0, static_cast<float>(size.height-1)));
Mat dstVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, static_cast<float>(shift)),
Vec2f(static_cast<float>(size.width-shift/2), 0),
Vec2f(static_cast<float>(size.width-shift), static_cast<float>(size.height-shift)),
Vec2f(static_cast<float>(shift/2), static_cast<float>(size.height-1)));
Mat warpMat = getPerspectiveTransform(srcVertices, dstVertices);
declare.in(src).out(dst);
declare.time(100);
TEST_CYCLE()
{
warpPerspective( src, dst, warpMat, size, interType, borderMode, borderColor );
}
#ifdef __ANDROID__
SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
PERF_TEST_P( TestRemap, remap,
Combine(
Values( CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1 ),
Values( szVGA, sz1080p ),
InterType::all(),
BorderMode::all(),
RemapMode::all()
)
)
{
int type = get<0>(GetParam());
Size size = get<1>(GetParam());
int interpolationType = get<2>(GetParam());
int borderMode = get<3>(GetParam());
int remapMode = get<4>(GetParam());
unsigned int height = size.height;
unsigned int width = size.width;
Mat source(height, width, type);
Mat destination;
Mat map_x(height, width, CV_32F);
Mat map_y(height, width, CV_32F);
declare.in(source, WARMUP_RNG);
update_map(source, map_x, map_y, remapMode);
TEST_CYCLE()
{
remap(source, destination, map_x, map_y, interpolationType, borderMode);
}
SANITY_CHECK_NOTHING();
}
void update_map(const Mat& src, Mat& map_x, Mat& map_y, const int remapMode )
{
for( int j = 0; j < src.rows; j++ )
{
for( int i = 0; i < src.cols; i++ )
{
switch( remapMode )
{
case HALF_SIZE:
if( i > src.cols*0.25 && i < src.cols*0.75 && j > src.rows*0.25 && j < src.rows*0.75 )
{
map_x.at<float>(j,i) = 2*( i - src.cols*0.25f ) + 0.5f ;
map_y.at<float>(j,i) = 2*( j - src.rows*0.25f ) + 0.5f ;
}
else
{
map_x.at<float>(j,i) = 0 ;
map_y.at<float>(j,i) = 0 ;
}
break;
case UPSIDE_DOWN:
map_x.at<float>(j,i) = static_cast<float>(i) ;
map_y.at<float>(j,i) = static_cast<float>(src.rows - j) ;
break;
case REFLECTION_X:
map_x.at<float>(j,i) = static_cast<float>(src.cols - i) ;
map_y.at<float>(j,i) = static_cast<float>(j) ;
break;
case REFLECTION_BOTH:
map_x.at<float>(j,i) = static_cast<float>(src.cols - i) ;
map_y.at<float>(j,i) = static_cast<float>(src.rows - j) ;
break;
} // end of switch
}
}
}
PERF_TEST(Transform, getPerspectiveTransform_1000)
{
unsigned int size = 8;
Mat source(1, size/2, CV_32FC2);
Mat destination(1, size/2, CV_32FC2);
Mat transformCoefficient;
declare.in(source, destination, WARMUP_RNG);
PERF_SAMPLE_BEGIN()
for (int i = 0; i < 1000; i++)
{
transformCoefficient = getPerspectiveTransform(source, destination);
}
PERF_SAMPLE_END()
SANITY_CHECK_NOTHING();
}
PERF_TEST(Transform, getPerspectiveTransform_QR_1000)
{
unsigned int size = 8;
Mat source(1, size/2, CV_32FC2);
Mat destination(1, size/2, CV_32FC2);
Mat transformCoefficient;
declare.in(source, destination, WARMUP_RNG);
PERF_SAMPLE_BEGIN()
for (int i = 0; i < 1000; i++)
{
transformCoefficient = getPerspectiveTransform(source, destination, DECOMP_QR);
}
PERF_SAMPLE_END()
SANITY_CHECK_NOTHING();
}
} // namespace