From 6fbaff6d837a1f297d4e281e15aae8b7a72a59ed Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 13:09:58 +0400 Subject: [PATCH 01/12] added perf tests for T-API warp operations --- modules/imgproc/perf/opencl/perf_imgwarp.cpp | 207 +++++++++++++++++++ modules/imgproc/src/opencl/resize.cl | 1 - 2 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 modules/imgproc/perf/opencl/perf_imgwarp.cpp diff --git a/modules/imgproc/perf/opencl/perf_imgwarp.cpp b/modules/imgproc/perf/opencl/perf_imgwarp.cpp new file mode 100644 index 000000000..a2fce368e --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_imgwarp.cpp @@ -0,0 +1,207 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ +#include "perf_precomp.hpp" +#include "opencv2/ts/ocl_perf.hpp" + +#ifdef HAVE_OPENCL + +namespace cvtest { +namespace ocl { + +///////////// WarpAffine //////////////////////// + +CV_ENUM(InterType, INTER_NEAREST, INTER_LINEAR) + +typedef tuple WarpAffineParams; +typedef TestBaseWithParam WarpAffineFixture; + +OCL_PERF_TEST_P(WarpAffineFixture, WarpAffine, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, 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 : 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 WarpPerspectiveFixture; + +OCL_PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all())) +{ + 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 ResizeParams; +typedef TestBaseWithParam ResizeFixture; + +OCL_PERF_TEST_P(ResizeFixture, Resize, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, + InterType::all(), ::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 ResizeAreaParams; +typedef TestBaseWithParam ResizeAreaFixture; + +OCL_PERF_TEST_P(ResizeAreaFixture, Resize, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ::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); +} + +///////////// Remap //////////////////////// + +typedef tuple RemapParams; +typedef TestBaseWithParam RemapFixture; + +OCL_PERF_TEST_P(RemapFixture, Remap, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, InterType::all())) +{ + 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; + + 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(i); + float * const ymap_row = _ymap.ptr(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(dst, eps); +} + +} } // namespace cvtest::ocl + +#endif // HAVE_OPENCL diff --git a/modules/imgproc/src/opencl/resize.cl b/modules/imgproc/src/opencl/resize.cl index 92491615e..ecab2faa5 100644 --- a/modules/imgproc/src/opencl/resize.cl +++ b/modules/imgproc/src/opencl/resize.cl @@ -50,7 +50,6 @@ #define INTER_RESIZE_COEF_BITS 11 #define INTER_RESIZE_COEF_SCALE (1 << INTER_RESIZE_COEF_BITS) #define CAST_BITS (INTER_RESIZE_COEF_BITS << 1) -#define CAST_SCALE (1.0f/(1< Date: Mon, 13 Jan 2014 14:06:15 +0400 Subject: [PATCH 02/12] added perf tests for cv::blendLinear --- modules/imgproc/perf/opencl/perf_blend.cpp | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 modules/imgproc/perf/opencl/perf_blend.cpp diff --git a/modules/imgproc/perf/opencl/perf_blend.cpp b/modules/imgproc/perf/opencl/perf_blend.cpp new file mode 100644 index 000000000..f595069bd --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_blend.cpp @@ -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 cvtest { +namespace ocl { + +///////////// BlendLinear //////////////////////// + +typedef Size_MatType BlendLinearFixture; + +OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4))) +{ + 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 cvtest::ocl + +#endif // HAVE_OPENCL From e76d51511ed27517210d2e5c28c439716ebbc4da Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 14:14:22 +0400 Subject: [PATCH 03/12] added perf test for cv::cvtColor, pyr operations --- modules/imgproc/perf/opencl/perf_color.cpp | 104 +++++++++++++++++++ modules/imgproc/perf/opencl/perf_imgwarp.cpp | 2 + modules/imgproc/perf/opencl/perf_pyramid.cpp | 104 +++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 modules/imgproc/perf/opencl/perf_color.cpp create mode 100644 modules/imgproc/perf/opencl/perf_pyramid.cpp diff --git a/modules/imgproc/perf/opencl/perf_color.cpp b/modules/imgproc/perf/opencl/perf_color.cpp new file mode 100644 index 000000000..1c6947082 --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_color.cpp @@ -0,0 +1,104 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "perf_precomp.hpp" +#include "opencv2/ts/ocl_perf.hpp" + +#ifdef HAVE_OPENCL + +namespace cvtest { +namespace ocl { + +using std::tr1::make_tuple; + +///////////// 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_YUV2RGB_NV12) + +typedef tuple > CvtColorParams; +typedef TestBaseWithParam 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_YUV2RGB_NV12), 1, 3) + ))) +{ + CvtColorParams params = GetParam(); + const Size srcSize = get<0>(params); + const tuple 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 cvtest::ocl + +#endif // HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_imgwarp.cpp b/modules/imgproc/perf/opencl/perf_imgwarp.cpp index a2fce368e..f309d283c 100644 --- a/modules/imgproc/perf/opencl/perf_imgwarp.cpp +++ b/modules/imgproc/perf/opencl/perf_imgwarp.cpp @@ -178,6 +178,8 @@ OCL_PERF_TEST_P(RemapFixture, Remap, 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); diff --git a/modules/imgproc/perf/opencl/perf_pyramid.cpp b/modules/imgproc/perf/opencl/perf_pyramid.cpp new file mode 100644 index 000000000..c81ff1861 --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_pyramid.cpp @@ -0,0 +1,104 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ +#include "perf_precomp.hpp" +#include "opencv2/ts/ocl_perf.hpp" + +#ifdef HAVE_OPENCL + +namespace cvtest { +namespace ocl { + +///////////// PyrDown ////////////////////// + +typedef Size_MatType PyrDownFixture; + +OCL_PERF_TEST_P(PyrDownFixture, PyrDown, + ::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); + 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)) +{ + 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::pyrDown(src, dst); + + SANITY_CHECK(dst, eps); +} + +} } // namespace cvtest::ocl + +#endif // HAVE_OPENCL From 04ae46e21c3c2df807764313b70a6e87bb2b082e Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 15:01:52 +0400 Subject: [PATCH 04/12] added perf tests to some imgproc functions --- modules/imgproc/perf/opencl/perf_imgproc.cpp | 202 +++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 modules/imgproc/perf/opencl/perf_imgproc.cpp diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp new file mode 100644 index 000000000..117fe1ad6 --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -0,0 +1,202 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "perf_precomp.hpp" +#include "opencv2/ts/ocl_perf.hpp" + +#ifdef HAVE_OPENCL + +namespace cvtest { +namespace ocl { + +///////////// equalizeHist //////////////////////// + +typedef TestBaseWithParam EqualizeHistFixture; + +OCL_PERF_TEST_P(EqualizeHistFixture, EqualizeHist, OCL_TEST_SIZES) +{ + const Size srcSize = GetParam(); + const double eps = 1; + + UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::equalizeHist(src, dst); + + SANITY_CHECK(dst, eps); +} + +/////////// CopyMakeBorder ////////////////////// + +CV_ENUM(Border, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101) + +typedef tuple CopyMakeBorderParamType; +typedef TestBaseWithParam CopyMakeBorderFixture; + +OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, Border::all())) +{ + const CopyMakeBorderParamType params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), borderType = get<2>(params); + + UMat src(srcSize, type), dst; + const Size dstSize = srcSize + Size(12, 12); + dst.create(dstSize, type); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::copyMakeBorder(src, dst, 7, 5, 5, 7, borderType, cv::Scalar(1.0)); + + SANITY_CHECK(dst); +} + +///////////// CornerMinEigenVal //////////////////////// + +typedef Size_MatType CornerMinEigenValFixture; + +OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), borderType = BORDER_REFLECT; + const int blockSize = 7, apertureSize = 1 + 2 * 3; + + UMat src(srcSize, type), dst(srcSize, CV_32FC1); + declare.in(src, WARMUP_RNG).out(dst); + + const int depth = CV_MAT_DEPTH(type); + const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE; + + OCL_TEST_CYCLE() cv::cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType); + + SANITY_CHECK(dst, 1e-6, errorType); +} + +///////////// CornerHarris //////////////////////// + +typedef Size_MatType CornerHarrisFixture; + +OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris, + ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1))) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), borderType = BORDER_REFLECT; + + UMat src(srcSize, type), dst(srcSize, CV_32FC1); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::cornerHarris(src, dst, 5, 7, 0.1, borderType); + + SANITY_CHECK(dst, 3e-5); +} + +///////////// Integral //////////////////////// + +typedef tuple IntegralParams; +typedef TestBaseWithParam IntegralFixture; + +OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32F, CV_64F))) +{ + const IntegralParams params = GetParam(); + const Size srcSize = get<0>(params); + const int ddepth = get<1>(params); + + UMat src(srcSize, CV_8UC1), dst(srcSize, ddepth); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::integral(src, dst, ddepth); + + SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); +} + +///////////// Threshold //////////////////////// + +CV_ENUM(ThreshType, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO_INV) + +typedef tuple ThreshParams; +typedef TestBaseWithParam ThreshFixture; + +OCL_PERF_TEST_P(ThreshFixture, Threshold, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, ThreshType::all())) +{ + const ThreshParams params = GetParam(); + const Size srcSize = get<0>(params); + const int srcType = get<1>(params); + const int threshType = get<2>(params); + const double maxValue = 220.0, threshold = 50; + + UMat src(srcSize, srcType), dst(srcSize, srcType); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::threshold(src, dst, threshold, maxValue, threshType); + + SANITY_CHECK(dst); +} + +///////////// CLAHE //////////////////////// + +typedef TestBaseWithParam CLAHEFixture; + +OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES) +{ + const Size srcSize = GetParam(); + + UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); + const double clipLimit = 40.0; + declare.in(src, WARMUP_RNG).out(dst); + + cv::Ptr clahe = cv::createCLAHE(clipLimit); + OCL_TEST_CYCLE() clahe->apply(src, dst); + + SANITY_CHECK(dst); +} + +} } // namespace cvtest::ocl + +#endif // HAVE_OPENCL + From f61597dce845732e7adef4eafa654dc6530f3348 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 15:26:50 +0400 Subject: [PATCH 05/12] added perf tests for filters --- modules/imgproc/perf/opencl/perf_filters.cpp | 231 +++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 modules/imgproc/perf/opencl/perf_filters.cpp diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp new file mode 100644 index 000000000..93d0f2faa --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -0,0 +1,231 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved. +// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// @Authors +// Fangfang Bai, fangfang@multicorewareinc.com +// Jin Ma, jin@multicorewareinc.com +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "perf_precomp.hpp" +#include "opencv2/ts/ocl_perf.hpp" + +#ifdef HAVE_OPENCL + +namespace cvtest { +namespace ocl { + +///////////// Blur //////////////////////// + +typedef Size_MatType BlurFixture; + +OCL_PERF_TEST_P(BlurFixture, Blur, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params), ksize(3, 3); + const int type = get<1>(params), bordertype = BORDER_CONSTANT; + const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::blur(src, dst, ksize, Point(-1, -1), bordertype); + + SANITY_CHECK(dst, eps); +} + +///////////// Laplacian//////////////////////// + +typedef Size_MatType LaplacianFixture; + +OCL_PERF_TEST_P(LaplacianFixture, Laplacian, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = 3; + const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize, 1); + + SANITY_CHECK(dst, eps); +} + +///////////// Erode //////////////////// + +typedef Size_MatType ErodeFixture; + +OCL_PERF_TEST_P(ErodeFixture, Erode, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = 3; + const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst).in(ker); + + OCL_TEST_CYCLE() cv::erode(src, dst, ker); + + SANITY_CHECK(dst); +} + +///////////// Sobel //////////////////////// + +typedef Size_MatType SobelFixture; + +OCL_PERF_TEST_P(SobelFixture, Sobel, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), dx = 1, dy = 1; + + checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::Sobel(src, dst, -1, dx, dy); + + SANITY_CHECK(dst); +} + +///////////// Scharr //////////////////////// + +typedef Size_MatType ScharrFixture; + +OCL_PERF_TEST_P(ScharrFixture, Scharr, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), dx = 1, dy = 0; + const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; + + checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::Scharr(src, dst, -1, dx, dy); + + SANITY_CHECK(dst, eps); +} + +///////////// GaussianBlur //////////////////////// + +typedef Size_MatType GaussianBlurFixture; + +OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = 7; + const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 + DBL_EPSILON : 3e-4; + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::GaussianBlur(src, dst, Size(ksize, ksize), 0); + + SANITY_CHECK(dst, eps); +} + +///////////// Filter2D //////////////////////// + +typedef Size_MatType Filter2DFixture; + +OCL_PERF_TEST_P(Filter2DFixture, Filter2D, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = 3; + const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type), kernel(ksize, ksize, CV_32SC1); + declare.in(src, WARMUP_RNG).in(kernel).out(dst); + randu(kernel, -3.0, 3.0); + + OCL_TEST_CYCLE() cv::filter2D(src, dst, -1, kernel); + + SANITY_CHECK(dst, eps); +} + +///////////// Bilateral //////////////////////// + +typedef TestBaseWithParam BilateralFixture; + +OCL_PERF_TEST_P(BilateralFixture, Bilateral, OCL_TEST_SIZES) +{ + const Size srcSize = GetParam(); + const int d = 7; + const double sigmacolor = 50.0, sigmaspace = 50.0; + + checkDeviceMaxMemoryAllocSize(srcSize, CV_8UC1); + + UMat src(srcSize, CV_8UC1), dst(srcSize, CV_8UC1); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::bilateralFilter(src, dst, d, sigmacolor, sigmaspace); + + SANITY_CHECK(dst); +} + +} } // namespace cvtest::ocl + +#endif // HAVE_OPENCL From 5a2a0b326a47f647eec9b438e6d1789a3b3678fa Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 15:30:35 +0400 Subject: [PATCH 06/12] added perf tests for cv::dilate --- modules/imgproc/perf/opencl/perf_filters.cpp | 22 ++++++++++++++++++++ modules/imgproc/perf/opencl/perf_imgproc.cpp | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp index 93d0f2faa..27abe051f 100644 --- a/modules/imgproc/perf/opencl/perf_filters.cpp +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -118,6 +118,28 @@ OCL_PERF_TEST_P(ErodeFixture, Erode, SANITY_CHECK(dst); } +///////////// Dilate //////////////////// + +typedef Size_MatType DilateFixture; + +OCL_PERF_TEST_P(DilateFixture, Dilate, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), ksize = 3; + const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst).in(ker); + + OCL_TEST_CYCLE() cv::dilate(src, dst, ker); + + SANITY_CHECK(dst); +} + ///////////// Sobel //////////////////////// typedef Size_MatType SobelFixture; diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index 117fe1ad6..d7d03b7b3 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -199,4 +199,3 @@ OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES) } } // namespace cvtest::ocl #endif // HAVE_OPENCL - From 5e7fd8bd7e95ab4f8e146de85e9d5bbf3cf735b9 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 15:43:09 +0400 Subject: [PATCH 07/12] added perf tests for cv::morphologyEx --- modules/imgproc/perf/opencl/perf_filters.cpp | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp index 27abe051f..96424ab04 100644 --- a/modules/imgproc/perf/opencl/perf_filters.cpp +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -140,6 +140,31 @@ OCL_PERF_TEST_P(DilateFixture, Dilate, SANITY_CHECK(dst); } +///////////// MorphologyEx //////////////////////// + +CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT) + +typedef tuple MorphologyExParams; +typedef TestBaseWithParam MorphologyExFixture; + +OCL_PERF_TEST_P(MorphologyExFixture, MorphologyEx, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, MorphOp::all())) +{ + const MorphologyExParams params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params), op = get<2>(params), ksize = 3; + const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type); + declare.in(src, WARMUP_RNG).out(dst).in(ker); + + OCL_TEST_CYCLE() cv::morphologyEx(src, dst, op, ker); + + SANITY_CHECK(dst); +} + ///////////// Sobel //////////////////////// typedef Size_MatType SobelFixture; From 6fb878a65fc9603c9a2cfae955d08bdeaaf29864 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 15:59:24 +0400 Subject: [PATCH 08/12] added perf tests for cv::medianBlur --- modules/imgproc/perf/opencl/perf_filters.cpp | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp index 96424ab04..fad50b0bf 100644 --- a/modules/imgproc/perf/opencl/perf_filters.cpp +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -273,6 +273,27 @@ OCL_PERF_TEST_P(BilateralFixture, Bilateral, OCL_TEST_SIZES) SANITY_CHECK(dst); } +///////////// MedianBlur //////////////////////// + +typedef tuple MedianBlurParams; +typedef TestBaseWithParam 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 cvtest::ocl #endif // HAVE_OPENCL From a7a7b80ff8602f7ff4a05eef2032a7e86379acea Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 17:50:14 +0400 Subject: [PATCH 09/12] added perf test for cv::Moments --- modules/imgproc/perf/opencl/perf_imgwarp.cpp | 1 + modules/imgproc/perf/opencl/perf_moments.cpp | 78 ++++++++++++++++++++ modules/imgproc/perf/opencl/perf_pyramid.cpp | 1 + modules/ts/include/opencv2/ts/ts_perf.hpp | 2 + modules/ts/src/ts_perf.cpp | 8 ++ 5 files changed, 90 insertions(+) create mode 100644 modules/imgproc/perf/opencl/perf_moments.cpp diff --git a/modules/imgproc/perf/opencl/perf_imgwarp.cpp b/modules/imgproc/perf/opencl/perf_imgwarp.cpp index f309d283c..c2efda7e5 100644 --- a/modules/imgproc/perf/opencl/perf_imgwarp.cpp +++ b/modules/imgproc/perf/opencl/perf_imgwarp.cpp @@ -43,6 +43,7 @@ // 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" diff --git a/modules/imgproc/perf/opencl/perf_moments.cpp b/modules/imgproc/perf/opencl/perf_moments.cpp new file mode 100644 index 000000000..e77b76850 --- /dev/null +++ b/modules/imgproc/perf/opencl/perf_moments.cpp @@ -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 cvtest { +namespace ocl { + +///////////// Moments //////////////////////// + +typedef tuple MomentsParams; +typedef TestBaseWithParam 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 cvtest::ocl + +#endif // HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_pyramid.cpp b/modules/imgproc/perf/opencl/perf_pyramid.cpp index c81ff1861..4beba2280 100644 --- a/modules/imgproc/perf/opencl/perf_pyramid.cpp +++ b/modules/imgproc/perf/opencl/perf_pyramid.cpp @@ -43,6 +43,7 @@ // 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" diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 499b53cad..fdee4e8bd 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -164,6 +164,7 @@ class CV_EXPORTS Regression { public: static Regression& add(TestBase* test, const std::string& name, cv::InputArray array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); + static Regression& addMoments(TestBase* test, const std::string& name, const cv::Moments & array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); static Regression& addKeypoints(TestBase* test, const std::string& name, const std::vector& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); static Regression& addMatches(TestBase* test, const std::string& name, const std::vector& array, double eps = DBL_EPSILON, ERROR_TYPE err = ERROR_ABSOLUTE); static void Init(const std::string& testSuitName, const std::string& ext = ".xml"); @@ -201,6 +202,7 @@ private: }; #define SANITY_CHECK(array, ...) ::perf::Regression::add(this, #array, array , ## __VA_ARGS__) +#define SANITY_CHECK_MOMENTS(array, ...) ::perf::Regression::addMoments(this, #array, array , ## __VA_ARGS__) #define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__) #define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__) #define SANITY_CHECK_NOTHING() this->setVerified(); diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 576c97f2e..35204c291 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -115,6 +115,14 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr return instance()(name, array, eps, err); } +Regression& Regression::addMoments(TestBase* test, const std::string& name, const cv::Moments& array, double eps, ERROR_TYPE err) +{ + int len = (int)sizeof(cv::Moments) / sizeof(double); + cv::Mat m(1, len, CV_64F, (void*)&array); + + return Regression::add(test, name, m, eps, err); +} + Regression& Regression::addKeypoints(TestBase* test, const std::string& name, const std::vector& array, double eps, ERROR_TYPE err) { int len = (int)array.size(); From 8702fceb4b609ed090a1a8dc6930aa4376dc157d Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 18:36:25 +0400 Subject: [PATCH 10/12] fixed cv::integral perf test --- modules/imgproc/perf/opencl/perf_imgproc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index d7d03b7b3..1b8ebc23f 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -140,7 +140,7 @@ OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris, typedef tuple IntegralParams; typedef TestBaseWithParam IntegralFixture; -OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32F, CV_64F))) +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); From 30b5234e9afca8ad60a8a139e8bc5b25b6e2e0bb Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 18:51:49 +0400 Subject: [PATCH 11/12] added perf test for cv::sqrBoxFilter --- modules/imgproc/perf/opencl/perf_imgproc.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index 1b8ebc23f..d5de677d0 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -146,7 +146,7 @@ OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, O const Size srcSize = get<0>(params); const int ddepth = get<1>(params); - UMat src(srcSize, CV_8UC1), dst(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); @@ -196,6 +196,22 @@ OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES) SANITY_CHECK(dst); } +///////////// SqrBoxFilter //////////////////////// + +typedef TestBaseWithParam SqrBoxFilterFixture; + +OCL_PERF_TEST_P(SqrBoxFilterFixture, SqrBoxFilter, OCL_TEST_SIZES) +{ + const Size srcSize = GetParam(); + + UMat src(srcSize, CV_8UC1), dst(srcSize, CV_32SC1); + declare.in(src, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() cv::sqrBoxFilter(src, dst, CV_32S, Size(3, 3)); + + SANITY_CHECK(dst); +} + } } // namespace cvtest::ocl #endif // HAVE_OPENCL From 82d3efc6c053455f1217e5af32732b69ef834a51 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 13 Jan 2014 19:46:00 +0400 Subject: [PATCH 12/12] added perf test for cv::Canny --- modules/imgproc/perf/opencl/perf_filters.cpp | 61 ++++++++++---------- modules/imgproc/perf/opencl/perf_imgproc.cpp | 28 ++++++++- modules/ts/include/opencv2/ts/ocl_perf.hpp | 32 +++++++--- 3 files changed, 82 insertions(+), 39 deletions(-) diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp index fad50b0bf..25b11caad 100644 --- a/modules/imgproc/perf/opencl/perf_filters.cpp +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -52,16 +52,19 @@ namespace cvtest { namespace ocl { +typedef tuple FilterParams; +typedef TestBaseWithParam FilterFixture; + ///////////// Blur //////////////////////// -typedef Size_MatType BlurFixture; +typedef FilterFixture BlurFixture; OCL_PERF_TEST_P(BlurFixture, Blur, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); - const Size srcSize = get<0>(params), ksize(3, 3); - const int type = get<1>(params), bordertype = BORDER_CONSTANT; + const 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); @@ -69,21 +72,21 @@ OCL_PERF_TEST_P(BlurFixture, Blur, UMat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::blur(src, dst, ksize, Point(-1, -1), bordertype); + OCL_TEST_CYCLE() cv::blur(src, dst, Size(ksize, ksize), Point(-1, -1), bordertype); SANITY_CHECK(dst, eps); } ///////////// Laplacian//////////////////////// -typedef Size_MatType LaplacianFixture; +typedef FilterFixture LaplacianFixture; OCL_PERF_TEST_P(LaplacianFixture, Laplacian, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + 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); @@ -98,14 +101,14 @@ OCL_PERF_TEST_P(LaplacianFixture, Laplacian, ///////////// Erode //////////////////// -typedef Size_MatType ErodeFixture; +typedef FilterFixture ErodeFixture; OCL_PERF_TEST_P(ErodeFixture, Erode, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + const int type = get<1>(params), ksize = get<2>(params); const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -120,14 +123,14 @@ OCL_PERF_TEST_P(ErodeFixture, Erode, ///////////// Dilate //////////////////// -typedef Size_MatType DilateFixture; +typedef FilterFixture DilateFixture; OCL_PERF_TEST_P(DilateFixture, Dilate, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + const int type = get<1>(params), ksize = get<2>(params); const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -144,15 +147,15 @@ OCL_PERF_TEST_P(DilateFixture, Dilate, CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT) -typedef tuple MorphologyExParams; +typedef tuple MorphologyExParams; typedef TestBaseWithParam MorphologyExFixture; OCL_PERF_TEST_P(MorphologyExFixture, MorphologyEx, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, MorphOp::all())) + ::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 = 3; + 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); @@ -210,14 +213,14 @@ OCL_PERF_TEST_P(ScharrFixture, Scharr, ///////////// GaussianBlur //////////////////////// -typedef Size_MatType GaussianBlurFixture; +typedef FilterFixture GaussianBlurFixture; OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5, 7))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 7; + const int type = get<1>(params), ksize = get<2>(params); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 + DBL_EPSILON : 3e-4; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -232,14 +235,14 @@ OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur, ///////////// Filter2D //////////////////////// -typedef Size_MatType Filter2DFixture; +typedef FilterFixture Filter2DFixture; OCL_PERF_TEST_P(Filter2DFixture, Filter2D, - ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES, OCL_PERF_ENUM(3, 5))) { - const Size_MatType_t params = GetParam(); + const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = 3; + 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); diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index d5de677d0..7c102fa21 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -132,7 +132,7 @@ OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris, OCL_TEST_CYCLE() cv::cornerHarris(src, dst, 5, 7, 0.1, borderType); - SANITY_CHECK(dst, 3e-5); + SANITY_CHECK(dst, 5e-5); } ///////////// Integral //////////////////////// @@ -212,6 +212,32 @@ OCL_PERF_TEST_P(SqrBoxFilterFixture, SqrBoxFilter, OCL_TEST_SIZES) SANITY_CHECK(dst); } +///////////// Canny //////////////////////// + +typedef tuple CannyParams; +typedef TestBaseWithParam CannyFixture; + +OCL_PERF_TEST_P(CannyFixture, Canny, ::testing::Combine(OCL_PERF_ENUM(3, 5), Bool())) +{ + const CannyParams params = GetParam(); + int apertureSize = get<0>(params); + bool L2Grad = get<1>(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; + _img.copyTo(img); + UMat edges(img.size(), CV_8UC1); + + declare.in(img, WARMUP_RNG).out(edges); + + OCL_TEST_CYCLE() cv::Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad); + + SANITY_CHECK(edges); +} + + } } // namespace cvtest::ocl #endif // HAVE_OPENCL diff --git a/modules/ts/include/opencv2/ts/ocl_perf.hpp b/modules/ts/include/opencv2/ts/ocl_perf.hpp index 0024377df..37d28862e 100644 --- a/modules/ts/include/opencv2/ts/ocl_perf.hpp +++ b/modules/ts/include/opencv2/ts/ocl_perf.hpp @@ -57,19 +57,33 @@ using std::tr1::tuple; #define OCL_PERF_STRATEGY PERF_STRATEGY_SIMPLE +#define OCL_PERF_TEST(fixture, name) SIMPLE_PERF_TEST(fixture, name) #define OCL_PERF_TEST_P(fixture, name, params) SIMPLE_PERF_TEST_P(fixture, name, params) -#define SIMPLE_PERF_TEST_P(fixture, name, params)\ - class OCL##_##fixture##_##name : public fixture {\ - public:\ - OCL##_##fixture##_##name() {}\ - protected:\ - virtual void PerfTestBody();\ - };\ - TEST_P(OCL##_##fixture##_##name, name){ declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); }\ - INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params);\ +#define SIMPLE_PERF_TEST(fixture, name) \ + class OCL##_##fixture##_##name : \ + public ::perf::TestBase \ + { \ + public: \ + OCL##_##fixture##_##name() { } \ + protected: \ + virtual void PerfTestBody(); \ + }; \ + TEST_F(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \ void OCL##_##fixture##_##name::PerfTestBody() +#define SIMPLE_PERF_TEST_P(fixture, name, params) \ + class OCL##_##fixture##_##name : \ + public fixture \ + { \ + public: \ + OCL##_##fixture##_##name() { } \ + protected: \ + virtual void PerfTestBody(); \ + }; \ + TEST_P(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \ + INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params); \ + void OCL##_##fixture##_##name::PerfTestBody() #define OCL_SIZE_1 szVGA #define OCL_SIZE_2 sz720p