opencv/modules/gpu/perf/perf_matop.cpp

116 lines
2.7 KiB
C++
Raw Normal View History

2011-09-07 15:16:07 +02:00
#include "perf_precomp.hpp"
using namespace std;
using namespace testing;
namespace {
2011-12-28 13:53:08 +01:00
//////////////////////////////////////////////////////////////////////
2012-05-23 14:58:01 +02:00
// SetTo
2011-12-28 13:53:08 +01:00
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
2011-09-07 15:16:07 +02:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2011-09-07 15:16:07 +02:00
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 15:16:07 +02:00
2011-12-28 13:53:08 +01:00
cv::Scalar val(1, 2, 3, 4);
2011-09-07 15:16:07 +02:00
cv::gpu::GpuMat d_src(size, type);
d_src.setTo(val);
2012-05-23 14:58:01 +02:00
TEST_CYCLE()
2011-09-07 15:16:07 +02:00
{
d_src.setTo(val);
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
//////////////////////////////////////////////////////////////////////
// SetToMasked
2011-09-07 15:16:07 +02:00
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
2011-09-07 15:16:07 +02:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 14:58:01 +02:00
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 15:16:07 +02:00
cv::Mat src(size, type);
fillRandom(src);
2011-09-07 15:16:07 +02:00
cv::Mat mask(size, CV_8UC1);
fillRandom(mask, 0, 2);
2011-09-07 15:16:07 +02:00
2011-12-28 13:53:08 +01:00
cv::Scalar val(1, 2, 3, 4);
2012-05-23 14:58:01 +02:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
d_src.setTo(val, d_mask);
2012-05-23 14:58:01 +02:00
TEST_CYCLE()
2011-09-07 15:16:07 +02:00
{
d_src.setTo(val, d_mask);
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
//////////////////////////////////////////////////////////////////////
// CopyToMasked
2011-09-07 15:16:07 +02:00
PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
2011-09-07 15:16:07 +02:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 14:58:01 +02:00
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 15:16:07 +02:00
cv::Mat src(size, type);
fillRandom(src);
2011-09-07 15:16:07 +02:00
cv::Mat mask(size, CV_8UC1);
fillRandom(mask, 0, 2);
2011-09-07 15:16:07 +02:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
cv::gpu::GpuMat d_dst;
2012-05-23 14:58:01 +02:00
d_src.copyTo(d_dst, d_mask);
2012-05-23 14:58:01 +02:00
TEST_CYCLE()
2011-09-07 15:16:07 +02:00
{
d_src.copyTo(d_dst, d_mask);
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
//////////////////////////////////////////////////////////////////////
// ConvertTo
2011-09-07 15:16:07 +02:00
DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
2011-09-07 15:16:07 +02: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 15:16:07 +02:00
cv::Mat src(size, depth1);
fillRandom(src);
2011-09-07 15:16:07 +02:00
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-05-23 14:58:01 +02:00
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
2012-05-23 14:58:01 +02:00
TEST_CYCLE()
2011-09-07 15:16:07 +02:00
{
d_src.convertTo(d_dst, depth2, 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
} // namespace