2011-09-07 15:16:07 +02:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
#ifdef HAVE_CUDA
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Merge
|
|
|
|
|
|
|
|
GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
cv::Size size = GET_PARAM(1);
|
|
|
|
int type = GET_PARAM(2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-07 15:16:07 +02:00
|
|
|
|
|
|
|
const int num_channels = 4;
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
std::vector<cv::gpu::GpuMat> src(num_channels);
|
2011-09-07 15:16:07 +02:00
|
|
|
for (int i = 0; i < num_channels; ++i)
|
2011-12-28 13:53:08 +01:00
|
|
|
src[i] = cv::gpu::GpuMat(size, type, cv::Scalar::all(i));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat dst;
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-11-15 08:03:44 +01:00
|
|
|
TEST_CYCLE(100)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::merge(src, dst);
|
2011-09-07 15:16:07 +02:00
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(MatOp, Merge, testing::Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
GPU_TYPICAL_MAT_SIZES,
|
|
|
|
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Split
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
cv::Size size = GET_PARAM(1);
|
|
|
|
int type = GET_PARAM(2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-07 15:16:07 +02:00
|
|
|
|
|
|
|
const int num_channels = 4;
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
std::vector<cv::gpu::GpuMat> dst(num_channels);
|
2011-09-07 15:16:07 +02:00
|
|
|
for (int i = 0; i < num_channels; ++i)
|
2011-12-28 13:53:08 +01:00
|
|
|
dst[i] = cv::gpu::GpuMat(size, type);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-11-15 08:03:44 +01:00
|
|
|
TEST_CYCLE(100)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::split(src, dst);
|
2011-09-07 15:16:07 +02:00
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(MatOp, Split, testing::Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
GPU_TYPICAL_MAT_SIZES,
|
|
|
|
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// SetTo
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
cv::Size size = GET_PARAM(1);
|
|
|
|
int type = GET_PARAM(2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat src(size, type);
|
|
|
|
cv::Scalar val(1, 2, 3, 4);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-11-15 08:03:44 +01:00
|
|
|
TEST_CYCLE(100)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
|
|
|
src.setTo(val);
|
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
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)));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// SetToMasked
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
cv::Size size = GET_PARAM(1);
|
|
|
|
int type = GET_PARAM(2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat src_host(size, type);
|
|
|
|
cv::Mat mask_host(size, CV_8UC1);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
|
|
|
declare.in(src_host, WARMUP_RNG);
|
2011-12-28 13:53:08 +01:00
|
|
|
fill(mask_host, 0, 2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat src(src_host);
|
|
|
|
cv::Scalar val(1, 2, 3, 4);
|
|
|
|
cv::gpu::GpuMat mask(mask_host);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-11-15 08:03:44 +01:00
|
|
|
TEST_CYCLE(100)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
|
|
|
src.setTo(val, mask);
|
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
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)));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// CopyToMasked
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
cv::Size size = GET_PARAM(1);
|
|
|
|
int type = GET_PARAM(2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat src_host(size, type);
|
|
|
|
cv::Mat mask_host(size, CV_8UC1);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
|
|
|
declare.in(src_host, WARMUP_RNG);
|
2011-12-28 13:53:08 +01:00
|
|
|
fill(mask_host, 0, 2);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat src(src_host);
|
|
|
|
cv::gpu::GpuMat mask(mask_host);
|
|
|
|
cv::gpu::GpuMat dst;
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-11-15 08:03:44 +01:00
|
|
|
TEST_CYCLE(100)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
|
|
|
src.copyTo(dst, mask);
|
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
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)));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// ConvertTo
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType, perf::MatType)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
|
|
|
cv::Size size = GET_PARAM(1);
|
|
|
|
int type1 = GET_PARAM(2);
|
|
|
|
int type2 = GET_PARAM(3);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::Mat src_host(size, type1);
|
2011-09-07 15:16:07 +02:00
|
|
|
|
|
|
|
declare.in(src_host, WARMUP_RNG);
|
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
cv::gpu::GpuMat src(src_host);
|
|
|
|
cv::gpu::GpuMat dst;
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-11-15 08:03:44 +01:00
|
|
|
TEST_CYCLE(100)
|
2011-09-07 15:16:07 +02:00
|
|
|
{
|
2011-12-28 13:53:08 +01:00
|
|
|
src.convertTo(dst, type2, 0.5, 1.0);
|
2011-09-07 15:16:07 +02:00
|
|
|
}
|
2011-12-28 13:53:08 +01:00
|
|
|
}
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
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)));
|
2011-09-07 15:16:07 +02:00
|
|
|
|
2011-12-28 13:53:08 +01:00
|
|
|
#endif
|