2011-09-07 21:16:07 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
using namespace std;
|
|
|
|
using namespace testing;
|
|
|
|
|
|
|
|
namespace {
|
2011-12-28 20:53:08 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2012-05-23 20:58:01 +08:00
|
|
|
// SetTo
|
2011-12-28 20:53:08 +08:00
|
|
|
|
2012-08-29 20:49:07 +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))
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Size size = GET_PARAM(0);
|
|
|
|
int depth = GET_PARAM(1);
|
|
|
|
int channels = GET_PARAM(2);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
int type = CV_MAKE_TYPE(depth, channels);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
cv::Scalar val(1, 2, 3, 4);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
if (runOnGpu)
|
|
|
|
{
|
|
|
|
cv::gpu::GpuMat d_src(size, type);
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
d_src.setTo(val);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
d_src.setTo(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 21:34:58 +08:00
|
|
|
cv::Mat src(size, type);
|
|
|
|
|
|
|
|
src.setTo(val);
|
|
|
|
|
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
src.setTo(val);
|
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// SetToMasked
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-29 20:49:07 +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))
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Size size = GET_PARAM(0);
|
|
|
|
int depth = GET_PARAM(1);
|
|
|
|
int channels = GET_PARAM(2);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
int type = CV_MAKE_TYPE(depth, channels);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat src(size, type);
|
|
|
|
fillRandom(src);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat mask(size, CV_8UC1);
|
|
|
|
fillRandom(mask, 0, 2);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
cv::Scalar val(1, 2, 3, 4);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
if (runOnGpu)
|
|
|
|
{
|
|
|
|
cv::gpu::GpuMat d_src(src);
|
|
|
|
cv::gpu::GpuMat d_mask(mask);
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
d_src.setTo(val, d_mask);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
d_src.setTo(val, d_mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 21:34:58 +08:00
|
|
|
src.setTo(val, mask);
|
|
|
|
|
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
src.setTo(val, mask);
|
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// CopyToMasked
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-29 20:49:07 +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))
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Size size = GET_PARAM(0);
|
|
|
|
int depth = GET_PARAM(1);
|
|
|
|
int channels = GET_PARAM(2);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
int type = CV_MAKE_TYPE(depth, channels);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat src(size, type);
|
|
|
|
fillRandom(src);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat mask(size, CV_8UC1);
|
|
|
|
fillRandom(mask, 0, 2);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
if (runOnGpu)
|
|
|
|
{
|
|
|
|
cv::gpu::GpuMat d_src(src);
|
|
|
|
cv::gpu::GpuMat d_mask(mask);
|
|
|
|
cv::gpu::GpuMat d_dst;
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
d_src.copyTo(d_dst, d_mask);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
d_src.copyTo(d_dst, d_mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 21:34:58 +08:00
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
src.copyTo(dst, mask);
|
|
|
|
|
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
src.copyTo(dst, mask);
|
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2011-12-28 20:53:08 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// ConvertTo
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +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)))
|
|
|
|
{
|
|
|
|
cv::Size size = GET_PARAM(0);
|
|
|
|
int depth1 = GET_PARAM(1);
|
|
|
|
int depth2 = GET_PARAM(2);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
cv::Mat src(size, depth1);
|
|
|
|
fillRandom(src);
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
if (runOnGpu)
|
|
|
|
{
|
|
|
|
cv::gpu::GpuMat d_src(src);
|
|
|
|
cv::gpu::GpuMat d_dst;
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
|
2012-05-23 20:58:01 +08:00
|
|
|
|
2012-08-17 21:34:58 +08:00
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-08-17 21:34:58 +08:00
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
src.convertTo(dst, depth2, 0.5, 1.0);
|
|
|
|
|
|
|
|
TEST_CYCLE()
|
|
|
|
{
|
|
|
|
src.convertTo(dst, depth2, 0.5, 1.0);
|
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
}
|
2011-12-28 20:53:08 +08:00
|
|
|
}
|
2011-09-07 21:16:07 +08:00
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
} // namespace
|