feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
		
							
								
								
									
										137
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_3vs4.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_3vs4.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										140
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_accumulate.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_accumulate.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										82
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_blend.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_blend.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										113
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_color.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_color.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										415
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_filters.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										415
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_filters.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										116
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_gftt.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_gftt.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										91
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_houghlines.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_houghlines.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										336
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_imgproc.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										336
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_imgproc.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										237
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_imgwarp.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										237
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_imgwarp.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										88
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_matchTemplate.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_matchTemplate.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										78
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_moments.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_moments.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										134
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_pyramid.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								3rdparty/opencv-4.5.4/modules/imgproc/perf/opencl/perf_pyramid.cpp
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
		Reference in New Issue
	
	Block a user