Commit 457b8d7b authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

update gpu perf tests

parent eccfc90b
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo_Size_MatType, transpose, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_32SC1, CV_64FC1)))
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// Transpose
GPU_PERF_TEST(Transpose, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size.width, size.height, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
transpose(src, dst);
cv::gpu::transpose(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, Transpose, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_32SC1, CV_64FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Flip
PERF_TEST_P(DevInfo_Size_MatType_FlipCode, flip, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4),
testing::Values((int)HORIZONTAL_AXIS, (int)VERTICAL_AXIS, (int)BOTH_AXIS)))
GPU_PERF_TEST(Flip, cv::gpu::DeviceInfo, cv::Size, perf::MatType, FlipCode)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int flipCode = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int flipCode = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
flip(src, dst, flipCode);
cv::gpu::flip(src, dst, flipCode);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, Flip, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4),
testing::Values((int) HORIZONTAL_AXIS, (int) VERTICAL_AXIS, (int) BOTH_AXIS)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// LUT
PERF_TEST_P(DevInfo_Size_MatType, LUT, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC3)))
GPU_PERF_TEST(LUT, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
Mat lut(1, 256, CV_8UC1);
cv::Mat src_host(size, type);
cv::Mat lut(1, 256, CV_8UC1);
declare.in(src_host, lut, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
LUT(src, lut, dst);
cv::gpu::LUT(src, lut, dst);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
}
PERF_TEST_P(DevInfo_Size, cartToPolar, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
setDevice(devInfo.deviceID());
Mat x_host(size, CV_32FC1);
Mat y_host(size, CV_32FC1);
INSTANTIATE_TEST_CASE_P(Arithm, LUT, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC3)));
declare.in(x_host, y_host, WARMUP_RNG);
//////////////////////////////////////////////////////////////////////
// CartToPolar
GpuMat x(x_host);
GpuMat y(y_host);
GpuMat magnitude(size, CV_32FC1);
GpuMat angle(size, CV_32FC1);
TEST_CYCLE(100)
{
cartToPolar(x, y, magnitude, angle);
}
Mat magnitude_host(magnitude);
Mat angle_host(angle);
SANITY_CHECK(magnitude_host);
SANITY_CHECK(angle_host);
}
PERF_TEST_P(DevInfo_Size, polarToCart, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(CartToPolar, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat magnitude_host(size, CV_32FC1);
Mat angle_host(size, CV_32FC1);
cv::Mat x_host(size, CV_32FC1);
cv::Mat y_host(size, CV_32FC1);
declare.in(magnitude_host, angle_host, WARMUP_RNG);
fill(x_host, -100.0, 100.0);
fill(y_host, -100.0, 100.0);
GpuMat magnitude(magnitude_host);
GpuMat angle(angle_host);
GpuMat x(size, CV_32FC1);
GpuMat y(size, CV_32FC1);
cv::gpu::GpuMat x(x_host);
cv::gpu::GpuMat y(y_host);
cv::gpu::GpuMat magnitude;
cv::gpu::GpuMat angle;
TEST_CYCLE(100)
{
polarToCart(magnitude, angle, x, y);
cv::gpu::cartToPolar(x, y, magnitude, angle);
}
Mat x_host(x);
Mat y_host(y);
SANITY_CHECK(x_host);
SANITY_CHECK(y_host);
}
PERF_TEST_P(DevInfo_Size_MatType, addMat, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1)))
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
setDevice(devInfo.deviceID());
INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
Mat a_host(size, type);
Mat b_host(size, type);
//////////////////////////////////////////////////////////////////////
// PolarToCart
declare.in(a_host, b_host, WARMUP_RNG);
GpuMat a(a_host);
GpuMat b(b_host);
GpuMat c(size, type);
TEST_CYCLE(100)
{
add(a, b, c);
}
Mat c_host(c);
SANITY_CHECK(c_host);
}
PERF_TEST_P(DevInfo_Size_MatType, addScalar, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_32FC1, CV_32FC2)))
GPU_PERF_TEST(PolarToCart, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat a_host(size, type);
cv::Mat magnitude_host(size, CV_32FC1);
cv::Mat angle_host(size, CV_32FC1);
declare.in(a_host, WARMUP_RNG);
fill(magnitude_host, 0.0, 100.0);
fill(angle_host, 0.0, 360.0);
GpuMat a(a_host);
Scalar b(1,2,3,4);
GpuMat c(size, type);
cv::gpu::GpuMat magnitude(magnitude_host);
cv::gpu::GpuMat angle(angle_host);
cv::gpu::GpuMat x;
cv::gpu::GpuMat y;
TEST_CYCLE(100)
{
add(a, b, c);
cv::gpu::polarToCart(magnitude, angle, x, y, true);
}
Mat c_host(c);
SANITY_CHECK(c_host);
}
PERF_TEST_P(DevInfo_Size_MatType, subtractMat, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_16SC1, CV_32FC1)))
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
setDevice(devInfo.deviceID());
Mat a_host(size, type);
Mat b_host(size, type);
declare.in(a_host, b_host, WARMUP_RNG);
GpuMat a(a_host);
GpuMat b(b_host);
GpuMat c(size, type);
TEST_CYCLE(100)
{
subtract(a, b, c);
}
Mat c_host(c);
INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(c_host);
}
//////////////////////////////////////////////////////////////////////
// AddMat
PERF_TEST_P(DevInfo_Size, multiplyMat, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(AddMat, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat a_host(size, CV_8UC4);
Mat b_host(size, CV_32FC1);
cv::Mat src1_host(size, type);
cv::Mat src2_host(size, type);
declare.in(a_host, b_host, WARMUP_RNG);
fill(src1_host, 0.0, 100.0);
fill(src2_host, 0.0, 100.0);
GpuMat a(a_host);
GpuMat b(b_host);
GpuMat c;
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
multiply(a, b, c);
cv::gpu::add(src1, src2, dst);
}
}
Mat c_host(c);
INSTANTIATE_TEST_CASE_P(Arithm, AddMat, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(c_host);
}
//////////////////////////////////////////////////////////////////////
// AddScalar
PERF_TEST_P(DevInfo_Size_MatType, multiplyScalar, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_32FC1)))
GPU_PERF_TEST(AddScalar, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat a_host(size, type);
cv::Mat src_host(size, type);
declare.in(a_host, WARMUP_RNG);
fill(src_host, 0.0, 100.0);
GpuMat a(a_host);
Scalar b(1,2,3,4);
GpuMat c(size, type);
cv::gpu::GpuMat src(src_host);
cv::Scalar s(1,2,3,4);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
multiply(a, b, c);
cv::gpu::add(src, s, dst);
}
}
Mat c_host(c);
INSTANTIATE_TEST_CASE_P(Arithm, AddScalar, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(c_host);
}
//////////////////////////////////////////////////////////////////////
// Exp
PERF_TEST_P(DevInfo_Size, exp, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(Exp, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat a_host(size, CV_32FC1);
cv::Mat src_host(size, CV_32FC1);
declare.in(a_host, WARMUP_RNG);
fill(src_host, 0.0, 10.0);
GpuMat a(a_host);
GpuMat b(size, CV_32FC1);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
exp(a, b);
cv::gpu::exp(src, dst);
}
}
Mat b_host(b);
INSTANTIATE_TEST_CASE_P(Arithm, Exp, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(b_host);
}
//////////////////////////////////////////////////////////////////////
// Pow
PERF_TEST_P(DevInfo_Size_MatType, pow, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1)))
GPU_PERF_TEST(Pow, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
pow(src, 2.0, dst);
cv::gpu::pow(src, 0.5, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, Pow, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Compare
PERF_TEST_P(DevInfo_Size_MatType_CmpOp, compare, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC4, CV_32FC1),
testing::Values((int)CMP_NE, (int)CMP_EQ)))
GPU_PERF_TEST(Compare, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int cmpop = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src1_host(size, type);
Mat src2_host(size, type);
cv::Mat src1_host(size, type);
cv::Mat src2_host(size, type);
declare.in(src1_host, src2_host, WARMUP_RNG);
GpuMat src1(src1_host);
GpuMat src2(src2_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
compare(src1, src2, dst, cmpop);
cv::gpu::compare(src1, src2, dst, cv::CMP_EQ);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, Compare, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// BitwiseNot
PERF_TEST_P(DevInfo_Size_MatType, bitwise_not, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1)))
GPU_PERF_TEST(BitwiseNot, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
bitwise_not(src, dst);
cv::gpu::bitwise_not(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, BitwiseNot, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// BitwiseAnd
PERF_TEST_P(DevInfo_Size_MatType, bitwise_and, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1)))
GPU_PERF_TEST(BitwiseAnd, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src1_host(size, type);
Mat src2_host(size, type);
cv::Mat src1_host(size, type);
cv::Mat src2_host(size, type);
declare.in(src1_host, src2_host, WARMUP_RNG);
GpuMat src1(src1_host);
GpuMat src2(src2_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
bitwise_and(src1, src2, dst);
cv::gpu::bitwise_and(src1, src2, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, BitwiseAnd, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Min
PERF_TEST_P(DevInfo_Size_MatType, min, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1)))
GPU_PERF_TEST(Min, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src1_host(size, type);
Mat src2_host(size, type);
cv::Mat src1_host(size, type);
cv::Mat src2_host(size, type);
declare.in(src1_host, src2_host, WARMUP_RNG);
GpuMat src1(src1_host);
GpuMat src2(src2_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
cv::gpu::GpuMat dst(size, type);
TEST_CYCLE(100)
{
min(src1, src2, dst);
cv::gpu::min(src1, src2, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, Min, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// MeanStdDev
PERF_TEST_P(DevInfo_Size, meanStdDev, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(MeanStdDev, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
cv::Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
Scalar mean;
Scalar stddev;
cv::gpu::GpuMat src(src_host);
cv::Scalar mean;
cv::Scalar stddev;
TEST_CYCLE(100)
{
meanStdDev(src, mean, stddev);
cv::gpu::meanStdDev(src, mean, stddev);
}
SANITY_CHECK(mean);
SANITY_CHECK(stddev);
}
PERF_TEST_P(DevInfo_Size_MatType_NormType, norm, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)))
INSTANTIATE_TEST_CASE_P(Arithm, MeanStdDev, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
//////////////////////////////////////////////////////////////////////
// Norm
GPU_PERF_TEST(Norm, cv::gpu::DeviceInfo, cv::Size, perf::MatType, NormType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int normType = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int normType = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
cv::gpu::GpuMat src(src_host);
double dst;
GpuMat buf;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
dst = norm(src, normType, buf);
dst = cv::gpu::norm(src, normType, buf);
}
SANITY_CHECK(dst);
}
PERF_TEST_P(DevInfo_Size_NormType, normDiff, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)))
INSTANTIATE_TEST_CASE_P(Arithm, Norm, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32SC1),
testing::Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2)));
//////////////////////////////////////////////////////////////////////
// NormDiff
GPU_PERF_TEST(NormDiff, cv::gpu::DeviceInfo, cv::Size, NormType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int normType = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int normType = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src1_host(size, CV_8UC1);
Mat src2_host(size, CV_8UC1);
cv::Mat src1_host(size, CV_8UC1);
cv::Mat src2_host(size, CV_8UC1);
declare.in(src1_host, src2_host, WARMUP_RNG);
GpuMat src1(src1_host);
GpuMat src2(src2_host);
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
double dst;
TEST_CYCLE(100)
{
dst = norm(src1, src2, normType);
dst = cv::gpu::norm(src1, src2, normType);
}
SANITY_CHECK(dst);
}
PERF_TEST_P(DevInfo_Size_MatType, sum, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
INSTANTIATE_TEST_CASE_P(Arithm, NormDiff, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2)));
//////////////////////////////////////////////////////////////////////
// Sum
GPU_PERF_TEST(Sum, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
Scalar dst;
GpuMat buf;
cv::gpu::GpuMat src(src_host);
cv::Scalar dst;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
dst = sum(src, buf);
dst = cv::gpu::sum(src, buf);
}
SANITY_CHECK(dst);
}
PERF_TEST_P(DevInfo_Size_MatType, minMax, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
INSTANTIATE_TEST_CASE_P(Arithm, Sum, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
//////////////////////////////////////////////////////////////////////
// MinMax
GPU_PERF_TEST(MinMax, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
cv::gpu::GpuMat src(src_host);
double minVal, maxVal;
GpuMat buf;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
minMax(src, &minVal, &maxVal, GpuMat(), buf);
cv::gpu::minMax(src, &minVal, &maxVal, cv::gpu::GpuMat(), buf);
}
SANITY_CHECK(minVal);
SANITY_CHECK(maxVal);
}
PERF_TEST_P(DevInfo_Size_MatType, minMaxLoc, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
INSTANTIATE_TEST_CASE_P(Arithm, MinMax, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
//////////////////////////////////////////////////////////////////////
// MinMaxLoc
GPU_PERF_TEST(MinMaxLoc, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
cv::gpu::GpuMat src(src_host);
double minVal, maxVal;
Point minLoc, maxLoc;
GpuMat valbuf, locbuf;
cv::Point minLoc, maxLoc;
cv::gpu::GpuMat valbuf, locbuf;
TEST_CYCLE(100)
{
minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, GpuMat(), valbuf, locbuf);
cv::gpu::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, cv::gpu::GpuMat(), valbuf, locbuf);
}
SANITY_CHECK(minVal);
SANITY_CHECK(maxVal);
}
PERF_TEST_P(DevInfo_Size_MatType, countNonZero, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
INSTANTIATE_TEST_CASE_P(Arithm, MinMaxLoc, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
//////////////////////////////////////////////////////////////////////
// CountNonZero
GPU_PERF_TEST(CountNonZero, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
fill(src_host, 0.0, 1.0);
GpuMat src(src_host);
int dst=0;
GpuMat buf;
cv::gpu::GpuMat src(src_host);
int dst;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
dst = countNonZero(src, buf);
dst = cv::gpu::countNonZero(src, buf);
}
SANITY_CHECK(dst);
}
PERF_TEST_P(DevInfo_Size_MatType, addWeighted, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
INSTANTIATE_TEST_CASE_P(Arithm, CountNonZero, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
//////////////////////////////////////////////////////////////////////
// AddWeighted
GPU_PERF_TEST(AddWeighted, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src1_host(size, type);
Mat src2_host(size, type);
cv::Mat src1_host(size, type);
cv::Mat src2_host(size, type);
declare.in(src1_host, src2_host, WARMUP_RNG);
fill(src1_host, 0.0, 100.0);
fill(src2_host, 0.0, 100.0);
GpuMat src1(src1_host);
GpuMat src2(src2_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
addWeighted(src1, 0.5, src2, 0.5, 0.0, dst);
cv::gpu::addWeighted(src1, 0.5, src2, 0.5, 0.0, dst);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
cv::Mat dst_host(dst);
}
PERF_TEST_P(DevInfo_Size_MatType_FlipCode, reduce, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values((int)HORIZONTAL_AXIS, (int)VERTICAL_AXIS)))
INSTANTIATE_TEST_CASE_P(Arithm, AddWeighted, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
//////////////////////////////////////////////////////////////////////
// Reduce
GPU_PERF_TEST(Reduce, cv::gpu::DeviceInfo, cv::Size, perf::MatType, FlipCode)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int dim = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int dim = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
fill(src_host, 0.0, 10.0);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
reduce(src, dst, dim, CV_REDUCE_MIN);
cv::gpu::reduce(src, dst, dim, CV_REDUCE_MIN);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
cv::Mat dst_host(dst);
}
PERF_TEST_P(DevInfo_Size, gemm, testing::Combine(testing::ValuesIn(devices()),
testing::Values(cv::Size(512, 512), cv::Size(1024, 1024), cv::Size(2048, 2048), cv::Size(4096, 4096))))
INSTANTIATE_TEST_CASE_P(Arithm, Reduce, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
testing::Values((int) HORIZONTAL_AXIS, (int) VERTICAL_AXIS)));
//////////////////////////////////////////////////////////////////////
// GEMM
GPU_PERF_TEST(GEMM, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src1_host(size, CV_32FC1);
Mat src2_host(size, CV_32FC1);
Mat src3_host(size, CV_32FC1);
cv::Mat src1_host(size, CV_32FC1);
cv::Mat src2_host(size, CV_32FC1);
cv::Mat src3_host(size, CV_32FC1);
declare.in(src1_host, src2_host, src3_host, WARMUP_RNG);
fill(src1_host, 0.0, 10.0);
fill(src2_host, 0.0, 10.0);
fill(src3_host, 0.0, 10.0);
GpuMat src1(src1_host);
GpuMat src2(src2_host);
GpuMat src3(src3_host);
GpuMat dst(size, CV_32FC1);
cv::gpu::GpuMat src1(src1_host);
cv::gpu::GpuMat src2(src2_host);
cv::gpu::GpuMat src3(src3_host);
cv::gpu::GpuMat dst;
declare.time(5.0);
TEST_CYCLE(100)
{
gemm(src1, src2, 1.0, src3, 1.0, dst);
cv::gpu::gemm(src1, src2, 1.0, src3, 1.0, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Arithm, GEMM, testing::Combine(
ALL_DEVICES,
testing::Values(cv::Size(512, 512), cv::Size(1024, 1024), cv::Size(2048, 2048))));
SANITY_CHECK(dst_host);
}
#endif
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo, transformPoints, testing::ValuesIn(devices()))
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// TransformPoints
GPU_PERF_TEST_1(TransformPoints, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(1, 10000, CV_32FC3);
cv::Mat src_host(1, 10000, CV_32FC3);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
transformPoints(src, Mat::ones(1, 3, CV_32FC1), Mat::ones(1, 3, CV_32FC1), dst);
cv::gpu::transformPoints(src, cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(1, 3, CV_32FC1), dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// ProjectPoints
PERF_TEST_P(DevInfo, projectPoints, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(ProjectPoints, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(1, 10000, CV_32FC3);
cv::Mat src_host(1, 10000, CV_32FC3);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
projectPoints(src, Mat::ones(1, 3, CV_32FC1), Mat::ones(1, 3, CV_32FC1), Mat::ones(3, 3, CV_32FC1), Mat(), dst);
cv::gpu::projectPoints(src, cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(1, 3, CV_32FC1), cv::Mat::ones(3, 3, CV_32FC1), cv::Mat(), dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// SolvePnPRansac
PERF_TEST_P(DevInfo, solvePnPRansac, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(SolvePnPRansac, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat object(1, 10000, CV_32FC3);
Mat image(1, 10000, CV_32FC2);
cv::Mat object(1, 10000, CV_32FC3);
cv::Mat image(1, 10000, CV_32FC2);
declare.in(object, image, WARMUP_RNG);
Mat rvec, tvec;
cv::Mat rvec, tvec;
declare.time(3.0);
TEST_CYCLE(100)
{
solvePnPRansac(object, image, Mat::ones(3, 3, CV_32FC1), Mat(1, 8, CV_32F, Scalar::all(0)), rvec, tvec);
cv::gpu::solvePnPRansac(object, image, cv::Mat::ones(3, 3, CV_32FC1), cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec);
}
SANITY_CHECK(rvec);
SANITY_CHECK(tvec);
}
PERF_TEST_P(DevInfo, StereoBM, testing::ValuesIn(devices()))
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// StereoBM
GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_l_host = readImage("gpu/perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_r_host = readImage("gpu/perf/aloeR.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
ASSERT_FALSE(img_r_host.empty());
GpuMat img_l(img_l_host);
GpuMat img_r(img_r_host);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
GpuMat dst;
StereoBM_GPU bm(0, 256);
cv::gpu::StereoBM_GPU bm(0, 256);
declare.time(5.0);
......@@ -95,30 +103,30 @@ PERF_TEST_P(DevInfo, StereoBM, testing::ValuesIn(devices()))
{
bm(img_l, img_r, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// StereoBeliefPropagation
PERF_TEST_P(DevInfo, StereoBeliefPropagation, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_l_host = readImage("gpu/stereobp/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_r_host = readImage("gpu/stereobp/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png");
cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png");
ASSERT_FALSE(img_l_host.empty());
ASSERT_FALSE(img_r_host.empty());
GpuMat img_l(img_l_host);
GpuMat img_r(img_r_host);
GpuMat dst;
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
StereoBeliefPropagation bp(128);
cv::gpu::StereoBeliefPropagation bp(64);
declare.time(10.0);
......@@ -126,30 +134,30 @@ PERF_TEST_P(DevInfo, StereoBeliefPropagation, testing::ValuesIn(devices()))
{
bp(img_l, img_r, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// StereoConstantSpaceBP
PERF_TEST_P(DevInfo, StereoConstantSpaceBP, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_l_host = readImage("gpu/stereocsbp/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_r_host = readImage("gpu/stereocsbp/aloeR.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
ASSERT_FALSE(img_r_host.empty());
GpuMat img_l(img_l_host);
GpuMat img_r(img_r_host);
GpuMat dst;
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
StereoConstantSpaceBP bp(128);
cv::gpu::StereoConstantSpaceBP bp(128);
declare.time(10.0);
......@@ -157,37 +165,38 @@ PERF_TEST_P(DevInfo, StereoConstantSpaceBP, testing::ValuesIn(devices()))
{
bp(img_l, img_r, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// DisparityBilateralFilter
PERF_TEST_P(DevInfo, DisparityBilateralFilter, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(DisparityBilateralFilter, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_host = readImage("gpu/stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
cv::Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
ASSERT_FALSE(disp_host.empty());
GpuMat img(img_host);
GpuMat disp(disp_host);
GpuMat dst;
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat disp(disp_host);
cv::gpu::GpuMat dst;
DisparityBilateralFilter f(128);
cv::gpu::DisparityBilateralFilter f(128);
TEST_CYCLE(100)
{
f(disp, img, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Calib3D, DisparityBilateralFilter, ALL_DEVICES);
#endif
SANITY_CHECK(dst_host);
}
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo_DescSize, BruteForceMatcher_match, testing::Combine(testing::ValuesIn(devices()),
testing::Values(64, 128, 256)))
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_match
GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
int desc_size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
int desc_size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat query_host(3000, desc_size, CV_32FC1);
Mat train_host(3000, desc_size, CV_32FC1);
cv::Mat query_host(3000, desc_size, CV_32FC1);
cv::Mat train_host(3000, desc_size, CV_32FC1);
declare.in(query_host, train_host, WARMUP_RNG);
GpuMat query(query_host);
GpuMat train(train_host);
GpuMat trainIdx, distance;
cv::gpu::GpuMat query(query_host);
cv::gpu::GpuMat train(train_host);
cv::gpu::GpuMat trainIdx, distance;
BruteForceMatcher_GPU< L2<float> > matcher;
cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher;
declare.time(3.0);
......@@ -25,34 +29,33 @@ PERF_TEST_P(DevInfo_DescSize, BruteForceMatcher_match, testing::Combine(testing:
{
matcher.matchSingle(query, train, trainIdx, distance);
}
}
Mat trainIdx_host(trainIdx);
Mat distance_host(distance);
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine(
ALL_DEVICES,
testing::Values(64, 128, 256)));
SANITY_CHECK(trainIdx_host);
SANITY_CHECK(distance_host);
}
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_knnMatch
PERF_TEST_P(DevInfo_K_DescSize, BruteForceMatcher_knnMatch, testing::Combine(testing::ValuesIn(devices()),
testing::Values(2, 3),
testing::Values(64, 128, 256)))
GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, int, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
int k = std::tr1::get<1>(GetParam());
int desc_size = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
int desc_size = GET_PARAM(1);
int k = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat query_host(3000, desc_size, CV_32FC1);
Mat train_host(3000, desc_size, CV_32FC1);
cv::Mat query_host(3000, desc_size, CV_32FC1);
cv::Mat train_host(3000, desc_size, CV_32FC1);
declare.in(query_host, train_host, WARMUP_RNG);
GpuMat query(query_host);
GpuMat train(train_host);
GpuMat trainIdx, distance, allDist;
cv::gpu::GpuMat query(query_host);
cv::gpu::GpuMat train(train_host);
cv::gpu::GpuMat trainIdx, distance, allDist;
BruteForceMatcher_GPU< L2<float> > matcher;
cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher;
declare.time(3.0);
......@@ -60,30 +63,34 @@ PERF_TEST_P(DevInfo_K_DescSize, BruteForceMatcher_knnMatch, testing::Combine(tes
{
matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k);
}
}
Mat trainIdx_host(trainIdx);
Mat distance_host(distance);
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine(
ALL_DEVICES,
testing::Values(64, 128, 256),
testing::Values(2, 3)));
SANITY_CHECK(trainIdx_host);
SANITY_CHECK(distance_host);
}
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_radiusMatch
PERF_TEST_P(DevInfo_DescSize, BruteForceMatcher_radiusMatch, testing::Combine(testing::ValuesIn(devices(SHARED_ATOMICS)),
testing::Values(64, 128, 256)))
GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
int desc_size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
int desc_size = GET_PARAM(1);
cv::gpu::setDevice(devInfo.deviceID());
setDevice(devInfo.deviceID());
cv::Mat query_host(3000, desc_size, CV_32FC1);
cv::Mat train_host(3000, desc_size, CV_32FC1);
Mat query_host = cvtest::randomMat(theRNG(), Size(desc_size, 3000), CV_32FC1, 0, 1, false);
Mat train_host = cvtest::randomMat(theRNG(), Size(desc_size, 3000), CV_32FC1, 0, 1, false);
fill(query_host, 0, 1);
fill(train_host, 0, 1);
GpuMat query(query_host);
GpuMat train(train_host);
GpuMat trainIdx, nMatches, distance;
cv::gpu::GpuMat query(query_host);
cv::gpu::GpuMat train(train_host);
cv::gpu::GpuMat trainIdx, nMatches, distance;
BruteForceMatcher_GPU< L2<float> > matcher;
cv::gpu::BruteForceMatcher_GPU< cv::L2<float> > matcher;
declare.time(3.0);
......@@ -91,81 +98,90 @@ PERF_TEST_P(DevInfo_DescSize, BruteForceMatcher_radiusMatch, testing::Combine(te
{
matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0);
}
}
Mat trainIdx_host(trainIdx);
Mat nMatches_host(nMatches);
Mat distance_host(distance);
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine(
ALL_DEVICES,
testing::Values(64, 128, 256)));
SANITY_CHECK(trainIdx_host);
SANITY_CHECK(nMatches_host);
SANITY_CHECK(distance_host);
}
//////////////////////////////////////////////////////////////////////
// SURF
PERF_TEST_P(DevInfo, SURF, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_host = readImage("gpu/perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
GpuMat img(img_host);
GpuMat keypoints, descriptors;
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat keypoints, descriptors;
SURF_GPU surf;
cv::gpu::SURF_GPU surf;
declare.time(2.0);
TEST_CYCLE(100)
{
surf(img, GpuMat(), keypoints, descriptors);
surf(img, cv::gpu::GpuMat(), keypoints, descriptors);
}
}
PERF_TEST_P(DevInfo, FAST, testing::ValuesIn(devices()))
INSTANTIATE_TEST_CASE_P(Features2D, SURF, DEVICES(cv::gpu::GLOBAL_ATOMICS));
//////////////////////////////////////////////////////////////////////
// FAST
GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_host = readImage("gpu/perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
GpuMat img(img_host);
GpuMat keypoints;
FAST_GPU fastGPU(20);
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat keypoints, descriptors;
declare.time(2.0);
cv::gpu::FAST_GPU fastGPU(20);
TEST_CYCLE(100)
{
fastGPU(img, GpuMat(), keypoints);
fastGPU(img, cv::gpu::GpuMat(), keypoints);
}
}
PERF_TEST_P(DevInfo, ORB, testing::ValuesIn(devices()))
INSTANTIATE_TEST_CASE_P(Features2D, FAST, DEVICES(cv::gpu::GLOBAL_ATOMICS));
//////////////////////////////////////////////////////////////////////
// ORB
GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_host = readImage("gpu/perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
GpuMat img(img_host);
GpuMat keypoints, descriptors;
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat keypoints, descriptors;
ORB_GPU orbGPU(4000);
declare.time(2.0);
cv::gpu::ORB_GPU orbGPU(4000);
TEST_CYCLE(100)
{
orbGPU(img, GpuMat(), keypoints, descriptors);
orbGPU(img, cv::gpu::GpuMat(), keypoints, descriptors);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, ORB, DEVICES(cv::gpu::GLOBAL_ATOMICS));
#endif
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo_Size_MatType_KernelSize, boxFilter, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4),
testing::Values(3, 5)))
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// BoxFilter
GPU_PERF_TEST(BoxFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int ksize = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
Ptr<FilterEngine_GPU> filter = createBoxFilter_GPU(type, type, Size(ksize, ksize));
cv::Ptr<cv::gpu::FilterEngine_GPU> filter = cv::gpu::createBoxFilter_GPU(type, type, cv::Size(ksize, ksize));
TEST_CYCLE(100)
{
filter->apply(src, dst);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
}
PERF_TEST_P(DevInfo_Size_MatType_MorphOp_KernelSize, morphologyFilter, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
INSTANTIATE_TEST_CASE_P(Filter, BoxFilter, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4),
testing::Values((int)MORPH_ERODE, (int)MORPH_DILATE),
testing::Values(3, 5)))
testing::Values(3, 5)));
//////////////////////////////////////////////////////////////////////
// MorphologyFilter
GPU_PERF_TEST(MorphologyFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, MorphOp, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int op = std::tr1::get<3>(GetParam());
int ksize = std::tr1::get<4>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int op = GET_PARAM(3);
int ksize = GET_PARAM(4);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
Ptr<FilterEngine_GPU> filter = createMorphologyFilter_GPU(op, type, Mat::ones(ksize, ksize, CV_8U));
cv::Ptr<cv::gpu::FilterEngine_GPU> filter = cv::gpu::createMorphologyFilter_GPU(op, type, cv::Mat::ones(ksize, ksize, CV_8U));
TEST_CYCLE(100)
{
filter->apply(src, dst);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
}
PERF_TEST_P(DevInfo_Size_MatType_KernelSize, linearFilter, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
INSTANTIATE_TEST_CASE_P(Filter, MorphologyFilter, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4),
testing::Values(3, 5)))
testing::Values((int) cv::MORPH_ERODE, (int) cv::MORPH_DILATE),
testing::Values(3, 5)));
//////////////////////////////////////////////////////////////////////
// LinearFilter
GPU_PERF_TEST(LinearFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int ksize = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
Ptr<FilterEngine_GPU> filter = createLinearFilter_GPU(type, type, Mat::ones(ksize, ksize, CV_8U));
cv::Ptr<cv::gpu::FilterEngine_GPU> filter = cv::gpu::createLinearFilter_GPU(type, type, cv::Mat::ones(ksize, ksize, CV_8U));
declare.time(1.0);
......@@ -91,42 +97,48 @@ PERF_TEST_P(DevInfo_Size_MatType_KernelSize, linearFilter, testing::Combine(test
{
filter->apply(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Filter, LinearFilter, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4),
testing::Values(3, 5)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// SeparableLinearFilter
PERF_TEST_P(DevInfo_Size_MatType_KernelSize, separableLinearFilter, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values(3, 5)))
GPU_PERF_TEST(SeparableLinearFilter, cv::gpu::DeviceInfo, cv::Size, perf::MatType, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int ksize = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
Mat kernel = getGaussianKernel(ksize, 0.5, CV_32F);
Ptr<FilterEngine_GPU> filter = createSeparableLinearFilter_GPU(type, type, kernel, kernel, Point(-1,-1));
cv::Mat kernel = cv::getGaussianKernel(ksize, 0.5, CV_32F);
cv::Ptr<cv::gpu::FilterEngine_GPU> filter = cv::gpu::createSeparableLinearFilter_GPU(type, type, kernel, kernel);
declare.time(1.0);
TEST_CYCLE(100)
{
filter->apply(src, dst, Rect(0, 0, src.cols, src.rows));
filter->apply(src, dst, cv::Rect(0, 0, src.cols, src.rows));
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(Filter, SeparableLinearFilter, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values(3, 5)));
SANITY_CHECK(dst_host);
}
#endif
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo_Size_MatType_Interpolation_BorderMode, remap, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),
testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC),
testing::Values((int)BORDER_REFLECT101, (int)BORDER_REPLICATE, (int)BORDER_CONSTANT)))
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int interpolation = std::tr1::get<3>(GetParam());
int borderMode = std::tr1::get<4>(GetParam());
#ifdef HAVE_CUDA
setDevice(devInfo.deviceID());
//////////////////////////////////////////////////////////////////////
// Remap
Mat src_host(size, type);
GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation, BorderMode)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
declare.in(src_host, WARMUP_RNG);
cv::gpu::setDevice(devInfo.deviceID());
GpuMat src(src_host);
GpuMat dst(size, type);
cv::Mat src_host(size, type);
cv::Mat xmap_host(size, CV_32FC1);
cv::Mat ymap_host(size, CV_32FC1);
Mat xmap_host(size, CV_32FC1);
Mat ymap_host(size, CV_32FC1);
randu(xmap_host, -300, size.width + 300);
randu(ymap_host, -300, size.height + 300);
declare.in(src_host, xmap_host, ymap_host, WARMUP_RNG);
GpuMat xmap(xmap_host);
GpuMat ymap(ymap_host);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat xmap(xmap_host);
cv::gpu::GpuMat ymap(ymap_host);
cv::gpu::GpuMat dst;
declare.time(3.0);
TEST_CYCLE(100)
{
remap(src, dst, xmap, ymap, interpolation, borderMode);
cv::gpu::remap(src, dst, xmap, ymap, interpolation, borderMode);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC),
testing::Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_CONSTANT)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// MeanShiftFiltering
PERF_TEST_P(DevInfo, meanShiftFiltering, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img = readImage("gpu/meanshift/cones.png");
cv::Mat img = readImage("gpu/meanshift/cones.png");
ASSERT_FALSE(img.empty());
Mat rgba;
cvtColor(img, rgba, CV_BGR2BGRA);
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
GpuMat src(rgba);
GpuMat dst(src.size(), CV_8UC4);
cv::gpu::GpuMat src(rgba);
cv::gpu::GpuMat dst;
declare.time(5.0);
TEST_CYCLE(100)
{
meanShiftFiltering(src, dst, 50, 50);
cv::gpu::meanShiftFiltering(src, dst, 50, 50);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// MeanShiftProc
PERF_TEST_P(DevInfo, meanShiftProc, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(MeanShiftProc, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img = readImage("gpu/meanshift/cones.png");
cv::Mat img = readImage("gpu/meanshift/cones.png");
ASSERT_FALSE(img.empty());
Mat rgba;
cvtColor(img, rgba, CV_BGR2BGRA);
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
GpuMat src(rgba);
GpuMat dstr(src.size(), CV_8UC4);
GpuMat dstsp(src.size(), CV_16SC2);
cv::gpu::GpuMat src(rgba);
cv::gpu::GpuMat dstr;
cv::gpu::GpuMat dstsp;
declare.time(5.0);
TEST_CYCLE(100)
{
meanShiftProc(src, dstr, dstsp, 50, 50);
cv::gpu::meanShiftProc(src, dstr, dstsp, 50, 50);
}
}
Mat dstr_host(dstr);
Mat dstsp_host(dstsp);
INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftProc, ALL_DEVICES);
SANITY_CHECK(dstr_host);
SANITY_CHECK(dstsp_host);
}
//////////////////////////////////////////////////////////////////////
// MeanShiftSegmentation
PERF_TEST_P(DevInfo, meanShiftSegmentation, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(MeanShiftSegmentation, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img = readImage("gpu/meanshift/cones.png");
cv::Mat img = readImage("gpu/meanshift/cones.png");
ASSERT_FALSE(img.empty());
Mat rgba;
cvtColor(img, rgba, CV_BGR2BGRA);
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
GpuMat src(rgba);
Mat dst(src.size(), CV_8UC4);
cv::gpu::GpuMat src(rgba);
cv::Mat dst;
declare.time(5.0);
......@@ -119,476 +122,503 @@ PERF_TEST_P(DevInfo, meanShiftSegmentation, testing::ValuesIn(devices()))
{
meanShiftSegmentation(src, dst, 10, 10, 20);
}
SANITY_CHECK(dst);
}
PERF_TEST_P(DevInfo_Size_MatType, drawColorDisp, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16SC1)))
INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// DrawColorDisp
GPU_PERF_TEST(DrawColorDisp, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
src_host.convertTo(src_host, type);
cv::Mat src_host(size, type);
fill(src_host, 0, 255);
GpuMat src(src_host);
GpuMat dst(size, CV_8UC4);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
drawColorDisp(src, dst, 255);
cv::gpu::drawColorDisp(src, dst, 255);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, DrawColorDisp, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16SC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// ReprojectImageTo3D
PERF_TEST_P(DevInfo_Size_MatType, reprojectImageTo3D, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16SC1)))
GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, CV_32FC4);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
reprojectImageTo3D(src, dst, Mat::ones(4, 4, CV_32FC1));
cv::gpu::reprojectImageTo3D(src, dst, cv::Mat::ones(4, 4, CV_32FC1));
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16SC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// CvtColor
PERF_TEST_P(DevInfo_Size_MatType_CvtColorInfo, cvtColor, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
testing::Values(CvtColorInfo(4, 4, CV_RGBA2BGRA), CvtColorInfo(4, 1, CV_BGRA2GRAY), CvtColorInfo(1, 4, CV_GRAY2BGRA),
CvtColorInfo(4, 4, CV_BGR2XYZ), CvtColorInfo(4, 4, CV_BGR2YCrCb), CvtColorInfo(4, 4, CV_YCrCb2BGR),
CvtColorInfo(4, 4, CV_BGR2HSV), CvtColorInfo(4, 4, CV_HSV2BGR))))
GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, perf::MatType, CvtColorInfo)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
CvtColorInfo info = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
CvtColorInfo info = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_MAKETYPE(type, info.scn));
cv::Mat src_host(size, CV_MAKETYPE(type, info.scn));
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, CV_MAKETYPE(type, info.dcn));
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst(size, CV_MAKETYPE(type, info.dcn));
TEST_CYCLE(100)
{
cvtColor(src, dst, info.code, info.dcn);
cv::gpu::cvtColor(src, dst, info.code, info.dcn);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
testing::Values(
CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),
CvtColorInfo(4, 4, cv::COLOR_BGR2XYZ), CvtColorInfo(4, 4, cv::COLOR_BGR2YCrCb), CvtColorInfo(4, 4, cv::COLOR_YCrCb2BGR),
CvtColorInfo(4, 4, cv::COLOR_BGR2HSV), CvtColorInfo(4, 4, cv::COLOR_HSV2BGR))));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Threshold
PERF_TEST_P(DevInfo_Size_MatType, threshold, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst(size, type);
TEST_CYCLE(100)
{
threshold(src, dst, 100.0, 255.0, THRESH_BINARY);
cv::gpu::threshold(src, dst, 100.0, 255.0, cv::THRESH_BINARY);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Resize
PERF_TEST_P(DevInfo_Size_MatType_Interpolation_SizeCoeff, resize, testing::Combine(testing::ValuesIn(devices()),
testing::Values(szSXGA, sz1080p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),
testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC),
testing::Values(0.5, 2.0)))
GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation, double)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int interpolation = std::tr1::get<3>(GetParam());
double f = std::tr1::get<4>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
double f = GET_PARAM(4);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
declare.time(1.0);
TEST_CYCLE(100)
{
resize(src, dst, Size(), f, f, interpolation);
cv::gpu::resize(src, dst, cv::Size(), f, f, interpolation);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine(
ALL_DEVICES,
testing::Values(perf::szSXGA, perf::sz1080p),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC),
testing::Values(0.5, 2.0)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// WarpAffine
PERF_TEST_P(DevInfo_Size_MatType_Interpolation, warpAffine, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC)))
GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int interpolation = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
static double reflect[2][3] = { {-1, 0, 0},
double reflect[2][3] = { {-1, 0, 0},
{ 0, -1, 0}};
reflect[0][2] = size.width;
reflect[1][2] = size.height;
Mat M(2, 3, CV_64F, (void*)reflect);
cv::Mat M(2, 3, CV_64F, (void*) reflect);
TEST_CYCLE(100)
{
warpAffine(src, dst, M, size, interpolation);
cv::gpu::warpAffine(src, dst, M, size, interpolation);
}
Mat dst_host(dst);
SANITY_CHECK(dst_host);
}
PERF_TEST_P(DevInfo_Size_MatType_Interpolation, warpPerspective, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC)))
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC)));
//////////////////////////////////////////////////////////////////////
// WarpPerspective
GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int interpolation = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
static double reflect[3][3] = { {-1, 0, 0},
double reflect[3][3] = { {-1, 0, 0},
{ 0, -1, 0},
{ 0, 0, 1}};
reflect[0][2] = size.width;
reflect[1][2] = size.height;
Mat M(3, 3, CV_64F, (void*)reflect);
cv::Mat M(3, 3, CV_64F, (void*)reflect);
TEST_CYCLE(100)
{
warpPerspective(src, dst, M, size, interpolation);
cv::gpu::warpPerspective(src, dst, M, size, interpolation);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// BuildWarpPlaneMaps
PERF_TEST_P(DevInfo_Size, buildWarpPlaneMaps, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(BuildWarpPlaneMaps, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
GpuMat map_x(size, CV_32FC1);
GpuMat map_y(size, CV_32FC1);
cv::gpu::GpuMat map_x;
cv::gpu::GpuMat map_y;
TEST_CYCLE(100)
{
buildWarpPlaneMaps(size, Rect(0, 0, size.width, size.height), Mat::eye(3, 3, CV_32FC1),
Mat::ones(3, 3, CV_32FC1), Mat::zeros(1, 3, CV_32F), 1.0, map_x, map_y);
cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1),
cv::Mat::ones(3, 3, CV_32FC1), cv::Mat::zeros(1, 3, CV_32F), 1.0, map_x, map_y);
}
}
Mat map_x_host(map_x);
Mat map_y_host(map_y);
INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpPlaneMaps, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(map_x_host);
SANITY_CHECK(map_y_host);
}
//////////////////////////////////////////////////////////////////////
// BuildWarpCylindricalMaps
PERF_TEST_P(DevInfo_Size, buildWarpCylindricalMaps, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(BuildWarpCylindricalMaps, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
GpuMat map_x(size, CV_32FC1);
GpuMat map_y(size, CV_32FC1);
cv::gpu::GpuMat map_x;
cv::gpu::GpuMat map_y;
TEST_CYCLE(100)
{
buildWarpCylindricalMaps(size, Rect(0, 0, size.width, size.height), Mat::eye(3, 3, CV_32FC1),
Mat::ones(3, 3, CV_32FC1), 1.0, map_x, map_y);
cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1),
cv::Mat::ones(3, 3, CV_32FC1), 1.0, map_x, map_y);
}
}
Mat map_x_host(map_x);
Mat map_y_host(map_y);
INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpCylindricalMaps, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(map_x_host);
SANITY_CHECK(map_y_host);
}
//////////////////////////////////////////////////////////////////////
// BuildWarpSphericalMaps
PERF_TEST_P(DevInfo_Size, buildWarpSphericalMaps, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(BuildWarpSphericalMaps, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
GpuMat map_x(size, CV_32FC1);
GpuMat map_y(size, CV_32FC1);
cv::gpu::GpuMat map_x;
cv::gpu::GpuMat map_y;
TEST_CYCLE(100)
{
buildWarpSphericalMaps(size, Rect(0, 0, size.width, size.height), Mat::eye(3, 3, CV_32FC1),
Mat::ones(3, 3, CV_32FC1), 1.0, map_x, map_y);
cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1),
cv::Mat::ones(3, 3, CV_32FC1), 1.0, map_x, map_y);
}
}
Mat map_x_host(map_x);
Mat map_y_host(map_y);
INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpSphericalMaps, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(map_x_host);
SANITY_CHECK(map_y_host);
}
//////////////////////////////////////////////////////////////////////
// Rotate
PERF_TEST_P(DevInfo_Size_MatType_Interpolation, rotate, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4),
testing::Values((int)INTER_NEAREST, (int)INTER_LINEAR, (int)INTER_CUBIC)))
GPU_PERF_TEST(Rotate, cv::gpu::DeviceInfo, cv::Size, perf::MatType, Interpolation)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int interpolation = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
rotate(src, dst, size, 30.0, 0, 0, interpolation);
cv::gpu::rotate(src, dst, size, 30.0, 0, 0, interpolation);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Rotate, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4),
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// CopyMakeBorder
PERF_TEST_P(DevInfo_Size_MatType_BorderMode, copyMakeBorder, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values((int)BORDER_REPLICATE, (int)BORDER_CONSTANT)))
GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, perf::MatType, BorderMode)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
int borderType = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int borderType = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
copyMakeBorder(src, dst, 5, 5, 5, 5, borderType);
cv::gpu::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),
testing::Values((int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT, (int) cv::BORDER_WRAP, (int) cv::BORDER_CONSTANT)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Integral
PERF_TEST_P(DevInfo_Size, integralBuffered, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
cv::Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
GpuMat buf;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
integralBuffered(src, dst, buf);
cv::gpu::integralBuffered(src, dst, buf);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// IntegralBoth
PERF_TEST_P(DevInfo_Size, integral, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(IntegralBoth, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
cv::Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat sum, sqsum;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat sum, sqsum;
TEST_CYCLE(100)
{
integral(src, sum, sqsum);
cv::gpu::integral(src, sum, sqsum);
}
}
Mat sum_host(sum);
Mat sqsum_host(sqsum);
INSTANTIATE_TEST_CASE_P(ImgProc, IntegralBoth, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(sum_host);
SANITY_CHECK(sqsum_host);
}
//////////////////////////////////////////////////////////////////////
// IntegralSqr
PERF_TEST_P(DevInfo_Size, sqrIntegral, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(IntegralSqr, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
cv::Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
sqrIntegral(src, dst);
cv::gpu::sqrIntegral(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, IntegralSqr, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// ColumnSum
PERF_TEST_P(DevInfo_Size, columnSum, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(ColumnSum, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_32FC1);
cv::Mat src_host(size, CV_32FC1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
columnSum(src, dst);
cv::gpu::columnSum(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// CornerHarris
PERF_TEST_P(DevInfo_MatType, cornerHarris, testing::Combine(testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_32FC1)))
GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
int type = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
int type = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img = readImage("gpu/stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
GpuMat src(img);
GpuMat dst;
GpuMat Dx;
GpuMat Dy;
cv::gpu::GpuMat src(img);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat Dx;
cv::gpu::GpuMat Dy;
int blockSize = 3;
int ksize = 7;
......@@ -596,297 +626,366 @@ PERF_TEST_P(DevInfo_MatType, cornerHarris, testing::Combine(testing::ValuesIn(de
TEST_CYCLE(100)
{
cornerHarris(src, dst, Dx, Dy, blockSize, ksize, k);
cv::gpu::cornerHarris(src, dst, Dx, Dy, blockSize, ksize, k);
}
}
Mat dst_host(dst);
Mat Dx_host(Dx);
Mat Dy_host(Dy);
INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine(
ALL_DEVICES,
testing::Values(CV_8UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
SANITY_CHECK(Dx_host);
SANITY_CHECK(Dy_host);
}
//////////////////////////////////////////////////////////////////////
// CornerMinEigenVal
PERF_TEST_P(DevInfo_MatType, cornerMinEigenVal, testing::Combine(testing::ValuesIn(devices()),
testing::Values(CV_8UC1, CV_32FC1)))
GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
int type = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
int type = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img = readImage("gpu/stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
GpuMat src(img);
GpuMat dst;
GpuMat Dx;
GpuMat Dy;
cv::gpu::GpuMat src(img);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat Dx;
cv::gpu::GpuMat Dy;
int blockSize = 3;
int ksize = 7;
TEST_CYCLE(100)
{
cornerMinEigenVal(src, dst, Dx, Dy, blockSize, ksize);
cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, blockSize, ksize);
}
}
Mat dst_host(dst);
Mat Dx_host(Dx);
Mat Dy_host(Dy);
INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine(
ALL_DEVICES,
testing::Values(CV_8UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
SANITY_CHECK(Dx_host);
SANITY_CHECK(Dy_host);
}
//////////////////////////////////////////////////////////////////////
// MulSpectrums
PERF_TEST_P(DevInfo_Size_MatType, mulSpectrums, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_32FC1)))
GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat a_host(size, CV_32FC2);
Mat b_host(size, CV_32FC2);
cv::Mat a_host(size, CV_32FC2);
cv::Mat b_host(size, CV_32FC2);
declare.in(a_host, b_host, WARMUP_RNG);
GpuMat a(a_host);
GpuMat b(b_host);
GpuMat dst;
cv::gpu::GpuMat a(a_host);
cv::gpu::GpuMat b(b_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
mulSpectrums(a, b, dst, 0);
cv::gpu::mulSpectrums(a, b, dst, 0);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Dft
PERF_TEST_P(DevInfo_Size, dft, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_32FC2);
cv::Mat src_host(size, CV_32FC2);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
declare.time(2.0);
TEST_CYCLE(100)
{
dft(src, dst, size);
cv::gpu::dft(src, dst, size);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Convolve
PERF_TEST_P(DevInfo_Int_Int, convolve, testing::Combine(testing::ValuesIn(devices()),
testing::Values(512, 1024, 1536, 2048, 2560, 3072, 3584),
testing::Values(3, 9, 27, 32, 64)))
GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, int)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
int image_size = std::tr1::get<1>(GetParam());
int templ_size = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int templ_size = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
GpuMat image = createContinuous(image_size, image_size, CV_32FC1);
GpuMat templ = createContinuous(templ_size, templ_size, CV_32FC1);
cv::gpu::GpuMat image = cv::gpu::createContinuous(size, CV_32FC1);
cv::gpu::GpuMat templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1);
image.setTo(Scalar(1.0));
templ.setTo(Scalar(1.0));
image.setTo(cv::Scalar(1.0));
templ.setTo(cv::Scalar(1.0));
GpuMat dst;
ConvolveBuf buf;
cv::gpu::GpuMat dst;
cv::gpu::ConvolveBuf buf;
declare.time(2.0);
TEST_CYCLE(100)
{
convolve(image, templ, dst, false, buf);
cv::gpu::convolve(image, templ, dst, false, buf);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(3, 9, 27, 32, 64)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// PyrDown
PERF_TEST_P(DevInfo_Size_MatType, pyrDown, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)))
GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
pyrDown(src, dst);
cv::gpu::pyrDown(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// PyrUp
PERF_TEST_P(DevInfo_Size_MatType, pyrUp, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)))
GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
pyrUp(src, dst);
cv::gpu::pyrUp(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// BlendLinear
PERF_TEST_P(DevInfo_Size_MatType, blendLinear, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_32FC1)))
GPU_PERF_TEST(BlendLinear, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img1_host(size, type);
Mat img2_host(size, type);
cv::Mat img1_host(size, type);
cv::Mat img2_host(size, type);
declare.in(img1_host, img2_host, WARMUP_RNG);
GpuMat img1(img1_host);
GpuMat img2(img2_host);
GpuMat weights1(size, CV_32FC1, Scalar::all(0.5));
GpuMat weights2(size, CV_32FC1, Scalar::all(0.5));
GpuMat dst;
cv::gpu::GpuMat img1(img1_host);
cv::gpu::GpuMat img2(img2_host);
cv::gpu::GpuMat weights1(size, CV_32FC1, cv::Scalar::all(0.5));
cv::gpu::GpuMat weights2(size, CV_32FC1, cv::Scalar::all(0.5));
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
blendLinear(img1, img2, weights1, weights2, dst);
cv::gpu::blendLinear(img1, img2, weights1, weights2, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, BlendLinear, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Canny
PERF_TEST_P(DevInfo, Canny, testing::ValuesIn(devices()))
GPU_PERF_TEST_1(Canny, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat image_host = readImage("gpu/perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat image_host = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(image_host.empty());
GpuMat image(image_host);
GpuMat dst;
CannyBuf buf;
cv::gpu::GpuMat image(image_host);
cv::gpu::GpuMat dst;
cv::gpu::CannyBuf buf;
TEST_CYCLE(100)
{
Canny(image, buf, dst, 50.0, 100.0);
cv::gpu::Canny(image, buf, dst, 50.0, 100.0);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, Canny, ALL_DEVICES);
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// CalcHist
PERF_TEST_P(DevInfo_Size, calcHist, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
GPU_PERF_TEST(CalcHist, cv::gpu::DeviceInfo, cv::Size)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
cv::Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat hist;
GpuMat buf;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat hist;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
calcHist(src, hist, buf);
cv::gpu::calcHist(src, hist, buf);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
Mat hist_host(hist);
//////////////////////////////////////////////////////////////////////
// EqualizeHist
SANITY_CHECK(hist_host);
GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat src_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat hist;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
cv::gpu::equalizeHist(src, dst, hist, buf);
}
}
PERF_TEST_P(DevInfo_Size, equalizeHist, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES)))
INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
//////////////////////////////////////////////////////////////////////
// ImagePyramid
GPU_PERF_TEST(ImagePyramid_build, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, CV_8UC1);
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst;
GpuMat hist;
GpuMat buf;
cv::gpu::GpuMat src(src_host);
cv::gpu::ImagePyramid pyr;
TEST_CYCLE(100)
{
equalizeHist(src, dst, hist, buf);
pyr.build(src, 5);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_build, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
SANITY_CHECK(dst_host);
GPU_PERF_TEST(ImagePyramid_getLayer, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat src_host(size, type);
declare.in(src_host, WARMUP_RNG);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::ImagePyramid pyr(src, 3);
TEST_CYCLE(100)
{
pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10));
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_getLayer, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
#endif
......@@ -5,8 +5,7 @@
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
Regression::Init("gpu");
TestBase::Init(argc, argv);
perf::TestBase::Init(argc, argv);
return RUN_ALL_TESTS();
}
......
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo_Size_MatType, merge, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// Merge
GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
const int num_channels = 4;
vector<GpuMat> src(num_channels);
std::vector<cv::gpu::GpuMat> src(num_channels);
for (int i = 0; i < num_channels; ++i)
src[i] = GpuMat(size, type, cv::Scalar::all(i));
src[i] = cv::gpu::GpuMat(size, type, cv::Scalar::all(i));
GpuMat dst(size, CV_MAKETYPE(type, num_channels));
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
merge(src, dst);
cv::gpu::merge(src, dst);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(MatOp, Merge, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// Split
PERF_TEST_P(DevInfo_Size_MatType, split, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
const int num_channels = 4;
GpuMat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4));
cv::gpu::GpuMat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4));
vector<GpuMat> dst(num_channels);
std::vector<cv::gpu::GpuMat> dst(num_channels);
for (int i = 0; i < num_channels; ++i)
dst[i] = GpuMat(size, type);
dst[i] = cv::gpu::GpuMat(size, type);
TEST_CYCLE(100)
{
split(src, dst);
cv::gpu::split(src, dst);
}
}
vector<Mat> dst_host(dst.size());
for (size_t i = 0; i < dst.size(); ++i)
dst[i].download(dst_host[i]);
INSTANTIATE_TEST_CASE_P(MatOp, Split, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// SetTo
PERF_TEST_P(DevInfo_Size_MatType, setTo, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1)))
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
GpuMat src(size, type);
Scalar val(1, 2, 3, 4);
cv::gpu::GpuMat src(size, type);
cv::Scalar val(1, 2, 3, 4);
TEST_CYCLE(100)
{
src.setTo(val);
}
}
Mat src_host(src);
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
SANITY_CHECK(src_host);
}
//////////////////////////////////////////////////////////////////////
// SetToMasked
PERF_TEST_P(DevInfo_Size_MatType, setToMasked, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1)))
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
cv::Mat mask_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
fill(mask_host, 0, 2);
GpuMat src(src_host);
Scalar val(1, 2, 3, 4);
Mat mask_host(size, CV_8UC1);
randu(mask_host, 0.0, 2.0);
GpuMat mask(mask_host);
cv::gpu::GpuMat src(src_host);
cv::Scalar val(1, 2, 3, 4);
cv::gpu::GpuMat mask(mask_host);
TEST_CYCLE(100)
{
src.setTo(val, mask);
}
}
src.download(src_host);
INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
SANITY_CHECK(src_host);
}
//////////////////////////////////////////////////////////////////////
// CopyToMasked
PERF_TEST_P(DevInfo_Size_MatType, copyToMasked, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1)))
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type = std::tr1::get<2>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type);
cv::Mat src_host(size, type);
cv::Mat mask_host(size, CV_8UC1);
declare.in(src_host, WARMUP_RNG);
fill(mask_host, 0, 2);
GpuMat src(src_host);
GpuMat dst(size, type);
Mat mask_host(size, CV_8UC1);
randu(mask_host, 0.0, 2.0);
GpuMat mask(mask_host);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat mask(mask_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
src.copyTo(dst, mask);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
SANITY_CHECK(dst_host);
}
//////////////////////////////////////////////////////////////////////
// ConvertTo
PERF_TEST_P(DevInfo_Size_MatType_MatType, convertTo, testing::Combine(testing::ValuesIn(devices()),
testing::Values(GPU_TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)))
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType, perf::MatType)
{
DeviceInfo devInfo = std::tr1::get<0>(GetParam());
Size size = std::tr1::get<1>(GetParam());
int type1 = std::tr1::get<2>(GetParam());
int type2 = std::tr1::get<3>(GetParam());
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::Size size = GET_PARAM(1);
int type1 = GET_PARAM(2);
int type2 = GET_PARAM(3);
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat src_host(size, type1);
cv::Mat src_host(size, type1);
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
GpuMat dst(size, type2);
double a = 0.5;
double b = 1.0;
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
TEST_CYCLE(100)
{
src.convertTo(dst, type2, a, b);
src.convertTo(dst, type2, 0.5, 1.0);
}
}
Mat dst_host(dst);
INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
SANITY_CHECK(dst_host);
}
#endif
#include "perf_precomp.hpp"
PERF_TEST_P(DevInfo, HOGDescriptor, testing::ValuesIn(devices()))
#ifdef HAVE_CUDA
GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo)
{
DeviceInfo devInfo = GetParam();
cv::gpu::DeviceInfo devInfo = GetParam();
setDevice(devInfo.deviceID());
cv::gpu::setDevice(devInfo.deviceID());
Mat img_host = readImage("gpu/hog/road.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat img_host = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE);
GpuMat img(img_host);
vector<Rect> found_locations;
cv::gpu::GpuMat img(img_host);
std::vector<cv::Rect> found_locations;
gpu::HOGDescriptor hog;
hog.setSVMDetector(gpu::HOGDescriptor::getDefaultPeopleDetector());
cv::gpu::HOGDescriptor hog;
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
TEST_CYCLE(100)
{
hog.detectMultiScale(img, found_locations);
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES);
#endif
......@@ -5,6 +5,7 @@
#include <iostream>
#include "cvconfig.h"
#include "opencv2/ts/ts.hpp"
#include "opencv2/ts/ts_perf.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
......
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
Mat readImage(const string& fileName, int flags)
{
return imread(::perf::TestBase::getDataPath(fileName), flags);
}
bool supportFeature(const DeviceInfo& info, FeatureSet feature)
{
return TargetArchs::builtWith(feature) && info.supports(feature);
}
const vector<DeviceInfo>& devices()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
}
vector<DeviceInfo> devices(FeatureSet feature)
{
const vector<DeviceInfo>& d = devices();
vector<DeviceInfo> devs_filtered;
if (TargetArchs::builtWith(feature))
{
devs_filtered.reserve(d.size());
for (size_t i = 0, size = d.size(); i < size; ++i)
{
const DeviceInfo& info = d[i];
if (info.supports(feature))
devs_filtered.push_back(info);
}
}
return devs_filtered;
}
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
void fill(Mat& m, double a, double b)
{
*os << info.name();
RNG rng(123456789);
rng.fill(m, RNG::UNIFORM, a, b);
}
void PrintTo(const CvtColorInfo& info, ::std::ostream* os)
void PrintTo(const CvtColorInfo& info, ostream* os)
{
static const char* str[] =
{
......@@ -190,3 +136,66 @@ void PrintTo(const CvtColorInfo& info, ::std::ostream* os)
*os << str[info.code];
}
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
{
*os << info.name();
}
Mat readImage(const string& fileName, int flags)
{
return imread(perf::TestBase::getDataPath(fileName), flags);
}
bool supportFeature(const DeviceInfo& info, FeatureSet feature)
{
return TargetArchs::builtWith(feature) && info.supports(feature);
}
const vector<DeviceInfo>& devices()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
}
vector<DeviceInfo> devices(FeatureSet feature)
{
const vector<DeviceInfo>& d = devices();
vector<DeviceInfo> devs_filtered;
if (TargetArchs::builtWith(feature))
{
devs_filtered.reserve(d.size());
for (size_t i = 0, size = d.size(); i < size; ++i)
{
const DeviceInfo& info = d[i];
if (info.supports(feature))
devs_filtered.push_back(info);
}
}
return devs_filtered;
}
#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__
#define __OPENCV_PERF_GPU_UTILITY_HPP__
#include <iosfwd>
#include "opencv2/ts/ts.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace perf;
void fill(cv::Mat& m, double a, double b);
enum {HORIZONTAL_AXIS = 0, VERTICAL_AXIS = 1, BOTH_AXIS = -1};
CV_ENUM(MorphOp, MORPH_ERODE, MORPH_DILATE)
CV_ENUM(BorderMode, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
CV_ENUM(MorphOp, cv::MORPH_ERODE, cv::MORPH_DILATE)
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
CV_ENUM(FlipCode, HORIZONTAL_AXIS, VERTICAL_AXIS, BOTH_AXIS)
CV_ENUM(CmpOp, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
CV_ENUM(MatchMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC)
CV_ENUM(MatchMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2)
struct CvtColorInfo
{
......@@ -30,53 +21,48 @@ struct CvtColorInfo
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
};
typedef TestBaseWithParam<DeviceInfo> DevInfo;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size> > DevInfo_Size;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, int, int> > DevInfo_Int_Int;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, MatType> > DevInfo_MatType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType> > DevInfo_Size_MatType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, MatType> > DevInfo_Size_MatType_MatType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, int> > DevInfo_Size_MatType_KernelSize;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, MorphOp, int> > DevInfo_Size_MatType_MorphOp_KernelSize;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, int, BorderMode> > DevInfo_Size_MatType_KernelSize_BorderMode;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, FlipCode> > DevInfo_Size_MatType_FlipCode;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, CmpOp> > DevInfo_Size_MatType_CmpOp;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, Interpolation> > DevInfo_Size_MatType_Interpolation;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, Interpolation, double> > DevInfo_Size_MatType_Interpolation_SizeCoeff;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, Interpolation, BorderMode> > DevInfo_Size_MatType_Interpolation_BorderMode;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, CvtColorInfo> > DevInfo_Size_MatType_CvtColorInfo;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, MatchMethod> > DevInfo_Size_MatType_MatchMethod;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, NormType> > DevInfo_Size_NormType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, NormType> > DevInfo_Size_MatType_NormType;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, int> > DevInfo_DescSize;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, int, int> > DevInfo_K_DescSize;
typedef TestBaseWithParam< std::tr1::tuple<DeviceInfo, Size, MatType, BorderMode> > DevInfo_Size_MatType_BorderMode;
const cv::Size sz1800x1500 = cv::Size(1800, 1500);
const cv::Size sz4700x3000 = cv::Size(4700, 3000);
//#define GPU_TYPICAL_MAT_SIZES szXGA, szSXGA, sz720p, sz1080p, sz1800x1500, sz4700x3000
#define GPU_TYPICAL_MAT_SIZES szSXGA, sz1080p, sz4700x3000
//! read image from testdata folder.
Mat readImage(const string& fileName, int flags = CV_LOAD_IMAGE_COLOR);
//! return true if device supports specified feature and gpu module was built with support the feature.
void PrintTo(const CvtColorInfo& info, std::ostream* os);
namespace cv { namespace gpu
{
void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os);
}}
#define GPU_PERF_TEST(name, ...) \
struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \
{ \
public: \
name() {} \
protected: \
void PerfTestBody(); \
}; \
TEST_P(name, perf){ RunPerfTestBody(); } \
void name :: PerfTestBody()
#define GPU_PERF_TEST_1(name, param_type) \
struct name : perf::TestBaseWithParam< param_type > \
{ \
public: \
name() {} \
protected: \
void PerfTestBody(); \
}; \
TEST_P(name, perf){ RunPerfTestBody(); } \
void name :: PerfTestBody()
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500))
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
//! return all devices compatible with current gpu module build.
const std::vector<cv::gpu::DeviceInfo>& devices();
//! return all devices compatible with current gpu module build which support specified feature.
std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature);
namespace cv
{
namespace gpu
{
void PrintTo(const DeviceInfo& info, ::std::ostream* os);
}
}
#define ALL_DEVICES testing::ValuesIn(devices())
#define DEVICES(feature) testing::ValuesIn(devices(feature))
void PrintTo(const CvtColorInfo& info, ::std::ostream* os);
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////
// BroxOpticalFlow
GPU_PERF_TEST_1(BroxOpticalFlow, cv::gpu::DeviceInfo)
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0_host.empty());
ASSERT_FALSE(frame1_host.empty());
frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0);
frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0);
cv::gpu::GpuMat frame0(frame0_host);
cv::gpu::GpuMat frame1(frame1_host);
cv::gpu::GpuMat u;
cv::gpu::GpuMat v;
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
declare.time(10);
TEST_CYCLE(100)
{
d_flow(frame0, frame1, u, v);
}
}
INSTANTIATE_TEST_CASE_P(Video, BroxOpticalFlow, ALL_DEVICES);
//////////////////////////////////////////////////////
// InterpolateFrames
GPU_PERF_TEST_1(InterpolateFrames, cv::gpu::DeviceInfo)
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0_host.empty());
ASSERT_FALSE(frame1_host.empty());
frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0);
frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0);
cv::gpu::GpuMat frame0(frame0_host);
cv::gpu::GpuMat frame1(frame1_host);
cv::gpu::GpuMat fu, fv;
cv::gpu::GpuMat bu, bv;
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(frame0, frame1, fu, fv);
d_flow(frame1, frame0, bu, bv);
cv::gpu::GpuMat newFrame;
cv::gpu::GpuMat buf;
TEST_CYCLE(100)
{
cv::gpu::interpolateFrames(frame0, frame1, fu, fv, bu, bv, 0.5f, newFrame, buf);
}
}
INSTANTIATE_TEST_CASE_P(Video, InterpolateFrames, ALL_DEVICES);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment