2012-10-17 07:18:30 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace testing;
|
2013-03-15 18:09:10 +08:00
|
|
|
using namespace perf;
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// SetTo
|
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo,
|
|
|
|
Combine(GPU_TYPICAL_MAT_SIZES,
|
|
|
|
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
|
|
|
GPU_CHANNELS_1_3_4))
|
2012-10-17 07:18:30 +08:00
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::Size size = GET_PARAM(0);
|
|
|
|
const int depth = GET_PARAM(1);
|
|
|
|
const int channels = GET_PARAM(2);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
const int type = CV_MAKE_TYPE(depth, channels);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::Scalar val(1, 2, 3, 4);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
if (PERF_RUN_GPU())
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
cv::gpu::GpuMat dst(size, type);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() dst.setTo(val);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
GPU_SANITY_CHECK(dst);
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
cv::Mat dst(size, type);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() dst.setTo(val);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
CPU_SANITY_CHECK(dst);
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// SetToMasked
|
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked,
|
|
|
|
Combine(GPU_TYPICAL_MAT_SIZES,
|
|
|
|
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
|
|
|
GPU_CHANNELS_1_3_4))
|
2012-10-17 07:18:30 +08:00
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::Size size = GET_PARAM(0);
|
|
|
|
const int depth = GET_PARAM(1);
|
|
|
|
const int channels = GET_PARAM(2);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
const int type = CV_MAKE_TYPE(depth, channels);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
cv::Mat src(size, type);
|
|
|
|
cv::Mat mask(size, CV_8UC1);
|
2013-02-26 17:49:35 +08:00
|
|
|
declare.in(src, mask, WARMUP_RNG);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::Scalar val(1, 2, 3, 4);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
if (PERF_RUN_GPU())
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
cv::gpu::GpuMat dst(src);
|
|
|
|
const cv::gpu::GpuMat d_mask(mask);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() dst.setTo(val, d_mask);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-28 20:43:08 +08:00
|
|
|
GPU_SANITY_CHECK(dst, 1e-10);
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
cv::Mat dst = src;
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() dst.setTo(val, mask);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
CPU_SANITY_CHECK(dst);
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// CopyToMasked
|
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked,
|
|
|
|
Combine(GPU_TYPICAL_MAT_SIZES,
|
|
|
|
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
|
|
|
GPU_CHANNELS_1_3_4))
|
2012-10-17 07:18:30 +08:00
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::Size size = GET_PARAM(0);
|
|
|
|
const int depth = GET_PARAM(1);
|
|
|
|
const int channels = GET_PARAM(2);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
const int type = CV_MAKE_TYPE(depth, channels);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
cv::Mat src(size, type);
|
|
|
|
cv::Mat mask(size, CV_8UC1);
|
2013-02-26 17:49:35 +08:00
|
|
|
declare.in(src, mask, WARMUP_RNG);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
if (PERF_RUN_GPU())
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::gpu::GpuMat d_src(src);
|
|
|
|
const cv::gpu::GpuMat d_mask(mask);
|
|
|
|
cv::gpu::GpuMat dst(d_src.size(), d_src.type(), cv::Scalar::all(0));
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() d_src.copyTo(dst, d_mask);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-28 20:43:08 +08:00
|
|
|
GPU_SANITY_CHECK(dst, 1e-10);
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
cv::Mat dst(src.size(), src.type(), cv::Scalar::all(0));
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() src.copyTo(dst, mask);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
CPU_SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// ConvertTo
|
|
|
|
|
|
|
|
DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
|
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo,
|
|
|
|
Combine(GPU_TYPICAL_MAT_SIZES,
|
|
|
|
Values(CV_8U, CV_16U, CV_32F, CV_64F),
|
|
|
|
Values(CV_8U, CV_16U, CV_32F, CV_64F)))
|
2012-10-17 07:18:30 +08:00
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::Size size = GET_PARAM(0);
|
|
|
|
const int depth1 = GET_PARAM(1);
|
|
|
|
const int depth2 = GET_PARAM(2);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
cv::Mat src(size, depth1);
|
2013-02-26 17:49:35 +08:00
|
|
|
declare.in(src, WARMUP_RNG);
|
|
|
|
|
|
|
|
const double a = 0.5;
|
|
|
|
const double b = 1.0;
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
if (PERF_RUN_GPU())
|
|
|
|
{
|
2013-02-26 17:49:35 +08:00
|
|
|
const cv::gpu::GpuMat d_src(src);
|
|
|
|
cv::gpu::GpuMat dst;
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() d_src.convertTo(dst, depth2, a, b);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2013-02-28 20:43:08 +08:00
|
|
|
GPU_SANITY_CHECK(dst, 1e-10);
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
2013-02-26 17:49:35 +08:00
|
|
|
TEST_CYCLE() src.convertTo(dst, depth2, a, b);
|
2012-10-17 07:18:30 +08:00
|
|
|
|
|
|
|
CPU_SANITY_CHECK(dst);
|
|
|
|
}
|
|
|
|
}
|