opencv/modules/gpu/perf/perf_core.cpp

1514 lines
35 KiB
C++
Raw Normal View History

2012-05-23 20:58:01 +08:00
#include "perf_precomp.hpp"
using namespace std;
using namespace testing;
namespace {
#define ARITHM_MAT_DEPTH Values(CV_8U, CV_16U, CV_32F, CV_64F)
2012-05-23 20:58:01 +08:00
//////////////////////////////////////////////////////////////////////
// Merge
PERF_TEST_P(Sz_Depth_Cn, Core_Merge, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
std::vector<cv::gpu::GpuMat> d_src(channels);
2012-05-23 20:58:01 +08:00
for (int i = 0; i < channels; ++i)
d_src[i] = cv::gpu::GpuMat(size, depth, cv::Scalar::all(i));
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::merge(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::merge(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Split
PERF_TEST_P(Sz_Depth_Cn, Core_Split, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, Values(2, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(size, CV_MAKE_TYPE(depth, channels), cv::Scalar(1, 2, 3, 4));
2012-05-23 20:58:01 +08:00
std::vector<cv::gpu::GpuMat> d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::split(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::split(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// AddMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_AddMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::add(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::add(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// AddScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_AddScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar s(1, 2, 3, 4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::add(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::add(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// SubtractMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_SubtractMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::subtract(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::subtract(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// SubtractScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_SubtractScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar s(1, 2, 3, 4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::subtract(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::subtract(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MultiplyMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_MultiplyMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::multiply(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::multiply(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MultiplyScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar s(1, 2, 3, 4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::multiply(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::multiply(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// DivideMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_DivideMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::divide(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::divide(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// DivideScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_DivideScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar s(1, 2, 3, 4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::divide(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::divide(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// DivideScalarInv
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
double s = 100.0;
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::divide(s, d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::divide(s, d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// AbsDiffMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::absdiff(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::absdiff(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// AbsDiffScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar s(1, 2, 3, 4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::absdiff(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::absdiff(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Abs
PERF_TEST_P(Sz_Depth, Core_Abs, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_16S, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::abs(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::abs(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Sqr
PERF_TEST_P(Sz_Depth, Core_Sqr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::sqr(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::sqr(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Sqrt
PERF_TEST_P(Sz_Depth, Core_Sqrt, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::sqrt(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::sqrt(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Log
PERF_TEST_P(Sz_Depth, Core_Log, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src, 1.0, 255.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::log(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::log(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Exp
PERF_TEST_P(Sz_Depth, Core_Exp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src, 1.0, 10.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::exp(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::exp(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Pow
DEF_PARAM_TEST(Sz_Depth_Power, cv::Size, MatDepth, double);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Power, Core_Pow, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S, CV_32F), Values(0.3, 2.0, 2.4)))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
double power = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src, 1.0, 10.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::pow(d_src, power, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::pow(d_src, power, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// CompareMat
2012-05-23 20:58:01 +08:00
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
#define ALL_CMP_CODES ValuesIn(CmpCode::all())
2012-05-23 20:58:01 +08:00
DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CmpCode);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Code, Core_CompareMat, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int cmp_code = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::compare(d_src1, d_src2, d_dst, cmp_code);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// CompareScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Code, Core_CompareScalar, Combine(GPU_TYPICAL_MAT_SIZES, ARITHM_MAT_DEPTH, ALL_CMP_CODES))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int cmp_code = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar s = cv::Scalar::all(100);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::compare(d_src, s, d_dst, cmp_code);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::compare(d_src, s, d_dst, cmp_code);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseNot
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_BitwiseNot, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_not(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_not(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseAndMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_BitwiseAndMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_and(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_and(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseAndScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseAndScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
cv::Scalar s = cv::Scalar::all(100);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_and(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_and(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseOrMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_BitwiseOrMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_or(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_or(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseOrScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseOrScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
cv::Scalar s = cv::Scalar::all(100);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_or(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_or(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseXorMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_BitwiseXorMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_xor(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_xor(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// BitwiseXorScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn, Core_BitwiseXorScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
cv::Scalar s = cv::Scalar::all(100);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::bitwise_xor(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::bitwise_xor(d_src, s, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// RShift
PERF_TEST_P(Sz_Depth_Cn, Core_RShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar_<int> val = cv::Scalar_<int>::all(4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::rshift(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::rshift(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// LShift
PERF_TEST_P(Sz_Depth_Cn, Core_LShift, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32S), Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar_<int> val = cv::Scalar_<int>::all(4);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::lshift(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::lshift(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MinMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_MinMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::min(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::min(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MinScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_MinScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
double val = 50.0;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::min(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::min(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MaxMat
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_MaxMat, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::max(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::max(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MaxScalar
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth, Core_MaxScalar, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
double val = 50.0;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::max(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::max(d_src, val, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// AddWeighted
DEF_PARAM_TEST(Sz_3Depth, cv::Size, MatDepth, MatDepth, MatDepth);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_3Depth, Core_AddWeighted, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F),
Values(CV_8U, CV_16U, CV_32F, CV_64F),
Values(CV_8U, CV_16U, CV_32F, CV_64F)))
{
cv::Size size = GET_PARAM(0);
int depth1 = GET_PARAM(1);
int depth2 = GET_PARAM(2);
int dst_depth = GET_PARAM(3);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, depth1);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, depth2);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, d_dst, dst_depth);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// GEMM
CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T)
#define ALL_GEMM_FLAGS Values(0, CV_GEMM_A_T, CV_GEMM_B_T, CV_GEMM_C_T, CV_GEMM_A_T | CV_GEMM_B_T, CV_GEMM_A_T | CV_GEMM_C_T, CV_GEMM_A_T | CV_GEMM_B_T | CV_GEMM_C_T)
2012-05-23 20:58:01 +08:00
DEF_PARAM_TEST(Sz_Type_Flags, cv::Size, MatType, GemmFlags);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Type_Flags, Core_GEMM, Combine(
Values(cv::Size(512, 512), cv::Size(1024, 1024)),
Values(CV_32FC1, CV_32FC2, CV_64FC1, CV_64FC2),
ALL_GEMM_FLAGS))
{
declare.time(5.0);
2012-05-23 20:58:01 +08:00
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int flags = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, type);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, type);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
cv::Mat src3(size, type);
fillRandom(src3);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_src3(src3);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst, flags);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Transpose
PERF_TEST_P(Sz_Type, Core_Transpose, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8UC1, CV_8UC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_64FC1)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::transpose(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::transpose(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Flip
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
#define ALL_FLIP_CODES ValuesIn(FlipCode::all())
2012-05-23 20:58:01 +08:00
DEF_PARAM_TEST(Sz_Depth_Cn_Code, cv::Size, MatDepth, int, FlipCode);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn_Code, Core_Flip, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
ALL_FLIP_CODES))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int flipCode = GET_PARAM(3);
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::flip(d_src, d_dst, flipCode);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::flip(d_src, d_dst, flipCode);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// LutOneChannel
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Type, Core_LutOneChannel, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8UC1, CV_8UC3)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Mat lut(1, 256, CV_8UC1);
fillRandom(lut);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::LUT(d_src, lut, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::LUT(d_src, lut, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// LutMultiChannel
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Type, Core_LutMultiChannel, Combine(
GPU_TYPICAL_MAT_SIZES,
Values<MatType>(CV_8UC3)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Mat lut(1, 256, CV_MAKE_TYPE(CV_8U, src.channels()));
fillRandom(lut);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::LUT(d_src, lut, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::LUT(d_src, lut, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MagnitudeComplex
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz, Core_MagnitudeComplex, GPU_TYPICAL_MAT_SIZES)
2012-05-23 20:58:01 +08:00
{
cv::Size size = GetParam();
2012-05-23 20:58:01 +08:00
cv::Mat src(size, CV_32FC2);
fillRandom(src, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::magnitude(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::magnitude(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MagnitudeSqrComplex
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz, Core_MagnitudeSqrComplex, GPU_TYPICAL_MAT_SIZES)
2012-05-23 20:58:01 +08:00
{
cv::Size size = GetParam();
2012-05-23 20:58:01 +08:00
cv::Mat src(size, CV_32FC2);
fillRandom(src, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::magnitudeSqr(d_src, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::magnitudeSqr(d_src, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Magnitude
PERF_TEST_P(Sz, Core_Magnitude, GPU_TYPICAL_MAT_SIZES)
2012-05-23 20:58:01 +08:00
{
cv::Size size = GetParam();
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, CV_32FC1);
fillRandom(src1, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, CV_32FC1);
fillRandom(src2, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::magnitude(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::magnitude(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MagnitudeSqr
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz, Core_MagnitudeSqr, GPU_TYPICAL_MAT_SIZES)
2012-05-23 20:58:01 +08:00
{
cv::Size size = GetParam();
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, CV_32FC1);
fillRandom(src1, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, CV_32FC1);
fillRandom(src2, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::magnitudeSqr(d_src1, d_src2, d_dst);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Phase
DEF_PARAM_TEST(Sz_AngleInDegrees, cv::Size, bool);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
bool angleInDegrees = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, CV_32FC1);
fillRandom(src1, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, CV_32FC1);
fillRandom(src2, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::phase(d_src1, d_src2, d_dst, angleInDegrees);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// CartToPolar
PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
bool angleInDegrees = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, CV_32FC1);
fillRandom(src1, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, CV_32FC1);
fillRandom(src2, -100.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_magnitude;
cv::gpu::GpuMat d_angle;
2012-05-23 20:58:01 +08:00
cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::cartToPolar(d_src1, d_src2, d_magnitude, d_angle, angleInDegrees);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// PolarToCart
PERF_TEST_P(Sz_AngleInDegrees, Core_PolarToCart, Combine(GPU_TYPICAL_MAT_SIZES, Bool()))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
bool angleInDegrees = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat magnitude(size, CV_32FC1);
fillRandom(magnitude, 0.0, 100.0);
2012-05-23 20:58:01 +08:00
cv::Mat angle(size, CV_32FC1);
fillRandom(angle, 0.0, angleInDegrees ? 360.0 : 2 * CV_PI);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_magnitude(magnitude);
cv::gpu::GpuMat d_angle(angle);
cv::gpu::GpuMat d_x;
cv::gpu::GpuMat d_y;
2012-05-23 20:58:01 +08:00
cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::polarToCart(d_magnitude, d_angle, d_x, d_y, angleInDegrees);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MeanStdDev
PERF_TEST_P(Sz, Core_MeanStdDev, GPU_TYPICAL_MAT_SIZES)
2012-05-23 20:58:01 +08:00
{
cv::Size size = GetParam();
2012-05-23 20:58:01 +08:00
cv::Mat src(size, CV_8UC1);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar mean;
cv::Scalar stddev;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
cv::gpu::meanStdDev(d_src, mean, stddev, d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::meanStdDev(d_src, mean, stddev, d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Norm
DEF_PARAM_TEST(Sz_Depth_Norm, cv::Size, MatDepth, NormType);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Norm, Core_Norm, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32S, CV_32F),
Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int normType = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
double dst;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
dst = cv::gpu::norm(d_src, normType, d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
dst = cv::gpu::norm(d_src, normType, d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// NormDiff
DEF_PARAM_TEST(Sz_Norm, cv::Size, NormType);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Norm, Core_NormDiff, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(NormType(cv::NORM_INF), NormType(cv::NORM_L1), NormType(cv::NORM_L2))))
{
cv::Size size = GET_PARAM(0);
int normType = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src1(size, CV_8UC1);
fillRandom(src1);
2012-05-23 20:58:01 +08:00
cv::Mat src2(size, CV_8UC1);
fillRandom(src2);
2012-05-23 20:58:01 +08:00
double dst;
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
dst = cv::gpu::norm(d_src1, d_src2, normType);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
dst = cv::gpu::norm(d_src1, d_src2, normType);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Sum
PERF_TEST_P(Sz_Depth_Cn, Core_Sum, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar dst;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
dst = cv::gpu::sum(d_src, d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
dst = cv::gpu::sum(d_src, d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// SumAbs
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn, Core_SumAbs, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar dst;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
dst = cv::gpu::absSum(d_src, d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
dst = cv::gpu::absSum(d_src, d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// SumSqr
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn, Core_SumSqr, Combine(
GPU_TYPICAL_MAT_SIZES,
Values<MatDepth>(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::Scalar dst;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
dst = cv::gpu::sqrSum(d_src, d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
dst = cv::gpu::sqrSum(d_src, d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MinMax
PERF_TEST_P(Sz_Depth, Core_MinMax, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
double minVal, maxVal;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::minMax(d_src, &minVal, &maxVal, cv::gpu::GpuMat(), d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MinMaxLoc
PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
double minVal, maxVal;
cv::Point minLoc, maxLoc;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_valbuf, d_locbuf;
cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::minMaxLoc(d_src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// CountNonZero
PERF_TEST_P(Sz_Depth, Core_CountNonZero, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F)))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, depth);
fillRandom(src);
2012-05-23 20:58:01 +08:00
int dst;
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_buf;
dst = cv::gpu::countNonZero(d_src, d_buf);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
dst = cv::gpu::countNonZero(d_src, d_buf);
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// Reduce
CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
#define ALL_REDUCE_CODES ValuesIn(ReduceCode::all())
2012-05-23 20:58:01 +08:00
enum {Rows = 0, Cols = 1};
CV_ENUM(ReduceDim, Rows, Cols)
#define ALL_REDUCE_DIMS ValuesIn(ReduceDim::all())
2012-05-23 20:58:01 +08:00
DEF_PARAM_TEST(Sz_Depth_Cn_Code_Dim, cv::Size, MatDepth, int, ReduceCode, ReduceDim);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn_Code_Dim, Core_Reduce, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(1, 2, 3, 4),
ALL_REDUCE_CODES,
ALL_REDUCE_DIMS))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
int reduceOp = GET_PARAM(3);
int dim = GET_PARAM(4);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-05-23 20:58:01 +08:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
cv::gpu::reduce(d_src, d_dst, dim, reduceOp);
2012-05-23 20:58:01 +08:00
TEST_CYCLE()
{
cv::gpu::reduce(d_src, d_dst, dim, reduceOp);
2012-05-23 20:58:01 +08:00
}
}
} // namespace