vendor: OpenCV 5.0.0 snapshot at 40738fb16ceddb5fb3fea747585f7ce6abb0605b
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage 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"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/ts/cuda_perf.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
using namespace testing;
|
||||
using namespace perf;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetTo
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn, CUDA_GpuMat_SetTo,
|
||||
Combine(CUDA_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
CUDA_CHANNELS_1_3_4))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
const cv::Scalar val(1, 2, 3, 4);
|
||||
|
||||
if (PERF_RUN_CUDA())
|
||||
{
|
||||
cv::cuda::GpuMat dst(size, type);
|
||||
|
||||
TEST_CYCLE() dst.setTo(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst(size, type);
|
||||
|
||||
TEST_CYCLE() dst.setTo(val);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetToMasked
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn, CUDA_GpuMat_SetToMasked,
|
||||
Combine(CUDA_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
CUDA_CHANNELS_1_3_4))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
cv::Mat mask(size, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG);
|
||||
|
||||
const cv::Scalar val(1, 2, 3, 4);
|
||||
|
||||
if (PERF_RUN_CUDA())
|
||||
{
|
||||
cv::cuda::GpuMat dst(src);
|
||||
const cv::cuda::GpuMat d_mask(mask);
|
||||
|
||||
TEST_CYCLE() dst.setTo(val, d_mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst = src;
|
||||
|
||||
TEST_CYCLE() dst.setTo(val, mask);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CopyToMasked
|
||||
|
||||
PERF_TEST_P(Sz_Depth_Cn, CUDA_GpuMat_CopyToMasked,
|
||||
Combine(CUDA_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
CUDA_CHANNELS_1_3_4))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth = GET_PARAM(1);
|
||||
const int channels = GET_PARAM(2);
|
||||
|
||||
const int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
cv::Mat src(size, type);
|
||||
cv::Mat mask(size, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG);
|
||||
|
||||
if (PERF_RUN_CUDA())
|
||||
{
|
||||
const cv::cuda::GpuMat d_src(src);
|
||||
const cv::cuda::GpuMat d_mask(mask);
|
||||
cv::cuda::GpuMat dst(d_src.size(), d_src.type(), cv::Scalar::all(0));
|
||||
|
||||
TEST_CYCLE() d_src.copyTo(dst, d_mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst(src.size(), src.type(), cv::Scalar::all(0));
|
||||
|
||||
TEST_CYCLE() src.copyTo(dst, mask);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ConvertTo
|
||||
|
||||
DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
|
||||
|
||||
PERF_TEST_P(Sz_2Depth, CUDA_GpuMat_ConvertTo,
|
||||
Combine(CUDA_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
||||
Values(CV_8U, CV_16U, CV_32F, CV_64F)))
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
const int depth1 = GET_PARAM(1);
|
||||
const int depth2 = GET_PARAM(2);
|
||||
|
||||
cv::Mat src(size, depth1);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
const double a = 0.5;
|
||||
const double b = 1.0;
|
||||
|
||||
if (PERF_RUN_CUDA())
|
||||
{
|
||||
const cv::cuda::GpuMat d_src(src);
|
||||
cv::cuda::GpuMat dst;
|
||||
|
||||
TEST_CYCLE() d_src.convertTo(dst, depth2, a, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
TEST_CYCLE() src.convertTo(dst, depth2, a, b);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,132 @@
|
||||
// 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.
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
struct BufferPoolState
|
||||
{
|
||||
BufferPoolController* controller_;
|
||||
size_t oldMaxReservedSize_;
|
||||
|
||||
BufferPoolState(BufferPoolController* c, bool enable)
|
||||
: controller_(c)
|
||||
{
|
||||
if (!cv::ocl::useOpenCL())
|
||||
{
|
||||
throw ::perf::TestBase::PerfSkipTestException();
|
||||
}
|
||||
oldMaxReservedSize_ = c->getMaxReservedSize();
|
||||
if (oldMaxReservedSize_ == (size_t)-1)
|
||||
{
|
||||
throw ::perf::TestBase::PerfSkipTestException();
|
||||
}
|
||||
if (!enable)
|
||||
{
|
||||
c->setMaxReservedSize(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
c->freeAllReservedBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
~BufferPoolState()
|
||||
{
|
||||
controller_->setMaxReservedSize(oldMaxReservedSize_);
|
||||
}
|
||||
};
|
||||
|
||||
typedef TestBaseWithParam<bool> BufferPoolFixture;
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCreation100, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
UMat u(sz, CV_8UC1);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCountNonZero100, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
UMat u(sz, CV_8UC1);
|
||||
countNonZero(u);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCanny10, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
int aperture = 3;
|
||||
bool useL2 = false;
|
||||
double thresh_low = 100;
|
||||
double thresh_high = 120;
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
UMat src(sz, CV_8UC1);
|
||||
UMat dst;
|
||||
Canny(src, dst, thresh_low, thresh_high, aperture, useL2);
|
||||
dst.getMat(ACCESS_READ); // complete async operations
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatIntegral10, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
UMat src(sz, CV_32FC1);
|
||||
UMat dst;
|
||||
integral(src, dst);
|
||||
dst.getMat(ACCESS_READ); // complete async operations
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,206 @@
|
||||
/*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 {
|
||||
|
||||
///////////// Merge////////////////////////
|
||||
|
||||
typedef tuple<Size, MatDepth, int> MergeParams;
|
||||
typedef TestBaseWithParam<MergeParams> MergeFixture;
|
||||
|
||||
OCL_PERF_TEST_P(MergeFixture, Merge,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F), Values(2, 3)))
|
||||
{
|
||||
const MergeParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), cn = get<2>(params), dtype = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat dst(srcSize, dtype);
|
||||
vector<UMat> src(cn);
|
||||
for (vector<UMat>::iterator i = src.begin(), end = src.end(); i != end; ++i)
|
||||
{
|
||||
i->create(srcSize, CV_MAKE_TYPE(depth, 1));
|
||||
declare.in(*i, WARMUP_RNG);
|
||||
}
|
||||
declare.out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::merge(src, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// Split ////////////////////////
|
||||
|
||||
typedef MergeParams SplitParams;
|
||||
typedef TestBaseWithParam<SplitParams> SplitFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SplitFixture, Split,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F), Values(2, 3)))
|
||||
{
|
||||
const SplitParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), cn = get<2>(params), type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
ASSERT_TRUE(cn == 3 || cn == 2);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
std::vector<UMat> dst(cn, UMat(srcSize, CV_MAKE_TYPE(depth, 1)));
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
for (int i = 0; i < cn; ++i)
|
||||
declare.in(dst[i]);
|
||||
|
||||
OCL_TEST_CYCLE() cv::split(src, dst);
|
||||
|
||||
ASSERT_EQ(cn, (int)dst.size());
|
||||
|
||||
if (cn == 2)
|
||||
{
|
||||
UMat & dst0 = dst[0], & dst1 = dst[1];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
}
|
||||
else
|
||||
{
|
||||
UMat & dst0 = dst[0], & dst1 = dst[1], & dst2 = dst[2];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
SANITY_CHECK(dst2);
|
||||
}
|
||||
}
|
||||
|
||||
///////////// MixChannels ////////////////////////
|
||||
|
||||
typedef tuple<Size, MatDepth> MixChannelsParams;
|
||||
typedef TestBaseWithParam<MixChannelsParams> MixChannelsFixture;
|
||||
|
||||
OCL_PERF_TEST_P(MixChannelsFixture, MixChannels,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
OCL_PERF_ENUM(CV_8U, CV_32F)))
|
||||
{
|
||||
const MixChannelsParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 2), n = 2;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
std::vector<UMat> src(n), dst(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
src[i] = UMat(srcSize, type);
|
||||
dst[i] = UMat(srcSize, type);
|
||||
declare.in(src[i], WARMUP_RNG).out(dst[i]);
|
||||
}
|
||||
|
||||
int fromTo[] = { 1,2, 2,0, 0,3, 3,1 };
|
||||
|
||||
OCL_TEST_CYCLE() cv::mixChannels(src, dst, fromTo, 4);
|
||||
|
||||
UMat & dst0 = dst[0], & dst1 = dst[1];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
}
|
||||
|
||||
///////////// InsertChannel ////////////////////////
|
||||
|
||||
typedef tuple<cv::Size, MatDepth> Size_MatDepth_t;
|
||||
typedef TestBaseWithParam<Size_MatDepth_t> Size_MatDepth;
|
||||
|
||||
typedef Size_MatDepth InsertChannelFixture;
|
||||
|
||||
OCL_PERF_TEST_P(InsertChannelFixture, InsertChannel,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
OCL_PERF_ENUM(CV_8U, CV_32F)))
|
||||
{
|
||||
const Size_MatDepth_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, depth), dst(srcSize, type, Scalar::all(17));
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::insertChannel(src, dst, 1);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// ExtractChannel ////////////////////////
|
||||
|
||||
typedef Size_MatDepth ExtractChannelFixture;
|
||||
|
||||
OCL_PERF_TEST_P(ExtractChannelFixture, ExtractChannel,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
OCL_PERF_ENUM(CV_8U, CV_32F)))
|
||||
{
|
||||
const Size_MatDepth_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, depth);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::extractChannel(src, dst, 1);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,118 @@
|
||||
/*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 {
|
||||
|
||||
///////////// dft ////////////////////////
|
||||
|
||||
enum OCL_FFT_TYPE
|
||||
{
|
||||
R2R = 0,
|
||||
C2R = 1,
|
||||
R2C = 2,
|
||||
C2C = 3
|
||||
};
|
||||
|
||||
typedef tuple<OCL_FFT_TYPE, Size, int> DftParams;
|
||||
typedef TestBaseWithParam<DftParams> DftFixture;
|
||||
|
||||
OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(Values(C2C, R2R, C2R, R2C),
|
||||
Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, Size(512, 512), Size(1024, 1024), Size(2048, 2048)),
|
||||
Values((int) 0, (int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE,
|
||||
(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE)))
|
||||
{
|
||||
const DftParams params = GetParam();
|
||||
const int dft_type = get<0>(params);
|
||||
const Size srcSize = get<1>(params);
|
||||
int flags = get<2>(params);
|
||||
|
||||
int in_cn = 0, out_cn = 0;
|
||||
switch (dft_type)
|
||||
{
|
||||
case R2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 1; out_cn = 1; break;
|
||||
case C2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 2; out_cn = 2; break;
|
||||
case R2C: flags |= cv::DFT_COMPLEX_OUTPUT; in_cn = 1; out_cn = 2; break;
|
||||
case C2C: flags |= cv::DFT_COMPLEX_OUTPUT; in_cn = 2; out_cn = 2; break;
|
||||
}
|
||||
|
||||
UMat src(srcSize, CV_MAKE_TYPE(CV_32F, in_cn)), dst(srcSize, CV_MAKE_TYPE(CV_32F, out_cn));
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::dft(src, dst, flags);
|
||||
|
||||
SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
///////////// MulSpectrums ////////////////////////
|
||||
|
||||
typedef tuple<Size, bool> MulSpectrumsParams;
|
||||
typedef TestBaseWithParam<MulSpectrumsParams> MulSpectrumsFixture;
|
||||
|
||||
OCL_PERF_TEST_P(MulSpectrumsFixture, MulSpectrums,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
Bool()))
|
||||
{
|
||||
const MulSpectrumsParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const bool conj = get<1>(params);
|
||||
|
||||
UMat src1(srcSize, CV_32FC2), src2(srcSize, CV_32FC2), dst(srcSize, CV_32FC2);
|
||||
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::mulSpectrums(src1, src2, dst, 0, conj);
|
||||
|
||||
SANITY_CHECK(dst, 1e-3);
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,84 @@
|
||||
/*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 {
|
||||
|
||||
///////////// gemm ////////////////////////
|
||||
|
||||
CV_ENUM(FlagType, 0, GEMM_1_T, GEMM_2_T, GEMM_3_T, GEMM_1_T|GEMM_2_T, GEMM_2_T|GEMM_3_T)
|
||||
|
||||
typedef tuple<Size, FlagType, MatType> GemmParams;
|
||||
typedef TestBaseWithParam<GemmParams> GemmFixture;
|
||||
|
||||
OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine(
|
||||
::testing::Values(Size(640, 640), Size(1280, 1280)),
|
||||
FlagType::all(), testing::Values(CV_32FC1, CV_32FC2)))
|
||||
{
|
||||
GemmParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int flags = get<1>(params);
|
||||
const int type = get<2>(params);
|
||||
|
||||
UMat src1(srcSize, type), src2(srcSize, type), src3(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src1, src2, src3).out(dst);
|
||||
randu(src1, -10.0f, 10.0f);
|
||||
randu(src2, -10.0f, 10.0f);
|
||||
randu(src3, -10.0f, 10.0f);
|
||||
|
||||
OCL_TEST_CYCLE() cv::gemm(src1, src2, 0.6, src3, 1.5, dst, flags);
|
||||
|
||||
SANITY_CHECK(dst, 0.01);
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,435 @@
|
||||
// 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 {
|
||||
|
||||
///////////// SetTo ////////////////////////
|
||||
|
||||
typedef Size_MatType SetToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SetToFixture, SetTo,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
const Scalar s = Scalar::all(17);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(src);
|
||||
|
||||
OCL_TEST_CYCLE() src.setTo(s);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
|
||||
///////////// SetTo with mask ////////////////////////
|
||||
|
||||
typedef Size_MatType SetToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SetToFixture, SetToWithMask,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
const Scalar s = Scalar::all(17);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), mask(srcSize, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG).out(src);
|
||||
|
||||
OCL_TEST_CYCLE() src.setTo(s, mask);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
|
||||
///////////// ConvertTo ////////////////////////
|
||||
|
||||
typedef Size_MatType ConvertToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(ConvertToFixture, ConvertTo,
|
||||
::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), ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U,
|
||||
cn = CV_MAT_CN(type), dtype = CV_MAKE_TYPE(ddepth, cn);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
|
||||
static Size convertFP16_srcSize(4000, 4000);
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP32FP16MatMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_32F;
|
||||
const int dtype = CV_16F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
Mat src(srcSize, type);
|
||||
Mat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP32FP16MatUMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_32F;
|
||||
const int dtype = CV_16F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
Mat src(srcSize, type);
|
||||
UMat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP32FP16UMatMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_32F;
|
||||
const int dtype = CV_16F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
Mat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP32FP16UMatUMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_32F;
|
||||
const int dtype = CV_16F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
UMat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP16FP32MatMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_16F;
|
||||
const int dtype = CV_32F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
Mat src(srcSize, type);
|
||||
Mat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP16FP32MatUMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_16F;
|
||||
const int dtype = CV_32F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
Mat src(srcSize, type);
|
||||
UMat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP16FP32UMatMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_16F;
|
||||
const int dtype = CV_32F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
Mat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST(Core, ConvertFP16FP32UMatUMat)
|
||||
{
|
||||
const Size srcSize = convertFP16_srcSize;
|
||||
const int type = CV_16F;
|
||||
const int dtype = CV_32F;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
UMat dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
|
||||
///////////// CopyTo ////////////////////////
|
||||
|
||||
typedef Size_MatType CopyToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(CopyToFixture, CopyTo,
|
||||
::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);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.copyTo(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// CopyTo with mask ////////////////////////
|
||||
|
||||
typedef Size_MatType CopyToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask,
|
||||
::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);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type), mask(srcSize, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.copyTo(dst, mask);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
|
||||
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_TEST_TYPES))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst, mask(srcSize, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG);
|
||||
|
||||
for ( ; next(); )
|
||||
{
|
||||
dst.release();
|
||||
startTimer();
|
||||
src.copyTo(dst, mask);
|
||||
cvtest::ocl::perf::safeFinish();
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
enum ROIType {
|
||||
ROI_FULL,
|
||||
ROI_2_RECT,
|
||||
ROI_2_TOP, // contiguous memory block
|
||||
ROI_2_LEFT,
|
||||
ROI_4,
|
||||
ROI_16,
|
||||
};
|
||||
static Rect getROI(enum ROIType t, const Size& sz)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case ROI_FULL: return Rect(0, 0, sz.width, sz.height);
|
||||
case ROI_2_RECT: return Rect(0, 0, sz.width * 71 / 100, sz.height * 71 / 100); // 71 = sqrt(1/2) * 100
|
||||
case ROI_2_TOP: return Rect(0, 0, sz.width, sz.height / 2); // 71 = sqrt(1/2) * 100
|
||||
case ROI_2_LEFT: return Rect(0, 0, sz.width / 2, sz.height); // 71 = sqrt(1/2) * 100
|
||||
case ROI_4: return Rect(0, 0, sz.width / 2, sz.height / 2);
|
||||
case ROI_16: return Rect(0, 0, sz.width / 4, sz.height / 4);
|
||||
}
|
||||
CV_Assert(false);
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam< tuple<cv::Size, MatType, ROIType> > OpenCLBuffer;
|
||||
|
||||
static inline void PrintTo(const tuple<cv::Size, MatType, enum ROIType>& v, std::ostream* os)
|
||||
{
|
||||
*os << "(" << get<0>(v) << ", " << typeToString(get<1>(v)) << ", ";
|
||||
enum ROIType roiType = get<2>(v);
|
||||
if (roiType == ROI_FULL)
|
||||
*os << "ROI_100_FULL";
|
||||
else if (roiType == ROI_2_RECT)
|
||||
*os << "ROI_050_RECT_HALF";
|
||||
else if (roiType == ROI_2_TOP)
|
||||
*os << "ROI_050_TOP_HALF";
|
||||
else if (roiType == ROI_2_LEFT)
|
||||
*os << "ROI_050_LEFT_HALF";
|
||||
else if (roiType == ROI_4)
|
||||
*os << "ROI_025_1/4";
|
||||
else
|
||||
*os << "ROI_012_1/16";
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_write)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = src(roi).getMat(ACCESS_WRITE);
|
||||
m.setTo(Scalar(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_read)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type, Scalar(1, 2, 3, 4));
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
unsigned counter = 0;
|
||||
Mat m = src(roi).getMat(ACCESS_READ);
|
||||
for (int y = 0; y < m.rows; y++)
|
||||
{
|
||||
uchar* ptr = m.ptr(y);
|
||||
size_t width_bytes = m.cols * m.elemSize();
|
||||
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
|
||||
counter += (unsigned)(ptr[x_bytes]);
|
||||
}
|
||||
(void)counter; // To avoid -Wunused-but-set-variable
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_update)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type, Scalar(1, 2, 3, 4));
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = src(roi).getMat(ACCESS_READ | ACCESS_WRITE);
|
||||
for (int y = 0; y < m.rows; y++)
|
||||
{
|
||||
uchar* ptr = m.ptr(y);
|
||||
size_t width_bytes = m.cols * m.elemSize();
|
||||
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
|
||||
ptr[x_bytes] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*FULL*/, OpenCLBuffer,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p, sz2160p),
|
||||
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4),
|
||||
testing::Values(ROI_FULL)
|
||||
)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ROI, OpenCLBuffer,
|
||||
testing::Combine(
|
||||
testing::Values(sz1080p, sz2160p),
|
||||
testing::Values(CV_8UC1),
|
||||
testing::Values(ROI_16, ROI_4, ROI_2_RECT, ROI_2_LEFT, ROI_2_TOP, ROI_FULL)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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.
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
typedef TestBaseWithParam<tuple<cv::Size, UMatUsageFlags, UMatUsageFlags, UMatUsageFlags>> SizeUsageFlagsFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SizeUsageFlagsFixture, UsageFlags_AllocMem,
|
||||
::testing::Combine(
|
||||
OCL_TEST_SIZES,
|
||||
testing::Values(USAGE_DEFAULT, USAGE_ALLOCATE_HOST_MEMORY, USAGE_ALLOCATE_DEVICE_MEMORY), // USAGE_ALLOCATE_SHARED_MEMORY
|
||||
testing::Values(USAGE_DEFAULT, USAGE_ALLOCATE_HOST_MEMORY, USAGE_ALLOCATE_DEVICE_MEMORY), // USAGE_ALLOCATE_SHARED_MEMORY
|
||||
testing::Values(USAGE_DEFAULT, USAGE_ALLOCATE_HOST_MEMORY, USAGE_ALLOCATE_DEVICE_MEMORY) // USAGE_ALLOCATE_SHARED_MEMORY
|
||||
))
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
UMatUsageFlags srcAllocMem = get<1>(GetParam());
|
||||
UMatUsageFlags dstAllocMem = get<2>(GetParam());
|
||||
UMatUsageFlags finalAllocMem = get<3>(GetParam());
|
||||
|
||||
UMat src(sz, CV_8UC1, Scalar::all(128), srcAllocMem);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
UMat dst(dstAllocMem);
|
||||
|
||||
cv::add(src, Scalar::all(1), dst);
|
||||
{
|
||||
Mat canvas = dst.getMat(ACCESS_RW);
|
||||
cv::putText(canvas, "Test", Point(20, 20), FONT_HERSHEY_PLAIN, 1, Scalar::all(255));
|
||||
}
|
||||
UMat final(finalAllocMem);
|
||||
cv::subtract(dst, Scalar::all(1), final);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define TYPICAL_MAT_SIZES_ABS TYPICAL_MAT_SIZES
|
||||
#define TYPICAL_MAT_TYPES_ABS CV_8SC1, CV_8SC4, CV_32SC1, CV_32FC1
|
||||
#define TYPICAL_MATS_ABS testing::Combine( testing::Values( TYPICAL_MAT_SIZES_ABS), testing::Values( TYPICAL_MAT_TYPES_ABS) )
|
||||
|
||||
PERF_TEST_P(Size_MatType, abs, TYPICAL_MATS_ABS)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() c = cv::abs(a);
|
||||
|
||||
SANITY_CHECK(c);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define TYPICAL_MAT_TYPES_ADWEIGHTED CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1
|
||||
#define TYPICAL_MATS_ADWEIGHTED testing::Combine(testing::Values(szVGA, sz720p, sz1080p), testing::Values(TYPICAL_MAT_TYPES_ADWEIGHTED))
|
||||
|
||||
PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
int depth = CV_MAT_DEPTH(type);
|
||||
Mat src1(size, type);
|
||||
Mat src2(size, type);
|
||||
double alpha = 3.75;
|
||||
double beta = -0.125;
|
||||
double gamma = 100.0;
|
||||
|
||||
Mat dst(size, type);
|
||||
|
||||
declare.in(src1, src2, dst, WARMUP_RNG).out(dst);
|
||||
|
||||
if (depth == CV_32S)
|
||||
{
|
||||
// there might be not enough precision for integers
|
||||
src1 /= 2048;
|
||||
src2 /= 2048;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() );
|
||||
|
||||
SANITY_CHECK(dst, depth == CV_32S ? 4 : 1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include <array>
|
||||
|
||||
using namespace perf;
|
||||
|
||||
#define ALLOC_MAT_SIZES ::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64, \
|
||||
::perf::sz5MP, ::perf::sz2K, ::perf::szSmall128, ::perf::szODD, ::perf::szQVGA, \
|
||||
::perf::szVGA, ::perf::szSVGA, ::perf::sz720p, ::perf::sz1080p, ::perf::sz2160p, \
|
||||
::perf::sz4320p, ::perf::sz3MP, ::perf::szXGA, ::perf::szSXGA, ::perf::szWQHD, \
|
||||
::perf::sznHD, ::perf::szqHD
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
||||
typedef perf::TestBaseWithParam<MatType> MatDepth_tb;
|
||||
|
||||
PERF_TEST_P(MatDepth_tb, DISABLED_Allocation_Aligned,
|
||||
testing::Values(CV_8UC1, CV_16SC1, CV_8UC3, CV_8UC4))
|
||||
{
|
||||
const int matType = GetParam();
|
||||
const cv::Mat utility(1, 1, matType);
|
||||
const size_t elementBytes = utility.elemSize();
|
||||
|
||||
const std::array<cv::Size, 20> sizes{ALLOC_MAT_SIZES};
|
||||
std::array<size_t, 20> bytes;
|
||||
for (size_t i = 0; i < sizes.size(); ++i)
|
||||
{
|
||||
bytes[i] = sizes[i].width * sizes[i].height * elementBytes;
|
||||
}
|
||||
|
||||
declare.time(60)
|
||||
.iterations(100);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
{
|
||||
fastFree(fastMalloc(bytes[i % sizes.size()]));
|
||||
}
|
||||
}
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,950 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#include <numeric>
|
||||
#include "opencv2/core/softfloat.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
using BroadcastTest = perf::TestBaseWithParam<std::tuple<std::vector<int>, perf::MatType, std::vector<int>>>;
|
||||
typedef Size_MatType BinaryOpTest;
|
||||
|
||||
PERF_TEST_P_(BroadcastTest, basic)
|
||||
{
|
||||
std::vector<int> shape_src = get<0>(GetParam());
|
||||
int dt_type = get<1>(GetParam());
|
||||
std::vector<int> shape_dst = get<2>(GetParam());
|
||||
|
||||
cv::Mat src(static_cast<int>(shape_src.size()), shape_src.data(), dt_type);
|
||||
cv::Mat dst(static_cast<int>(shape_dst.size()), shape_dst.data(), dt_type);
|
||||
|
||||
cv::randu(src, -1.f, 1.f);
|
||||
|
||||
TEST_CYCLE() cv::broadcast(src, shape_dst, dst);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , BroadcastTest,
|
||||
testing::Combine(
|
||||
testing::Values(std::vector<int>{1, 100, 800},
|
||||
std::vector<int>{10, 1, 800},
|
||||
std::vector<int>{10, 100, 1}),
|
||||
testing::Values(CV_32FC1),
|
||||
testing::Values(std::vector<int>{10, 100, 800})
|
||||
)
|
||||
);
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, min)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::min(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, minScalarDouble)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::min(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, minScalarSameType)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::min(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, max)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::max(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, maxScalarDouble)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::max(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, maxScalarSameType)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::max(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, absdiff)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: absdiff can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::absdiff(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, absdiffScalarDouble)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: absdiff can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::absdiff(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, absdiffScalarSameType)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: absdiff can be without saturation on 32S
|
||||
a /= 2;
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::absdiff(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, add)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
declare.time(50);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: add can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::add(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, addScalarDouble)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: add can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::add(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, addScalarSameType)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: add can be without saturation on 32S
|
||||
a /= 2;
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::add(a, b, c, noArray(), type);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, subtract)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: subtract can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::subtract(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, subtractScalarDouble)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: subtract can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::subtract(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, subtractScalarSameType)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: subtract can be without saturation on 32S
|
||||
a /= 2;
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::subtract(a, b, c, noArray(), type);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, multiply)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a(sz, type), b(sz, type), c(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//According to docs, saturation is not applied when result is 32bit integer
|
||||
a /= (2 << 16);
|
||||
b /= (2 << 16);
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::multiply(a, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, multiplyScale)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a(sz, type), b(sz, type), c(sz, type);
|
||||
double scale = 0.5;
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(type) == CV_32S)
|
||||
{
|
||||
//According to docs, saturation is not applied when result is 32bit integer
|
||||
a /= (2 << 16);
|
||||
b /= (2 << 16);
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::multiply(a, b, c, scale);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, divide)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a(sz, type), b(sz, type), c(sz, type);
|
||||
double scale = 0.5;
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::divide(a, b, c, scale);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, reciprocal)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat b(sz, type), c(sz, type);
|
||||
double scale = 0.5;
|
||||
|
||||
declare.in(b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::divide(scale, b, c);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, transpose2d)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
Size tsz = Size(sz.height, sz.width);
|
||||
cv::Mat a(sz, type), b(tsz, type);;
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(b);
|
||||
|
||||
TEST_CYCLE() cv::transpose(a, b);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(BinaryOpTest, transposeND)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type).reshape(1);
|
||||
|
||||
std::vector<int> order(a.dims);
|
||||
std::iota(order.begin(), order.end(), 0);
|
||||
std::reverse(order.begin(), order.end());
|
||||
|
||||
std::vector<int> new_sz(a.dims);
|
||||
std::copy(a.size.p, a.size.p + a.dims, new_sz.begin());
|
||||
std::reverse(new_sz.begin(), new_sz.end());
|
||||
cv::Mat b = Mat(new_sz, type);
|
||||
|
||||
declare.in(a,WARMUP_RNG).out(b);
|
||||
|
||||
TEST_CYCLE() cv::transposeND(a, order, b);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , BinaryOpTest,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p),
|
||||
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1)
|
||||
)
|
||||
);
|
||||
|
||||
///////////// Mixed type arithmetics ////////
|
||||
|
||||
typedef perf::TestBaseWithParam<std::tuple<cv::Size, std::tuple<perf::MatType, perf::MatType>>> ArithmMixedTest;
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, add)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a = Mat(sz, srcType);
|
||||
cv::Mat b = Mat(sz, srcType);
|
||||
cv::Mat c = Mat(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
declare.time(50);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: add can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::add(a, b, c, /* mask */ noArray(), dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, addScalarDouble)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a = Mat(sz, srcType);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: add can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::add(a, b, c, /* mask */ noArray(), dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, addScalarSameType)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a = Mat(sz, srcType);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: add can be without saturation on 32S
|
||||
a /= 2;
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::add(a, b, c, /* mask */ noArray(), dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, subtract)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a = Mat(sz, srcType);
|
||||
cv::Mat b = Mat(sz, srcType);
|
||||
cv::Mat c = Mat(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: subtract can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::subtract(a, b, c, /* mask */ noArray(), dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, subtractScalarDouble)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a = Mat(sz, srcType);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: subtract can be without saturation on 32S
|
||||
a /= 2;
|
||||
b /= 2;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::subtract(a, b, c, /* mask */ noArray(), dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, subtractScalarSameType)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a = Mat(sz, srcType);
|
||||
cv::Scalar b;
|
||||
cv::Mat c = Mat(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) < CV_32S)
|
||||
{
|
||||
b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing
|
||||
}
|
||||
else if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//see ticket 1529: subtract can be without saturation on 32S
|
||||
a /= 2;
|
||||
b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::subtract(a, b, c, /* mask */ noArray(), dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, multiply)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a(sz, srcType), b(sz, srcType), c(sz, dstType);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//According to docs, saturation is not applied when result is 32bit integer
|
||||
a /= (2 << 16);
|
||||
b /= (2 << 16);
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::multiply(a, b, c, /* scale */ 1.0, dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, multiplyScale)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a(sz, srcType), b(sz, srcType), c(sz, dstType);
|
||||
double scale = 0.5;
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
if (CV_MAT_DEPTH(dstType) == CV_32S)
|
||||
{
|
||||
//According to docs, saturation is not applied when result is 32bit integer
|
||||
a /= (2 << 16);
|
||||
b /= (2 << 16);
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::multiply(a, b, c, scale, dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, divide)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat a(sz, srcType), b(sz, srcType), c(sz, dstType);
|
||||
double scale = 0.5;
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::divide(a, b, c, scale, dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(ArithmMixedTest, reciprocal)
|
||||
{
|
||||
auto p = GetParam();
|
||||
Size sz = get<0>(p);
|
||||
int srcType = get<0>(get<1>(p));
|
||||
int dstType = get<1>(get<1>(p));
|
||||
|
||||
cv::Mat b(sz, srcType), c(sz, dstType);
|
||||
double scale = 0.5;
|
||||
|
||||
declare.in(b, WARMUP_RNG).out(c);
|
||||
|
||||
TEST_CYCLE() cv::divide(scale, b, c, dstType);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , ArithmMixedTest,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p),
|
||||
testing::Values(std::tuple<perf::MatType, perf::MatType>{CV_8U, CV_16U},
|
||||
std::tuple<perf::MatType, perf::MatType>{CV_8S, CV_16S},
|
||||
std::tuple<perf::MatType, perf::MatType>{CV_8U, CV_32F},
|
||||
std::tuple<perf::MatType, perf::MatType>{CV_8S, CV_32F}
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
typedef perf::TestBaseWithParam<std::tuple<cv::Size, int, bool>> SqrtFixture;
|
||||
PERF_TEST_P_(SqrtFixture, Sqrt) {
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
bool inverse = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, type), dst(sz, type);
|
||||
randu(src, FLT_EPSILON, 1000);
|
||||
declare.in(src).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::pow(src, inverse ? -0.5 : 0.5, dst);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , SqrtFixture,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_32FC1, CV_64FC1),
|
||||
testing::Bool()
|
||||
)
|
||||
);
|
||||
|
||||
///////////// Rotate ////////////////////////
|
||||
|
||||
typedef perf::TestBaseWithParam<std::tuple<cv::Size, int, perf::MatType>> RotateTest;
|
||||
|
||||
PERF_TEST_P_(RotateTest, rotate)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int rotatecode = get<1>(GetParam());
|
||||
int type = get<2>(GetParam());
|
||||
cv::Mat a(sz, type), b(sz, type);
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(b);
|
||||
|
||||
TEST_CYCLE() cv::rotate(a, b, rotatecode);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , RotateTest,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p),
|
||||
testing::Values(ROTATE_180, ROTATE_90_CLOCKWISE, ROTATE_90_COUNTERCLOCKWISE),
|
||||
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
///////////// PatchNaNs ////////////////////////
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp randomNan(RNG& rng);
|
||||
|
||||
template<>
|
||||
float randomNan(RNG& rng)
|
||||
{
|
||||
uint32_t r = rng.next();
|
||||
Cv32suf v;
|
||||
v.u = r;
|
||||
// exp & set a bit to avoid zero mantissa
|
||||
v.u = v.u | 0x7f800001;
|
||||
return v.f;
|
||||
}
|
||||
|
||||
template<>
|
||||
double randomNan(RNG& rng)
|
||||
{
|
||||
uint32_t r0 = rng.next();
|
||||
uint32_t r1 = rng.next();
|
||||
Cv64suf v;
|
||||
v.u = (uint64_t(r0) << 32) | uint64_t(r1);
|
||||
// exp &set a bit to avoid zero mantissa
|
||||
v.u = v.u | 0x7ff0000000000001;
|
||||
return v.f;
|
||||
}
|
||||
|
||||
typedef Size_MatType PatchNaNsFixture;
|
||||
|
||||
PERF_TEST_P_(PatchNaNsFixture, PatchNaNs)
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type);
|
||||
|
||||
Mat src(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(src);
|
||||
|
||||
// generating NaNs
|
||||
{
|
||||
srcSize.width *= cn;
|
||||
RNG& rng = theRNG();
|
||||
for (int y = 0; y < srcSize.height; ++y)
|
||||
{
|
||||
float *const ptrf = src.ptr<float>(y);
|
||||
double *const ptrd = src.ptr<double>(y);
|
||||
for (int x = 0; x < srcSize.width; ++x)
|
||||
{
|
||||
if (depth == CV_32F)
|
||||
{
|
||||
ptrf[x] = (x + y) % 2 == 0 ? randomNan<float >(rng) : ptrf[x];
|
||||
}
|
||||
else if (depth == CV_64F)
|
||||
{
|
||||
ptrd[x] = (x + y) % 2 == 0 ? randomNan<double>(rng) : ptrd[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::patchNaNs(src, 17.7);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , PatchNaNsFixture,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p, sz2160p),
|
||||
testing::Values(CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4, CV_64FC1, CV_64FC2, CV_64FC3, CV_64FC4)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
////////////// finiteMask ////////////////////////
|
||||
|
||||
typedef Size_MatType FiniteMaskFixture;
|
||||
|
||||
PERF_TEST_P_(FiniteMaskFixture, FiniteMask)
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type);
|
||||
|
||||
Mat src(srcSize, type);
|
||||
Mat mask(srcSize, CV_8UC1);
|
||||
declare.in(src, WARMUP_RNG).out(mask);
|
||||
|
||||
// generating NaNs
|
||||
{
|
||||
srcSize.width *= cn;
|
||||
const softfloat fpinf = softfloat ::inf();
|
||||
const softfloat fninf = softfloat ::inf().setSign(true);
|
||||
const softdouble dpinf = softdouble::inf();
|
||||
const softdouble dninf = softdouble::inf().setSign(true);
|
||||
RNG& rng = theRNG();
|
||||
for (int y = 0; y < srcSize.height; ++y)
|
||||
{
|
||||
float *const ptrf = src.ptr<float>(y);
|
||||
double *const ptrd = src.ptr<double>(y);
|
||||
for (int x = 0; x < srcSize.width; ++x)
|
||||
{
|
||||
int rem = (x + y) % 10;
|
||||
if (depth == CV_32F)
|
||||
{
|
||||
ptrf[x] = rem < 4 ? randomNan<float >(rng) :
|
||||
rem == 5 ? (float )((x + y)%2 ? fpinf : fninf) : ptrf[x];
|
||||
}
|
||||
else if (depth == CV_64F)
|
||||
{
|
||||
ptrd[x] = rem < 4 ? randomNan<double>(rng) :
|
||||
rem == 5 ? (double)((x + y)%2 ? dpinf : dninf) : ptrd[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::finiteMask(src, mask);
|
||||
|
||||
SANITY_CHECK(mask);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , FiniteMaskFixture,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p, sz2160p),
|
||||
testing::Values(CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4, CV_64FC1, CV_64FC2, CV_64FC3, CV_64FC4)
|
||||
)
|
||||
);
|
||||
|
||||
//////////////EXP////////////
|
||||
|
||||
typedef Size_MatType ExpFixture;
|
||||
|
||||
PERF_TEST_P(ExpFixture, Exp,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_32F, CV_64F)))
|
||||
{
|
||||
cv::Size size = std::get<0>(GetParam());
|
||||
int type = std::get<1>(GetParam());
|
||||
|
||||
cv::Mat src(size, type);
|
||||
cv::Mat dst(size, type);
|
||||
|
||||
declare.in(src).out(dst);
|
||||
|
||||
cv::randu(src, -5.0, 5.0);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::exp(src, dst);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//////////////LOG////////////
|
||||
|
||||
typedef Size_MatType LogFixture;
|
||||
|
||||
PERF_TEST_P(LogFixture, Log,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_32F, CV_64F)))
|
||||
{
|
||||
cv::Size size = std::get<0>(GetParam());
|
||||
int type = std::get<1>(GetParam());
|
||||
|
||||
cv::Mat src(size, type);
|
||||
cv::Mat dst(size, type);
|
||||
|
||||
declare.in(src).out(dst);
|
||||
|
||||
cv::randu(src, 1e-5, 1e5);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::log(src, dst);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,75 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define TYPICAL_MAT_SIZES_BITW_ARITHM TYPICAL_MAT_SIZES
|
||||
#define TYPICAL_MAT_TYPES_BITW_ARITHM CV_8UC1, CV_8SC1, CV_8UC4, CV_32SC1, CV_32SC4
|
||||
#define TYPICAL_MATS_BITW_ARITHM testing::Combine(testing::Values(TYPICAL_MAT_SIZES_BITW_ARITHM), testing::Values(TYPICAL_MAT_TYPES_BITW_ARITHM))
|
||||
|
||||
PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(c);
|
||||
declare.iterations(200);
|
||||
|
||||
TEST_CYCLE() cv::bitwise_not(a, c);
|
||||
|
||||
SANITY_CHECK(c);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, bitwise_and, TYPICAL_MATS_BITW_ARITHM)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE() bitwise_and(a, b, c);
|
||||
|
||||
SANITY_CHECK(c);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, bitwise_or, TYPICAL_MATS_BITW_ARITHM)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE() bitwise_or(a, b, c);
|
||||
|
||||
SANITY_CHECK(c);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, bitwise_xor, TYPICAL_MATS_BITW_ARITHM)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
cv::Mat a = Mat(sz, type);
|
||||
cv::Mat b = Mat(sz, type);
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG).out(c);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE() bitwise_xor(a, b, c);
|
||||
|
||||
SANITY_CHECK(c);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,59 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
CV_ENUM(CmpType, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
|
||||
|
||||
typedef tuple<Size, MatType, CmpType> Size_MatType_CmpType_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_CmpType_t> Size_MatType_CmpType;
|
||||
|
||||
PERF_TEST_P( Size_MatType_CmpType, compare,
|
||||
testing::Combine(
|
||||
testing::Values(::perf::szVGA, ::perf::sz1080p),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1),
|
||||
CmpType::all()
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType1 = get<1>(GetParam());
|
||||
CmpType cmpType = get<2>(GetParam());
|
||||
|
||||
Mat src1(sz, matType1);
|
||||
Mat src2(sz, matType1);
|
||||
Mat dst(sz, CV_8UC(CV_MAT_CN(matType1)));
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::compare(src1, src2, dst, cmpType);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
PERF_TEST_P( Size_MatType_CmpType, compareScalar,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
CmpType::all()
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
CmpType cmpType = get<2>(GetParam());
|
||||
|
||||
Mat src1(sz, matType);
|
||||
Scalar src2;
|
||||
Mat dst(sz, CV_8UC(CV_MAT_CN(matType)));
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
||||
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) cv::compare(src1, src2, dst, cmpType);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<Size, MatType, MatType, int, double> Size_DepthSrc_DepthDst_Channels_alpha_t;
|
||||
typedef perf::TestBaseWithParam<Size_DepthSrc_DepthDst_Channels_alpha_t> Size_DepthSrc_DepthDst_Channels_alpha;
|
||||
|
||||
PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,
|
||||
testing::Combine
|
||||
(
|
||||
testing::Values(szVGA, sz1080p),
|
||||
testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
||||
testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
|
||||
testing::Values(1, 4),
|
||||
testing::Values(1.0, 1./255)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int depthSrc = get<1>(GetParam());
|
||||
int depthDst = get<2>(GetParam());
|
||||
int channels = get<3>(GetParam());
|
||||
double alpha = get<4>(GetParam());
|
||||
|
||||
int maxValue = 255;
|
||||
|
||||
Mat src(sz, CV_MAKETYPE(depthSrc, channels));
|
||||
randu(src, 0, maxValue);
|
||||
Mat dst(sz, CV_MAKETYPE(depthDst, channels));
|
||||
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha);
|
||||
|
||||
double eps = depthSrc <= CV_32S && (depthDst <= CV_32S || depthDst == CV_64F) ? 1e-12 : (FLT_EPSILON * maxValue);
|
||||
eps = eps * std::max(1.0, fabs(alpha));
|
||||
SANITY_CHECK(dst, eps);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define DECL_ROUND_TEST(NAME, OP, EXTRA) \
|
||||
template <typename T> \
|
||||
static void OP ## Mat(const cv::Mat & src, cv::Mat & dst) \
|
||||
{ \
|
||||
for (int y = 0; y < dst.rows; ++y) \
|
||||
{ \
|
||||
const T * sptr = src.ptr<T>(y); \
|
||||
int * dptr = dst.ptr<int>(y); \
|
||||
\
|
||||
for (int x = 0; x < dst.cols; ++x) \
|
||||
dptr[x] = OP(sptr[x]) EXTRA; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
PERF_TEST_P(Size_MatType, CvRound_Float ## NAME, \
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES), \
|
||||
testing::Values(CV_32FC1, CV_64FC1))) \
|
||||
{ \
|
||||
Size size = get<0>(GetParam()); \
|
||||
int type = get<1>(GetParam()), depth = CV_MAT_DEPTH(type); \
|
||||
\
|
||||
cv::Mat src(size, type), dst(size, CV_32SC1); \
|
||||
\
|
||||
declare.in(src, WARMUP_RNG).out(dst); \
|
||||
\
|
||||
if (depth == CV_32F) \
|
||||
{ \
|
||||
TEST_CYCLE() \
|
||||
OP ## Mat<float>(src, dst); \
|
||||
} \
|
||||
else if (depth == CV_64F) \
|
||||
{ \
|
||||
TEST_CYCLE() \
|
||||
OP ## Mat<double>(src, dst); \
|
||||
} \
|
||||
\
|
||||
SANITY_CHECK_NOTHING(); \
|
||||
}
|
||||
|
||||
DECL_ROUND_TEST(,cvRound,)
|
||||
DECL_ROUND_TEST(_Ceil,cvCeil,)
|
||||
DECL_ROUND_TEST(_Floor,cvFloor,)
|
||||
|
||||
/* For FP classification tests, try to test them in way which uses
|
||||
branching logic and avoids extra FP logic. */
|
||||
DECL_ROUND_TEST(_NaN,cvIsNaN, ? 1 : 2)
|
||||
DECL_ROUND_TEST(_Inf,cvIsInf, ? 1 : 2)
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
///////////////////////////////////////////////////////dft//////////////////////////////////////////////////////////////
|
||||
|
||||
#define MAT_TYPES_DFT CV_32FC1, CV_32FC2, CV_64FC1
|
||||
#define MAT_SIZES_DFT cv::Size(320, 480), cv::Size(800, 600), cv::Size(1280, 1024), sz1080p, sz2K
|
||||
CV_ENUM(FlagsType, 0, DFT_INVERSE, DFT_SCALE, DFT_COMPLEX_OUTPUT, DFT_ROWS, DFT_INVERSE|DFT_COMPLEX_OUTPUT)
|
||||
#define TEST_MATS_DFT testing::Combine(testing::Values(MAT_SIZES_DFT), testing::Values(MAT_TYPES_DFT), FlagsType::all(), testing::Values(true, false))
|
||||
|
||||
typedef tuple<Size, MatType, FlagsType, bool> Size_MatType_FlagsType_NzeroRows_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_FlagsType_NzeroRows_t> Size_MatType_FlagsType_NzeroRows;
|
||||
|
||||
PERF_TEST_P(Size_MatType_FlagsType_NzeroRows, dft, TEST_MATS_DFT)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
int flags = get<2>(GetParam());
|
||||
bool isNzeroRows = get<3>(GetParam());
|
||||
|
||||
int nonzero_rows = 0;
|
||||
|
||||
Mat src(sz, type);
|
||||
Mat dst(sz, type);
|
||||
|
||||
declare.in(src, WARMUP_RNG).time(60);
|
||||
|
||||
if (isNzeroRows)
|
||||
nonzero_rows = sz.height/2;
|
||||
|
||||
TEST_CYCLE() dft(src, dst, flags, nonzero_rows);
|
||||
|
||||
SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////dct//////////////////////////////////////////////////////
|
||||
|
||||
CV_ENUM(DCT_FlagsType, 0, DCT_INVERSE , DCT_ROWS, DCT_INVERSE|DCT_ROWS)
|
||||
|
||||
typedef tuple<Size, MatType, DCT_FlagsType> Size_MatType_Flag_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_Flag_t> Size_MatType_Flag;
|
||||
|
||||
PERF_TEST_P(Size_MatType_Flag, dct, testing::Combine(
|
||||
testing::Values(cv::Size(320, 240),cv::Size(800, 600),
|
||||
cv::Size(1024, 768), cv::Size(1280, 1024),
|
||||
sz1080p, sz2K),
|
||||
testing::Values(CV_32FC1, CV_64FC1), DCT_FlagsType::all()))
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
int flags = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, type);
|
||||
Mat dst(sz, type);
|
||||
|
||||
declare
|
||||
.in(src, WARMUP_RNG)
|
||||
.out(dst)
|
||||
.time(60);
|
||||
|
||||
TEST_CYCLE() dct(src, dst, flags);
|
||||
|
||||
SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<MatType, int> MatType_Length_t;
|
||||
typedef TestBaseWithParam<MatType_Length_t> MatType_Length;
|
||||
|
||||
PERF_TEST_P( MatType_Length, dot,
|
||||
testing::Combine(
|
||||
testing::Values( CV_8UC1, CV_8SC1, CV_16SC1, CV_16UC1, CV_32SC1, CV_32FC1 ),
|
||||
testing::Values( 32, 64, 128, 256, 512, 1024 )
|
||||
))
|
||||
{
|
||||
int type = get<0>(GetParam());
|
||||
int size = get<1>(GetParam());
|
||||
Mat a(size, size, type);
|
||||
Mat b(size, size, type);
|
||||
|
||||
declare.in(a, b, WARMUP_RNG);
|
||||
declare.time(100);
|
||||
|
||||
double product;
|
||||
|
||||
TEST_CYCLE_N(1000) product = a.dot(b);
|
||||
|
||||
SANITY_CHECK(product, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,45 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
using namespace perf;
|
||||
|
||||
enum
|
||||
{
|
||||
FLIP_XY = 0,
|
||||
FLIP_X = 1,
|
||||
FLIP_Y = 2,
|
||||
};
|
||||
|
||||
#define FLIP_SIZES szQVGA, szVGA, sz1080p
|
||||
#define FLIP_TYPES CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_32SC1, CV_32FC1
|
||||
#define FLIP_CODES FLIP_X, FLIP_Y, FLIP_XY
|
||||
|
||||
CV_FLAGS(FlipCode, FLIP_X, FLIP_Y, FLIP_XY);
|
||||
typedef tuple<Size, MatType, FlipCode> Size_MatType_FlipCode_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_FlipCode_t> Size_MatType_FlipCode;
|
||||
|
||||
PERF_TEST_P(Size_MatType_FlipCode,
|
||||
flip,
|
||||
testing::Combine(testing::Values(FLIP_SIZES),
|
||||
testing::Values(FLIP_TYPES),
|
||||
testing::Values(FLIP_CODES)))
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int flipCode = get<2>(GetParam()) - 1;
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat dst(sz, matType);
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::flip(src, dst, flipCode);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}} // namespace opencv_test
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define TYPICAL_MAT_TYPES_INRANGE CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_32FC4
|
||||
#define TYPICAL_MATS_INRANGE testing::Combine(testing::Values(szVGA, sz720p, sz1080p), testing::Values(TYPICAL_MAT_TYPES_INRANGE))
|
||||
|
||||
PERF_TEST_P(Size_MatType, inRange, TYPICAL_MATS_INRANGE)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
Mat src1(size, type);
|
||||
Mat src2(size, type);
|
||||
Mat src3(size, type);
|
||||
Mat dst(size, type);
|
||||
|
||||
declare.in(src1, src2, src3, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() inRange( src1, src2, src3, dst );
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,86 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<cv::Size, MatType, String> Size_MatType_Str_t;
|
||||
typedef TestBaseWithParam<Size_MatType_Str_t> Size_Mat_StrType;
|
||||
|
||||
#define MAT_SIZES ::perf::sz1080p/*, ::perf::sz4320p*/
|
||||
#define MAT_TYPES CV_8UC1, CV_32FC1
|
||||
#define FILE_EXTENSION String(".xml"), String(".yml"), String(".json")
|
||||
|
||||
|
||||
PERF_TEST_P(Size_Mat_StrType, DISABLED_fs_text,
|
||||
testing::Combine(testing::Values(MAT_SIZES),
|
||||
testing::Values(MAT_TYPES),
|
||||
testing::Values(FILE_EXTENSION))
|
||||
)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
String ext = get<2>(GetParam());
|
||||
|
||||
Mat src(size.height, size.width, type);
|
||||
Mat dst = src.clone();
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
cv::String file_name = cv::tempfile(ext.c_str());
|
||||
cv::String key = "test_mat";
|
||||
|
||||
TEST_CYCLE_MULTIRUN(2)
|
||||
{
|
||||
{
|
||||
FileStorage fs(file_name, cv::FileStorage::WRITE);
|
||||
fs << key << src;
|
||||
fs.release();
|
||||
}
|
||||
{
|
||||
FileStorage fs(file_name, cv::FileStorage::READ);
|
||||
fs[key] >> dst;
|
||||
fs.release();
|
||||
}
|
||||
}
|
||||
|
||||
remove(file_name.c_str());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_Mat_StrType, DISABLED_fs_base64,
|
||||
testing::Combine(testing::Values(MAT_SIZES),
|
||||
testing::Values(MAT_TYPES),
|
||||
testing::Values(FILE_EXTENSION))
|
||||
)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
String ext = get<2>(GetParam());
|
||||
|
||||
Mat src(size.height, size.width, type);
|
||||
Mat dst = src.clone();
|
||||
|
||||
cv::String file_name = cv::tempfile(ext.c_str());
|
||||
cv::String key = "test_mat";
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
TEST_CYCLE_MULTIRUN(2)
|
||||
{
|
||||
{
|
||||
FileStorage fs(file_name, cv::FileStorage::WRITE_BASE64);
|
||||
fs << key << src;
|
||||
fs.release();
|
||||
}
|
||||
{
|
||||
FileStorage fs(file_name, cv::FileStorage::READ);
|
||||
fs[key] >> dst;
|
||||
fs.release();
|
||||
}
|
||||
}
|
||||
|
||||
remove(file_name.c_str());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
using namespace perf;
|
||||
|
||||
typedef perf::TestBaseWithParam<Size> SizePrm;
|
||||
|
||||
PERF_TEST_P( SizePrm, LUT,
|
||||
testing::Values(szQVGA, szVGA, sz1080p)
|
||||
)
|
||||
{
|
||||
Size sz = GetParam();
|
||||
|
||||
int maxValue = 255;
|
||||
|
||||
Mat src(sz, CV_8UC1);
|
||||
randu(src, 0, maxValue);
|
||||
Mat lut(1, 256, CV_8UC1);
|
||||
randu(lut, 0, maxValue);
|
||||
Mat dst(sz, CV_8UC1);
|
||||
|
||||
TEST_CYCLE() LUT(src, lut, dst);
|
||||
|
||||
SANITY_CHECK(dst, 0.1);
|
||||
}
|
||||
|
||||
PERF_TEST_P( SizePrm, LUT_multi,
|
||||
testing::Values(szQVGA, szVGA, sz1080p)
|
||||
)
|
||||
{
|
||||
Size sz = GetParam();
|
||||
|
||||
int maxValue = 255;
|
||||
|
||||
Mat src(sz, CV_8UC3);
|
||||
randu(src, 0, maxValue);
|
||||
Mat lut(1, 256, CV_8UC1);
|
||||
randu(lut, 0, maxValue);
|
||||
Mat dst(sz, CV_8UC3);
|
||||
|
||||
TEST_CYCLE() LUT(src, lut, dst);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#ifdef _MSC_VER
|
||||
# if _MSC_VER >= 1700
|
||||
# pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_HPX)
|
||||
#include <hpx/hpx_main.hpp>
|
||||
#endif
|
||||
|
||||
CV_PERF_TEST_MAIN(core)
|
||||
@@ -0,0 +1,195 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_Eye,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES))
|
||||
|
||||
)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
Mat diagonalMatrix(size.height, size.width, type);
|
||||
|
||||
declare.out(diagonalMatrix);
|
||||
|
||||
int runs = (size.width <= 640) ? 15 : 5;
|
||||
TEST_CYCLE_MULTIRUN(runs)
|
||||
{
|
||||
diagonalMatrix = Mat::eye(size, type);
|
||||
}
|
||||
|
||||
SANITY_CHECK(diagonalMatrix, 1);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_Zeros,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES, CV_32FC3))
|
||||
|
||||
)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
Mat zeroMatrix(size.height, size.width, type);
|
||||
|
||||
declare.out(zeroMatrix);
|
||||
|
||||
int runs = (size.width <= 640) ? 15 : 5;
|
||||
TEST_CYCLE_MULTIRUN(runs)
|
||||
{
|
||||
zeroMatrix = Mat::zeros(size, type);
|
||||
}
|
||||
|
||||
SANITY_CHECK(zeroMatrix, 1);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_Clone,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES))
|
||||
|
||||
)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
Mat source(size.height, size.width, type);
|
||||
Mat destination(size.height, size.width, type);
|
||||
|
||||
declare.in(source, WARMUP_RNG).out(destination);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
Mat tmp = source.clone();
|
||||
CV_UNUSED(tmp);
|
||||
}
|
||||
destination = source.clone();
|
||||
|
||||
SANITY_CHECK(destination, 1);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_Clone_Roi,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES))
|
||||
|
||||
)
|
||||
{
|
||||
Size size = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
|
||||
unsigned int width = size.width;
|
||||
unsigned int height = size.height;
|
||||
Mat source(height, width, type);
|
||||
Mat destination(size.height/2, size.width/2, type);
|
||||
|
||||
declare.in(source, WARMUP_RNG).out(destination);
|
||||
|
||||
Mat roi(source, Rect(width/4, height/4, 3*width/4, 3*height/4));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
Mat tmp = roi.clone();
|
||||
CV_UNUSED(tmp);
|
||||
}
|
||||
destination = roi.clone();
|
||||
|
||||
SANITY_CHECK(destination, 1);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_CopyToWithMask,
|
||||
testing::Combine(testing::Values(::perf::sz1080p, ::perf::szODD),
|
||||
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_16UC1, CV_16UC3, CV_32SC1, CV_32SC2, CV_32FC4))
|
||||
)
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size size = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
Mat src(size, type), dst(size, type), mask(size, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.copyTo(dst, mask);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_SetToWithMask,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC2))
|
||||
)
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size size = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
const Scalar sc = Scalar::all(27);
|
||||
|
||||
Mat src(size, type), mask(size, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG).out(src);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
src.setTo(sc, mask);
|
||||
}
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
|
||||
///////////// Transform ////////////////////////
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_Transform,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC3, CV_8SC3, CV_16UC3, CV_16SC3, CV_32SC3, CV_32FC3, CV_64FC3))
|
||||
)
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize0 = get<0>(params);
|
||||
const Size srcSize = Size(1, srcSize0.width*srcSize0.height);
|
||||
const int type = get<1>(params);
|
||||
const float transform[] = { 0.5f, 0.f, 0.86602540378f, 128,
|
||||
0.f, 1.f, 0.f, -64,
|
||||
0.86602540378f, 0.f, 0.5f, 32,};
|
||||
Mat mtx(Size(4, 3), CV_32FC1, (void*)transform);
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
randu(src, 0, 30);
|
||||
declare.in(src).out(dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::transform(src, dst, mtx);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, Mat_Transform_Diagonal,
|
||||
testing::Combine(testing::Values(szVGA, sz720p, sz1080p),
|
||||
testing::Values(CV_8UC3, CV_8SC3, CV_16UC3, CV_16SC3, CV_32SC3, CV_32FC3, CV_64FC3))
|
||||
)
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize0 = get<0>(params);
|
||||
const Size srcSize = Size(1, srcSize0.width*srcSize0.height);
|
||||
const int type = get<1>(params);
|
||||
const float transform[] = { 0.5f, 0.f, 0.f, 128,
|
||||
0.f, 0.86602540378f, 0.f, -64,
|
||||
0.f, 0.f, 0.4330127019f, 32, };
|
||||
Mat mtx(Size(4, 3), CV_32FC1, (void*)transform);
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
randu(src, 0, 30);
|
||||
declare.in(src).out(dst);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::transform(src, dst, mtx);
|
||||
}
|
||||
|
||||
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,455 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
namespace {
|
||||
|
||||
typedef perf::TestBaseWithParam<size_t> VectorLength;
|
||||
|
||||
PERF_TEST_P(VectorLength, phase32f, testing::Values(128, 1000, 128*1024, 512*1024, 1024*1024))
|
||||
{
|
||||
size_t length = GetParam();
|
||||
vector<float> X(length);
|
||||
vector<float> Y(length);
|
||||
vector<float> angle(length);
|
||||
|
||||
declare.in(X, Y, WARMUP_RNG).out(angle);
|
||||
|
||||
TEST_CYCLE_N(200) cv::phase(X, Y, angle, true);
|
||||
|
||||
SANITY_CHECK(angle, 5e-5);
|
||||
}
|
||||
|
||||
PERF_TEST_P(VectorLength, phase64f, testing::Values(128, 1000, 128*1024, 512*1024, 1024*1024))
|
||||
{
|
||||
size_t length = GetParam();
|
||||
vector<double> X(length);
|
||||
vector<double> Y(length);
|
||||
vector<double> angle(length);
|
||||
|
||||
declare.in(X, Y, WARMUP_RNG).out(angle);
|
||||
|
||||
TEST_CYCLE_N(200) cv::phase(X, Y, angle, true);
|
||||
|
||||
SANITY_CHECK(angle, 5e-5);
|
||||
}
|
||||
|
||||
///////////// Magnitude /////////////
|
||||
|
||||
typedef Size_MatType MagnitudeFixture;
|
||||
|
||||
PERF_TEST_P(MagnitudeFixture, Magnitude,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_32F, CV_64F)))
|
||||
{
|
||||
cv::Size size = std::get<0>(GetParam());
|
||||
int type = std::get<1>(GetParam());
|
||||
|
||||
cv::Mat x(size, type);
|
||||
cv::Mat y(size, type);
|
||||
cv::Mat magnitude(size, type);
|
||||
|
||||
declare.in(x, y, WARMUP_RNG).out(magnitude);
|
||||
|
||||
TEST_CYCLE() cv::magnitude(x, y, magnitude);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
///////////// Cart to Polar /////////////
|
||||
|
||||
typedef Size_MatType CartToPolarFixture;
|
||||
|
||||
PERF_TEST_P(CartToPolarFixture, CartToPolar,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_32F, CV_64F)))
|
||||
{
|
||||
cv::Size size = std::get<0>(GetParam());
|
||||
int type = std::get<1>(GetParam());
|
||||
|
||||
cv::Mat x(size, type);
|
||||
cv::Mat y(size, type);
|
||||
cv::Mat magnitude(size, type);
|
||||
cv::Mat angle(size, type);
|
||||
|
||||
declare.in(x, y, WARMUP_RNG).out(magnitude, angle);
|
||||
|
||||
TEST_CYCLE() cv::cartToPolar(x, y, magnitude, angle);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
///////////// Polar to Cart /////////////
|
||||
|
||||
typedef Size_MatType PolarToCartFixture;
|
||||
|
||||
PERF_TEST_P(PolarToCartFixture, PolarToCart,
|
||||
testing::Combine(testing::Values(TYPICAL_MAT_SIZES), testing::Values(CV_32F, CV_64F)))
|
||||
{
|
||||
cv::Size size = std::get<0>(GetParam());
|
||||
int type = std::get<1>(GetParam());
|
||||
|
||||
cv::Mat magnitude(size, type);
|
||||
cv::Mat angle(size, type);
|
||||
cv::Mat x(size, type);
|
||||
cv::Mat y(size, type);
|
||||
|
||||
declare.in(magnitude, angle, WARMUP_RNG).out(x, y);
|
||||
|
||||
TEST_CYCLE() cv::polarToCart(magnitude, angle, x, y);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
// generates random vectors, performs Gram-Schmidt orthogonalization on them
|
||||
Mat randomOrtho(int rows, int ftype, RNG& rng)
|
||||
{
|
||||
Mat result(rows, rows, ftype);
|
||||
rng.fill(result, RNG::UNIFORM, cv::Scalar(-1), cv::Scalar(1));
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
Mat v = result.row(i);
|
||||
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
Mat p = result.row(j);
|
||||
v -= p.dot(v) * p;
|
||||
}
|
||||
|
||||
v = v * (1. / cv::norm(v));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename FType>
|
||||
Mat buildRandomMat(int rows, int cols, RNG& rng, int rank, bool symmetrical)
|
||||
{
|
||||
int mtype = cv::traits::Depth<FType>::value;
|
||||
Mat u = randomOrtho(rows, mtype, rng);
|
||||
Mat v = randomOrtho(cols, mtype, rng);
|
||||
Mat s(rows, cols, mtype, Scalar(0));
|
||||
|
||||
std::vector<FType> singVals(rank);
|
||||
rng.fill(singVals, RNG::UNIFORM, Scalar(0), Scalar(10));
|
||||
std::sort(singVals.begin(), singVals.end());
|
||||
auto singIter = singVals.rbegin();
|
||||
for (int i = 0; i < rank; i++)
|
||||
{
|
||||
s.at<FType>(i, i) = *singIter++;
|
||||
}
|
||||
|
||||
if (symmetrical)
|
||||
return u * s * u.t();
|
||||
else
|
||||
return u * s * v.t();
|
||||
}
|
||||
|
||||
Mat buildRandomMat(int rows, int cols, int mtype, RNG& rng, int rank, bool symmetrical)
|
||||
{
|
||||
if (mtype == CV_32F)
|
||||
{
|
||||
return buildRandomMat<float>(rows, cols, rng, rank, symmetrical);
|
||||
}
|
||||
else if (mtype == CV_64F)
|
||||
{
|
||||
return buildRandomMat<double>(rows, cols, rng, rank, symmetrical);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Error(cv::Error::StsBadArg, "This type is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
CV_ENUM(SolveDecompEnum, DECOMP_LU, DECOMP_SVD, DECOMP_EIG, DECOMP_CHOLESKY, DECOMP_QR)
|
||||
|
||||
enum RankMatrixOptions
|
||||
{
|
||||
RANK_HALF, RANK_MINUS_1, RANK_FULL
|
||||
};
|
||||
|
||||
CV_ENUM(RankEnum, RANK_HALF, RANK_MINUS_1, RANK_FULL)
|
||||
|
||||
enum SolutionsOptions
|
||||
{
|
||||
NO_SOLUTIONS, ONE_SOLUTION, MANY_SOLUTIONS
|
||||
};
|
||||
|
||||
CV_ENUM(SolutionsEnum, NO_SOLUTIONS, ONE_SOLUTION, MANY_SOLUTIONS)
|
||||
|
||||
typedef perf::TestBaseWithParam<std::tuple<int, RankEnum, MatDepth, SolveDecompEnum, bool, SolutionsEnum>> SolveTest;
|
||||
|
||||
PERF_TEST_P(SolveTest, randomMat, ::testing::Combine(
|
||||
::testing::Values(31, 64, 100),
|
||||
::testing::Values(RANK_HALF, RANK_MINUS_1, RANK_FULL),
|
||||
::testing::Values(CV_32F, CV_64F),
|
||||
::testing::Values(DECOMP_LU, DECOMP_SVD, DECOMP_EIG, DECOMP_CHOLESKY, DECOMP_QR),
|
||||
::testing::Bool(), // normal
|
||||
::testing::Values(NO_SOLUTIONS, ONE_SOLUTION, MANY_SOLUTIONS)
|
||||
))
|
||||
{
|
||||
auto t = GetParam();
|
||||
int size = std::get<0>(t);
|
||||
auto rankEnum = std::get<1>(t);
|
||||
int mtype = std::get<2>(t);
|
||||
int method = std::get<3>(t);
|
||||
bool normal = std::get<4>(t);
|
||||
auto solutions = std::get<5>(t);
|
||||
|
||||
bool symmetrical = (method == DECOMP_CHOLESKY || method == DECOMP_LU);
|
||||
|
||||
if (normal)
|
||||
{
|
||||
method |= DECOMP_NORMAL;
|
||||
}
|
||||
|
||||
int rank = size;
|
||||
switch (rankEnum)
|
||||
{
|
||||
case RANK_HALF: rank /= 2; break;
|
||||
case RANK_MINUS_1: rank -= 1; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
RNG& rng = theRNG();
|
||||
Mat A = buildRandomMat(size, size, mtype, rng, rank, symmetrical);
|
||||
Mat x(size, 1, mtype);
|
||||
Mat b(size, 1, mtype);
|
||||
|
||||
switch (solutions)
|
||||
{
|
||||
// no solutions, let's make b random
|
||||
case NO_SOLUTIONS:
|
||||
{
|
||||
rng.fill(b, RNG::UNIFORM, Scalar(-1), Scalar(1));
|
||||
}
|
||||
break;
|
||||
// exactly 1 solution, let's combine b from A and x
|
||||
case ONE_SOLUTION:
|
||||
{
|
||||
rng.fill(x, RNG::UNIFORM, Scalar(-10), Scalar(10));
|
||||
b = A * x;
|
||||
}
|
||||
break;
|
||||
// infinitely many solutions, let's make b zero
|
||||
default:
|
||||
{
|
||||
b = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
TEST_CYCLE() cv::solve(A, b, x, method);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef perf::TestBaseWithParam<std::tuple<std::tuple<int, int>, RankEnum, MatDepth, bool, bool>> SvdTest;
|
||||
|
||||
PERF_TEST_P(SvdTest, decompose, ::testing::Combine(
|
||||
::testing::Values(std::make_tuple(5, 15), std::make_tuple(32, 32), std::make_tuple(100, 100)),
|
||||
::testing::Values(RANK_HALF, RANK_MINUS_1, RANK_FULL),
|
||||
::testing::Values(CV_32F, CV_64F),
|
||||
::testing::Bool(), // symmetrical
|
||||
::testing::Bool() // needUV
|
||||
))
|
||||
{
|
||||
auto t = GetParam();
|
||||
auto rc = std::get<0>(t);
|
||||
auto rankEnum = std::get<1>(t);
|
||||
int mtype = std::get<2>(t);
|
||||
bool symmetrical = std::get<3>(t);
|
||||
bool needUV = std::get<4>(t);
|
||||
|
||||
int rows = std::get<0>(rc);
|
||||
int cols = std::get<1>(rc);
|
||||
|
||||
if (symmetrical)
|
||||
{
|
||||
rows = max(rows, cols);
|
||||
cols = rows;
|
||||
}
|
||||
|
||||
int rank = std::min(rows, cols);
|
||||
switch (rankEnum)
|
||||
{
|
||||
case RANK_HALF: rank /= 2; break;
|
||||
case RANK_MINUS_1: rank -= 1; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
int flags = needUV ? 0 : SVD::NO_UV;
|
||||
|
||||
RNG& rng = theRNG();
|
||||
Mat A = buildRandomMat(rows, cols, mtype, rng, rank, symmetrical);
|
||||
TEST_CYCLE() cv::SVD svd(A, flags);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
|
||||
PERF_TEST_P(SvdTest, backSubst, ::testing::Combine(
|
||||
::testing::Values(std::make_tuple(5, 15), std::make_tuple(32, 32), std::make_tuple(100, 100)),
|
||||
::testing::Values(RANK_HALF, RANK_MINUS_1, RANK_FULL),
|
||||
::testing::Values(CV_32F, CV_64F),
|
||||
// back substitution works the same regardless of source matrix properties
|
||||
::testing::Values(true),
|
||||
// back substitution has no sense without u and v
|
||||
::testing::Values(true) // needUV
|
||||
))
|
||||
{
|
||||
auto t = GetParam();
|
||||
auto rc = std::get<0>(t);
|
||||
auto rankEnum = std::get<1>(t);
|
||||
int mtype = std::get<2>(t);
|
||||
|
||||
int rows = std::get<0>(rc);
|
||||
int cols = std::get<1>(rc);
|
||||
|
||||
int rank = std::min(rows, cols);
|
||||
switch (rankEnum)
|
||||
{
|
||||
case RANK_HALF: rank /= 2; break;
|
||||
case RANK_MINUS_1: rank -= 1; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
RNG& rng = theRNG();
|
||||
Mat A = buildRandomMat(rows, cols, mtype, rng, rank, /* symmetrical */ false);
|
||||
cv::SVD svd(A);
|
||||
// preallocate to not spend time on it during backSubst()
|
||||
Mat dst(cols, 1, mtype);
|
||||
Mat rhs(rows, 1, mtype);
|
||||
rng.fill(rhs, RNG::UNIFORM, Scalar(-10), Scalar(10));
|
||||
|
||||
TEST_CYCLE() svd.backSubst(rhs, dst);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
|
||||
typedef perf::TestBaseWithParam< testing::tuple<int, int, int> > KMeans;
|
||||
|
||||
PERF_TEST_P_(KMeans, single_iter)
|
||||
{
|
||||
RNG& rng = theRNG();
|
||||
const int K = testing::get<0>(GetParam());
|
||||
const int dims = testing::get<1>(GetParam());
|
||||
const int N = testing::get<2>(GetParam());
|
||||
const int attempts = 5;
|
||||
|
||||
Mat data(N, dims, CV_32F);
|
||||
rng.fill(data, RNG::UNIFORM, -0.1, 0.1);
|
||||
|
||||
const int N0 = K;
|
||||
Mat data0(N0, dims, CV_32F);
|
||||
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
int base = rng.uniform(0, N0);
|
||||
cv::add(data0.row(base), data.row(i), data.row(i));
|
||||
}
|
||||
|
||||
declare.in(data);
|
||||
|
||||
Mat labels, centers;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 1, 0),
|
||||
attempts, KMEANS_PP_CENTERS, centers);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(KMeans, good)
|
||||
{
|
||||
RNG& rng = theRNG();
|
||||
const int K = testing::get<0>(GetParam());
|
||||
const int dims = testing::get<1>(GetParam());
|
||||
const int N = testing::get<2>(GetParam());
|
||||
const int attempts = 5;
|
||||
|
||||
Mat data(N, dims, CV_32F);
|
||||
rng.fill(data, RNG::UNIFORM, -0.1, 0.1);
|
||||
|
||||
const int N0 = K;
|
||||
Mat data0(N0, dims, CV_32F);
|
||||
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
int base = rng.uniform(0, N0);
|
||||
cv::add(data0.row(base), data.row(i), data.row(i));
|
||||
}
|
||||
|
||||
declare.in(data);
|
||||
|
||||
Mat labels, centers;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
|
||||
attempts, KMEANS_PP_CENTERS, centers);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(KMeans, with_duplicates)
|
||||
{
|
||||
RNG& rng = theRNG();
|
||||
const int K = testing::get<0>(GetParam());
|
||||
const int dims = testing::get<1>(GetParam());
|
||||
const int N = testing::get<2>(GetParam());
|
||||
const int attempts = 5;
|
||||
|
||||
Mat data(N, dims, CV_32F, Scalar::all(0));
|
||||
|
||||
const int N0 = std::max(2, K * 2 / 3);
|
||||
Mat data0(N0, dims, CV_32F);
|
||||
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
int base = rng.uniform(0, N0);
|
||||
data0.row(base).copyTo(data.row(i));
|
||||
}
|
||||
|
||||
declare.in(data);
|
||||
|
||||
Mat labels, centers;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
|
||||
attempts, KMEANS_PP_CENTERS, centers);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/ , KMeans,
|
||||
testing::Values(
|
||||
// K clusters, dims, N points
|
||||
testing::make_tuple(2, 3, 100000),
|
||||
testing::make_tuple(4, 3, 500),
|
||||
testing::make_tuple(4, 3, 1000),
|
||||
testing::make_tuple(4, 3, 10000),
|
||||
testing::make_tuple(8, 3, 1000),
|
||||
testing::make_tuple(8, 16, 1000),
|
||||
testing::make_tuple(8, 64, 1000),
|
||||
testing::make_tuple(16, 16, 1000),
|
||||
testing::make_tuple(16, 32, 1000),
|
||||
testing::make_tuple(32, 16, 1000),
|
||||
testing::make_tuple(32, 32, 1000),
|
||||
testing::make_tuple(100, 2, 1000)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<Size, MatType, int> Size_SrcDepth_DstChannels_t;
|
||||
typedef perf::TestBaseWithParam<Size_SrcDepth_DstChannels_t> Size_SrcDepth_DstChannels;
|
||||
|
||||
PERF_TEST_P( Size_SrcDepth_DstChannels, merge,
|
||||
testing::Combine
|
||||
(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8U, CV_16S, CV_32S, CV_32F, CV_64F),
|
||||
testing::Values(2, 3, 4)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int srcDepth = get<1>(GetParam());
|
||||
int dstChannels = get<2>(GetParam());
|
||||
|
||||
int maxValue = 255;
|
||||
|
||||
vector<Mat> mv;
|
||||
for( int i = 0; i < dstChannels; ++i )
|
||||
{
|
||||
mv.push_back( Mat(sz, CV_MAKETYPE(srcDepth, 1)) );
|
||||
randu(mv[i], 0, maxValue);
|
||||
}
|
||||
|
||||
Mat dst;
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) merge( (vector<Mat> &)mv, dst );
|
||||
|
||||
double eps = srcDepth <= CV_32S ? 1e-12 : (FLT_EPSILON * maxValue);
|
||||
SANITY_CHECK(dst, eps);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
PERF_TEST_P(Size_MatType, minMaxLoc, testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
double minVal, maxVal;
|
||||
Point minLoc, maxLoc;
|
||||
|
||||
if (matType == CV_8U)
|
||||
randu(src, 1, 254 /*do not include 0 and 255 to avoid early exit on 1 byte data*/);
|
||||
else if (matType == CV_8S)
|
||||
randu(src, -127, 126);
|
||||
else
|
||||
warmup(src, WARMUP_RNG);
|
||||
|
||||
declare.in(src);
|
||||
|
||||
TEST_CYCLE() minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);
|
||||
|
||||
SANITY_CHECK(minVal, 1e-12);
|
||||
SANITY_CHECK(maxVal, 1e-12);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,305 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define HAMMING_NORM_SIZES cv::Size(640, 480), cv::Size(1920, 1080)
|
||||
#define HAMMING_NORM_TYPES CV_8UC1
|
||||
|
||||
CV_FLAGS(NormType, NORM_HAMMING2, NORM_HAMMING, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
|
||||
typedef tuple<Size, MatType, NormType> Size_MatType_NormType_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_NormType_t> Size_MatType_NormType;
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, norm,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
double n;
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
TEST_CYCLE() n = cv::norm(src, normType);
|
||||
|
||||
SANITY_CHECK(n, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, norm_mask,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat mask = Mat::ones(sz, CV_8U);
|
||||
double n;
|
||||
|
||||
declare.in(src, WARMUP_RNG).in(mask);
|
||||
|
||||
TEST_CYCLE() n = cv::norm(src, normType, mask);
|
||||
|
||||
SANITY_CHECK(n, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, norm2,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)(NORM_RELATIVE+NORM_INF), (int)(NORM_RELATIVE+NORM_L1), (int)(NORM_RELATIVE+NORM_L2))
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src1(sz, matType);
|
||||
Mat src2(sz, matType);
|
||||
double n;
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG);
|
||||
|
||||
TEST_CYCLE() n = cv::norm(src1, src2, normType);
|
||||
|
||||
SANITY_CHECK(n, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, norm2_mask,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)(NORM_RELATIVE|NORM_INF), (int)(NORM_RELATIVE|NORM_L1), (int)(NORM_RELATIVE|NORM_L2))
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src1(sz, matType);
|
||||
Mat src2(sz, matType);
|
||||
Mat mask = Mat::ones(sz, CV_8U);
|
||||
double n;
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG).in(mask);
|
||||
|
||||
TEST_CYCLE() n = cv::norm(src1, src2, normType, mask);
|
||||
|
||||
SANITY_CHECK(n, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
namespace {
|
||||
typedef tuple<NormType, MatType, Size> PerfHamming_t;
|
||||
typedef perf::TestBaseWithParam<PerfHamming_t> PerfHamming;
|
||||
|
||||
PERF_TEST_P(PerfHamming, norm,
|
||||
testing::Combine(
|
||||
testing::Values(NORM_HAMMING, NORM_HAMMING2),
|
||||
testing::Values(HAMMING_NORM_TYPES),
|
||||
testing::Values(HAMMING_NORM_SIZES)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<2>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<0>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
double n;
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
TEST_CYCLE() n = cv::norm(src, normType);
|
||||
|
||||
CV_UNUSED(n);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(PerfHamming, norm2,
|
||||
testing::Combine(
|
||||
testing::Values(NORM_HAMMING, NORM_HAMMING2),
|
||||
testing::Values(HAMMING_NORM_TYPES),
|
||||
testing::Values(HAMMING_NORM_SIZES)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<2>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<0>(GetParam());
|
||||
|
||||
Mat src1(sz, matType);
|
||||
Mat src2(sz, matType);
|
||||
double n;
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG);
|
||||
|
||||
TEST_CYCLE() n = cv::norm(src1, src2, normType);
|
||||
|
||||
CV_UNUSED(n);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, normalize,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat dst(sz, matType);
|
||||
|
||||
double alpha = 100.;
|
||||
if(normType==NORM_L1) alpha = (double)src.total() * src.channels();
|
||||
if(normType==NORM_L2) alpha = (double)src.total()/10;
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::normalize(src, dst, alpha, 0., normType);
|
||||
|
||||
SANITY_CHECK(dst, 1e-6);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, normalize_mask,
|
||||
testing::Combine(
|
||||
testing::Values(::perf::szVGA, ::perf::sz1080p),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat dst(sz, matType);
|
||||
Mat mask = Mat::ones(sz, CV_8U);
|
||||
|
||||
double alpha = 100.;
|
||||
if(normType==NORM_L1) alpha = (double)src.total() * src.channels();
|
||||
if(normType==NORM_L2) alpha = (double)src.total()/10;
|
||||
|
||||
declare.in(src, WARMUP_RNG).in(mask).out(dst);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE() cv::normalize(src, dst, alpha, 0., normType, -1, mask);
|
||||
|
||||
SANITY_CHECK(dst, 1e-6);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, normalize_32f,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int normType = get<2>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat dst(sz, CV_32F);
|
||||
|
||||
double alpha = 100.;
|
||||
if(normType==NORM_L1) alpha = (double)src.total() * src.channels();
|
||||
if(normType==NORM_L2) alpha = (double)src.total()/10;
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::normalize(src, dst, alpha, 0., normType, CV_32F);
|
||||
|
||||
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P( Size_MatType, normalize_minmax, TYPICAL_MATS )
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat dst(sz, matType);
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
declare.time(30);
|
||||
|
||||
TEST_CYCLE() cv::normalize(src, dst, 20., 100., NORM_MINMAX);
|
||||
|
||||
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam< int > test_len;
|
||||
PERF_TEST_P(test_len, hal_normL1_u8,
|
||||
testing::Values(300000, 2000000)
|
||||
)
|
||||
{
|
||||
int len = GetParam();
|
||||
|
||||
Mat src1(1, len, CV_8UC1);
|
||||
Mat src2(1, len, CV_8UC1);
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG);
|
||||
double n;
|
||||
TEST_CYCLE() n = hal::normL1_(src1.ptr<uchar>(0), src2.ptr<uchar>(0), len);
|
||||
CV_UNUSED(n);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(test_len, hal_normL1_f32,
|
||||
testing::Values(300000, 2000000)
|
||||
)
|
||||
{
|
||||
int len = GetParam();
|
||||
|
||||
Mat src1(1, len, CV_32FC1);
|
||||
Mat src2(1, len, CV_32FC1);
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG);
|
||||
double n;
|
||||
TEST_CYCLE() n = hal::normL1_(src1.ptr<float>(0), src2.ptr<float>(0), len);
|
||||
CV_UNUSED(n);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(test_len, hal_normL2Sqr,
|
||||
testing::Values(300000, 2000000)
|
||||
)
|
||||
{
|
||||
int len = GetParam();
|
||||
|
||||
Mat src1(1, len, CV_32FC1);
|
||||
Mat src2(1, len, CV_32FC1);
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG);
|
||||
double n;
|
||||
TEST_CYCLE() n = hal::normL2Sqr_(src1.ptr<float>(0), src2.ptr<float>(0), len);
|
||||
CV_UNUSED(n);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,9 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html
|
||||
#ifndef __OPENCV_PERF_PRECOMP_HPP__
|
||||
#define __OPENCV_PERF_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
CV_ENUM(ROp, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN, REDUCE_SUM2)
|
||||
typedef tuple<Size, MatType, ROp> Size_MatType_ROp_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_ROp_t> Size_MatType_ROp;
|
||||
|
||||
|
||||
PERF_TEST_P(Size_MatType_ROp, reduceR,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
ROp::all()
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int reduceOp = get<2>(GetParam());
|
||||
|
||||
int ddepth = -1;
|
||||
if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) )
|
||||
ddepth = CV_32S;
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat vec(1, sz.width, ddepth < 0 ? matType : ddepth);
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(vec);
|
||||
declare.time(100);
|
||||
|
||||
int runs = 15;
|
||||
TEST_CYCLE_MULTIRUN(runs) reduce(src, vec, 0, reduceOp, ddepth);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_ROp, reduceC,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
ROp::all()
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int reduceOp = get<2>(GetParam());
|
||||
|
||||
int ddepth = -1;
|
||||
if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) )
|
||||
ddepth = CV_32S;
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat vec(sz.height, 1, ddepth < 0 ? matType : ddepth);
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(vec);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE() reduce(src, vec, 1, reduceOp, ddepth);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef tuple<Size, MatType, int> Size_MatType_RMode_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_RMode_t> Size_MatType_RMode;
|
||||
|
||||
PERF_TEST_P(Size_MatType_RMode, DISABLED_reduceArgMinMax, testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8U, CV_32F),
|
||||
testing::Values(0, 1)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size srcSize = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
int axis = get<2>(GetParam());
|
||||
|
||||
Mat src(srcSize, matType);
|
||||
|
||||
std::vector<int> dstSize(src.dims);
|
||||
std::copy(src.size.p, src.size.p + src.dims, dstSize.begin());
|
||||
dstSize[axis] = 1;
|
||||
|
||||
Mat dst(dstSize, CV_32S, 0.);
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::reduceArgMin(src, dst, axis, true);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
#define TYPICAL_MAT_SIZES_SORT TYPICAL_MAT_SIZES
|
||||
#define TYPICAL_MAT_TYPES_SORT CV_8UC1, CV_16UC1, CV_32FC1
|
||||
#define SORT_TYPES SORT_EVERY_ROW | SORT_ASCENDING, SORT_EVERY_ROW | SORT_DESCENDING
|
||||
#define TYPICAL_MATS_SORT testing::Combine( testing::Values(TYPICAL_MAT_SIZES_SORT), testing::Values(TYPICAL_MAT_TYPES_SORT), testing::Values(SORT_TYPES) )
|
||||
|
||||
typedef tuple<Size, MatType, int> sortParams;
|
||||
typedef TestBaseWithParam<sortParams> sortFixture;
|
||||
|
||||
PERF_TEST_P(sortFixture, sort, TYPICAL_MATS_SORT)
|
||||
{
|
||||
const sortParams params = GetParam();
|
||||
const Size sz = get<0>(params);
|
||||
const int type = get<1>(params), flags = get<2>(params);
|
||||
|
||||
cv::Mat a(sz, type), b(sz, type);
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(b);
|
||||
|
||||
TEST_CYCLE() cv::sort(a, b, flags);
|
||||
|
||||
SANITY_CHECK(b);
|
||||
}
|
||||
|
||||
typedef sortFixture sortIdxFixture;
|
||||
|
||||
#undef SORT_TYPES
|
||||
#define SORT_TYPES SORT_EVERY_COLUMN | SORT_ASCENDING, SORT_EVERY_COLUMN | SORT_DESCENDING
|
||||
|
||||
PERF_TEST_P(sortIdxFixture, sorIdx, TYPICAL_MATS_SORT)
|
||||
{
|
||||
const sortParams params = GetParam();
|
||||
const Size sz = get<0>(params);
|
||||
const int type = get<1>(params), flags = get<2>(params);
|
||||
|
||||
cv::Mat a(sz, type), b(sz, type);
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(b);
|
||||
|
||||
TEST_CYCLE() cv::sortIdx(a, b, flags);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<Size, MatType, int> Size_Depth_Channels_t;
|
||||
typedef perf::TestBaseWithParam<Size_Depth_Channels_t> Size_Depth_Channels;
|
||||
|
||||
PERF_TEST_P( Size_Depth_Channels, split,
|
||||
testing::Combine
|
||||
(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8U, CV_16S, CV_32F, CV_64F),
|
||||
testing::Values(2, 3, 4)
|
||||
)
|
||||
)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int depth = get<1>(GetParam());
|
||||
int channels = get<2>(GetParam());
|
||||
|
||||
Mat m(sz, CV_MAKETYPE(depth, channels));
|
||||
randu(m, 0, 255);
|
||||
|
||||
vector<Mat> mv;
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) split(m, (vector<Mat>&)mv);
|
||||
|
||||
SANITY_CHECK(mv, 2e-5);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,120 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
PERF_TEST_P(Size_MatType, sum, TYPICAL_MATS)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
|
||||
Mat arr(sz, type);
|
||||
Scalar s;
|
||||
|
||||
declare.in(arr, WARMUP_RNG).out(s);
|
||||
|
||||
TEST_CYCLE() s = sum(arr);
|
||||
|
||||
SANITY_CHECK(s, 1e-6, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, type);
|
||||
Scalar s;
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(s);
|
||||
|
||||
TEST_CYCLE() s = cv::mean(src);
|
||||
|
||||
SANITY_CHECK(s, 1e-5);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int type = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, type);
|
||||
Mat mask = Mat::ones(src.size(), CV_8U);
|
||||
Scalar s;
|
||||
|
||||
declare.in(src, WARMUP_RNG).in(mask).out(s);
|
||||
|
||||
TEST_CYCLE() s = cv::mean(src, mask);
|
||||
|
||||
SANITY_CHECK(s, 5e-5);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Scalar mean;
|
||||
Scalar dev;
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(mean, dev);
|
||||
|
||||
TEST_CYCLE() meanStdDev(src, mean, dev);
|
||||
|
||||
SANITY_CHECK(mean, 1e-5, ERROR_RELATIVE);
|
||||
SANITY_CHECK(dev, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS)
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
Mat mask = Mat::ones(sz, CV_8U);
|
||||
Scalar mean;
|
||||
Scalar dev;
|
||||
|
||||
declare.in(src, WARMUP_RNG).in(mask).out(mean, dev);
|
||||
|
||||
TEST_CYCLE() meanStdDev(src, mean, dev, mask);
|
||||
|
||||
SANITY_CHECK(mean, 1e-5);
|
||||
SANITY_CHECK(dev, 1e-5);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) ))
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
int cnt = 0;
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) cnt = countNonZero(src);
|
||||
|
||||
SANITY_CHECK(cnt);
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType, hasNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) ))
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
int matType = get<1>(GetParam());
|
||||
|
||||
Mat src(sz, matType);
|
||||
/*bool hnz = false;*/
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) /*hnz =*/ hasNonZero(src);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,64 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
using namespace ::cvtest::ocl;
|
||||
|
||||
|
||||
struct OpenCLState
|
||||
{
|
||||
OpenCLState(bool useOpenCL)
|
||||
{
|
||||
isOpenCL_enabled = cv::ocl::useOpenCL();
|
||||
cv::ocl::setUseOpenCL(useOpenCL);
|
||||
}
|
||||
|
||||
~OpenCLState()
|
||||
{
|
||||
cv::ocl::setUseOpenCL(isOpenCL_enabled);
|
||||
}
|
||||
|
||||
private:
|
||||
bool isOpenCL_enabled;
|
||||
};
|
||||
|
||||
typedef TestBaseWithParam< tuple<Size, bool, int> > UMatTest;
|
||||
|
||||
OCL_PERF_TEST_P(UMatTest, CustomPtr, Combine(Values(sz1080p, sz2160p), Bool(), ::testing::Values(4, 64, 4096)))
|
||||
{
|
||||
OpenCLState s(get<1>(GetParam()));
|
||||
|
||||
int type = CV_8UC1;
|
||||
cv::Size size = get<0>(GetParam());
|
||||
size_t align_base = 4096;
|
||||
const int align_offset = get<2>(GetParam());
|
||||
|
||||
void* pData_allocated = new unsigned char [size.area() * CV_ELEM_SIZE(type) + (align_base + align_offset)];
|
||||
void* pData = (char*)alignPtr(pData_allocated, (int)align_base) + align_offset;
|
||||
size_t step = size.width * CV_ELEM_SIZE(type);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = Mat(size, type, pData, step);
|
||||
m.setTo(cv::Scalar::all(2));
|
||||
|
||||
UMat u = m.getUMat(ACCESS_RW);
|
||||
cv::add(u, cv::Scalar::all(2), u);
|
||||
cv::add(u, cv::Scalar::all(3), u);
|
||||
|
||||
Mat d = u.getMat(ACCESS_READ);
|
||||
ASSERT_EQ(7, d.at<char>(0, 0));
|
||||
}
|
||||
|
||||
delete[] (unsigned char*)pData_allocated;
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user