opencv/modules/gpu/perf_cpu/perf_matop.cpp

125 lines
3.3 KiB
C++
Raw Normal View History

2012-05-22 12:29:58 +02:00
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// SetTo
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
2012-05-22 12:29:58 +02:00
cv::Mat src(size, type);
cv::Scalar val(1, 2, 3, 4);
2012-05-23 14:58:01 +02:00
src.setTo(val);
TEST_CYCLE()
{
src.setTo(val);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine(
2012-05-23 14:58:01 +02:00
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// SetToMasked
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
2012-05-22 12:29:58 +02:00
cv::Mat src(size, type);
2012-05-23 14:58:01 +02:00
fill(src, 0, 255);
2012-05-23 14:58:01 +02:00
cv::Mat mask(size, CV_8UC1);
2012-05-22 12:29:58 +02:00
fill(mask, 0, 2);
cv::Scalar val(1, 2, 3, 4);
2012-05-22 12:29:58 +02:00
2012-05-23 14:58:01 +02:00
src.setTo(val, mask);
TEST_CYCLE()
{
src.setTo(val, mask);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine(
2012-05-23 14:58:01 +02:00
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// CopyToMasked
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
2012-05-22 12:29:58 +02:00
cv::Mat src(size, type);
2012-05-23 14:58:01 +02:00
fill(src, 0, 255);
2012-05-23 14:58:01 +02:00
cv::Mat mask(size, CV_8UC1);
2012-05-22 12:29:58 +02:00
fill(mask, 0, 2);
2012-05-22 12:29:58 +02:00
cv::Mat dst;
2012-05-23 14:58:01 +02:00
src.copyTo(dst, mask);
TEST_CYCLE()
{
src.copyTo(dst, mask);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine(
2012-05-23 14:58:01 +02:00
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// ConvertTo
2012-05-23 14:58:01 +02:00
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth)
{
cv::Size size = GET_PARAM(1);
2012-05-23 14:58:01 +02:00
int depth1 = GET_PARAM(2);
int depth2 = GET_PARAM(3);
2012-05-23 14:58:01 +02:00
cv::Mat src(size, depth1);
fill(src, 0, 255);
2012-05-22 12:29:58 +02:00
cv::Mat dst;
2012-05-23 14:58:01 +02:00
src.convertTo(dst, depth2, 0.5, 1.0);
TEST_CYCLE()
{
2012-05-23 14:58:01 +02:00
src.convertTo(dst, depth2, 0.5, 1.0);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine(
2012-05-23 14:58:01 +02:00
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)),
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F))));
#endif