opencv/modules/gpu/perf/perf_imgproc.cpp

1717 lines
43 KiB
C++
Raw Normal View History

2011-09-07 21:16:07 +08:00
#include "perf_precomp.hpp"
using namespace std;
using namespace testing;
namespace {
2011-09-07 21:16:07 +08:00
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
// Remap
2011-09-07 21:16:07 +08:00
enum{HALF_SIZE=0, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH};
CV_ENUM(RemapMode, HALF_SIZE, UPSIDE_DOWN, REFLECTION_X, REFLECTION_BOTH);
#define ALL_REMAP_MODES ValuesIn(RemapMode::all())
void generateMap(cv::Mat& map_x, cv::Mat& map_y, int remapMode)
{
for (int j = 0; j < map_x.rows; ++j)
{
for (int i = 0; i < map_x.cols; ++i)
{
switch (remapMode)
{
case HALF_SIZE:
if (i > map_x.cols*0.25 && i < map_x.cols*0.75 && j > map_x.rows*0.25 && j < map_x.rows*0.75)
{
map_x.at<float>(j,i) = 2.f * (i - map_x.cols * 0.25f) + 0.5f;
map_y.at<float>(j,i) = 2.f * (j - map_x.rows * 0.25f) + 0.5f;
}
else
{
map_x.at<float>(j,i) = 0.f;
map_y.at<float>(j,i) = 0.f;
}
break;
case UPSIDE_DOWN:
map_x.at<float>(j,i) = static_cast<float>(i);
map_y.at<float>(j,i) = static_cast<float>(map_x.rows - j);
break;
case REFLECTION_X:
map_x.at<float>(j,i) = static_cast<float>(map_x.cols - i);
map_y.at<float>(j,i) = static_cast<float>(j);
break;
case REFLECTION_BOTH:
map_x.at<float>(j,i) = static_cast<float>(map_x.cols - i);
map_y.at<float>(j,i) = static_cast<float>(map_x.rows - j);
break;
} // end of switch
}
}
}
DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border_Mode, cv::Size, MatDepth, int, Interpolation, BorderMode, RemapMode);
PERF_TEST_P(Sz_Depth_Cn_Inter_Border_Mode, ImgProc_Remap, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
ALL_BORDER_MODES,
ALL_REMAP_MODES))
2011-12-28 20:53:08 +08:00
{
2012-08-17 21:34:58 +08:00
declare.time(20.0);
2012-05-23 20:58:01 +08:00
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2011-12-28 20:53:08 +08:00
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
int remapMode = GET_PARAM(5);
2011-09-07 21:16:07 +08:00
int type = CV_MAKE_TYPE(depth, channels);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
2011-09-07 21:16:07 +08:00
cv::Mat xmap(size, CV_32FC1);
cv::Mat ymap(size, CV_32FC1);
2011-09-07 21:16:07 +08:00
generateMap(xmap, ymap, remapMode);
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_xmap(xmap);
cv::gpu::GpuMat d_ymap(ymap);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
TEST_CYCLE()
{
cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Resize
2011-09-07 21:16:07 +08:00
DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Scale, cv::Size, MatDepth, int, Interpolation, double);
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
ALL_INTERPOLATIONS,
Values(0.5, 0.3, 2.0)))
2012-05-23 20:58:01 +08:00
{
2012-08-17 21:34:58 +08:00
declare.time(20.0);
2011-09-07 21:16:07 +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
int interpolation = GET_PARAM(3);
double f = GET_PARAM(4);
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, type);
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
cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::resize(src, dst, cv::Size(), f, f, interpolation);
TEST_CYCLE()
{
cv::resize(src, dst, cv::Size(), f, f, interpolation);
}
2011-09-07 21:16:07 +08:00
}
2011-12-28 20:53:08 +08:00
}
2011-09-07 21:16:07 +08:00
//////////////////////////////////////////////////////////////////////
// ResizeArea
DEF_PARAM_TEST(Sz_Depth_Cn_Scale, cv::Size, MatDepth, int, double);
PERF_TEST_P(Sz_Depth_Cn_Scale, ImgProc_ResizeArea, Combine(
2012-05-23 20:58:01 +08:00
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
Values(0.2, 0.1, 0.05)))
{
declare.time(1.0);
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
int interpolation = cv::INTER_AREA;
double f = GET_PARAM(3);
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-08-17 21:34:58 +08:00
cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::resize(d_src, d_dst, cv::Size(), f, f, interpolation);
}
}
else
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::resize(src, dst, cv::Size(), f, f, interpolation);
TEST_CYCLE()
{
cv::resize(src, dst, cv::Size(), f, f, interpolation);
}
}
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// WarpAffine
2011-09-07 21:16:07 +08:00
DEF_PARAM_TEST(Sz_Depth_Cn_Inter_Border, cv::Size, MatDepth, int, Interpolation, BorderMode);
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
ALL_BORDER_MODES))
{
2012-08-17 21:34:58 +08:00
declare.time(20.0);
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, type);
fillRandom(src);
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
const double aplha = CV_PI / 4;
double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},
{std::sin(aplha), std::cos(aplha), 0}};
cv::Mat M(2, 3, CV_64F, (void*) mat);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-08-17 21:34:58 +08:00
cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::warpAffine(d_src, d_dst, M, size, interpolation, borderMode);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::warpAffine(src, dst, M, size, interpolation, borderMode);
TEST_CYCLE()
{
cv::warpAffine(src, dst, M, size, interpolation, borderMode);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// WarpPerspective
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
ALL_BORDER_MODES))
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
declare.time(20.0);
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, type);
fillRandom(src);
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
const double aplha = CV_PI / 4;
double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},
{std::sin(aplha), std::cos(aplha), 0},
{0.0, 0.0, 1.0}};
cv::Mat M(3, 3, CV_64F, (void*) mat);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-08-17 21:34:58 +08:00
cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::warpPerspective(d_src, d_dst, M, size, interpolation, borderMode);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
TEST_CYCLE()
{
cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
}
2011-09-07 21:16:07 +08:00
}
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// CopyMakeBorder
2011-12-28 20:53:08 +08:00
DEF_PARAM_TEST(Sz_Depth_Cn_Border, cv::Size, MatDepth, int, BorderMode);
PERF_TEST_P(Sz_Depth_Cn_Border, ImgProc_CopyMakeBorder, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
ALL_BORDER_MODES))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
int borderMode = GET_PARAM(3);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-08-17 21:34:58 +08:00
cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::copyMakeBorder(d_src, d_dst, 5, 5, 5, 5, borderMode);
}
}
else
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);
TEST_CYCLE()
{
cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderMode);
}
}
2011-12-28 20:53:08 +08:00
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Threshold
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
#define ALL_THRESH_OPS ValuesIn(ThreshOp::all())
DEF_PARAM_TEST(Sz_Depth_Op, cv::Size, MatDepth, ThreshOp);
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F, CV_64F),
ALL_THRESH_OPS))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int threshOp = GET_PARAM(2);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, depth);
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;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::threshold(d_src, d_dst, 100.0, 255.0, threshOp);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::threshold(src, dst, 100.0, 255.0, threshOp);
TEST_CYCLE()
{
cv::threshold(src, dst, 100.0, 255.0, threshOp);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Integral
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_Integral, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
cv::Mat src(size, CV_8UC1);
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;
cv::gpu::GpuMat d_buf;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::integralBuffered(d_src, d_dst, d_buf);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::integralBuffered(d_src, d_dst, d_buf);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::integral(src, dst);
TEST_CYCLE()
{
cv::integral(src, dst);
}
2011-09-07 21:16:07 +08:00
}
2011-12-28 20:53:08 +08:00
}
2011-09-07 21:16:07 +08:00
//////////////////////////////////////////////////////////////////////
// IntegralSqr
PERF_TEST_P(Sz, ImgProc_IntegralSqr, GPU_TYPICAL_MAT_SIZES)
{
cv::Size size = GetParam();
cv::Mat src(size, CV_8UC1);
fillRandom(src);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-08-17 21:34:58 +08:00
cv::gpu::sqrIntegral(d_src, d_dst);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::sqrIntegral(d_src, d_dst);
}
}
else
{
2012-08-17 21:34:58 +08:00
FAIL();
}
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
// HistEvenC1
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC1, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S)))
2011-09-07 21:16:07 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, depth);
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_hist;
cv::gpu::GpuMat d_buf;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::histEven(d_src, d_hist, d_buf, 30, 0, 180);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
int hbins = 30;
float hranges[] = {0.0f, 180.0f};
int histSize[] = {hbins};
const float* ranges[] = {hranges};
int channels[] = {0};
cv::Mat hist;
cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);
TEST_CYCLE()
{
cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);
}
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
//////////////////////////////////////////////////////////////////////
// HistEvenC4
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth, ImgProc_HistEvenC4, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_16S)))
2011-09-07 21:16:07 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, CV_MAKE_TYPE(depth, 4));
fillRandom(src);
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
int histSize[] = {30, 30, 30, 30};
int lowerLevel[] = {0, 0, 0, 0};
int upperLevel[] = {180, 180, 180, 180};
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_hist[4];
cv::gpu::GpuMat d_buf;
2012-08-17 21:34:58 +08:00
cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::histEven(d_src, d_hist, d_buf, histSize, lowerLevel, upperLevel);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// CalcHist
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_CalcHist, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
cv::Mat src(size, CV_8UC1);
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_hist;
cv::gpu::GpuMat d_buf;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::calcHist(d_src, d_hist, d_buf);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::calcHist(d_src, d_hist, d_buf);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// EqualizeHist
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_EqualizeHist, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
cv::Mat src(size, CV_8UC1);
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;
cv::gpu::GpuMat d_hist;
cv::gpu::GpuMat d_buf;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::equalizeHist(d_src, d_dst, d_hist, d_buf);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::equalizeHist(src, dst);
TEST_CYCLE()
{
cv::equalizeHist(src, dst);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// ColumnSum
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_ColumnSum, GPU_TYPICAL_MAT_SIZES)
{
cv::Size size = GetParam();
cv::Mat src(size, CV_32FC1);
fillRandom(src);
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
cv::gpu::columnSum(d_src, d_dst);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::columnSum(d_src, d_dst);
}
}
else
{
2012-08-17 21:34:58 +08:00
FAIL();
}
2011-12-28 20:53:08 +08:00
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Canny
DEF_PARAM_TEST(Image_AppertureSz_L2gradient, string, int, bool);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny, Combine(
Values("perf/800x600.jpg", "perf/1280x1024.jpg", "perf/1680x1050.jpg"),
Values(3, 5),
Bool()))
{
string fileName = GET_PARAM(0);
2012-05-23 20:58:01 +08:00
int apperture_size = GET_PARAM(1);
bool useL2gradient = GET_PARAM(2);
cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(image.empty());
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_dst;
cv::gpu::CannyBuf d_buf;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::Canny(d_image, d_buf, d_dst, 50.0, 100.0, apperture_size, useL2gradient);
}
}
else
2012-05-23 20:58:01 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);
TEST_CYCLE()
{
cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);
}
2012-05-23 20:58:01 +08:00
}
}
//////////////////////////////////////////////////////////////////////
// MeanShiftFiltering
DEF_PARAM_TEST_1(Image, string);
PERF_TEST_P(Image, ImgProc_MeanShiftFiltering, Values<string>("gpu/meanshift/cones.png"))
2012-05-23 20:58:01 +08:00
{
2012-08-17 21:34:58 +08:00
declare.time(15.0);
cv::Mat img = readImage(GetParam());
2012-05-23 20:58:01 +08:00
ASSERT_FALSE(img.empty());
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(rgba);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::meanShiftFiltering(d_src, d_dst, 50, 50);
}
}
else
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::pyrMeanShiftFiltering(img, dst, 50, 50);
TEST_CYCLE()
{
cv::pyrMeanShiftFiltering(img, dst, 50, 50);
}
}
2011-12-28 20:53:08 +08:00
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// MeanShiftProc
PERF_TEST_P(Image, ImgProc_MeanShiftProc, Values<string>("gpu/meanshift/cones.png"))
{
declare.time(5.0);
2012-05-23 20:58:01 +08:00
cv::Mat img = readImage(GetParam());
2012-05-23 20:58:01 +08:00
ASSERT_FALSE(img.empty());
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(rgba);
cv::gpu::GpuMat d_dstr;
cv::gpu::GpuMat d_dstsp;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::meanShiftProc(d_src, d_dstr, d_dstsp, 50, 50);
}
}
else
2012-05-23 20:58:01 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
2012-05-23 20:58:01 +08:00
}
}
2012-05-23 20:58:01 +08:00
//////////////////////////////////////////////////////////////////////
// MeanShiftSegmentation
PERF_TEST_P(Image, ImgProc_MeanShiftSegmentation, Values<string>("gpu/meanshift/cones.png"))
2012-05-23 20:58:01 +08:00
{
declare.time(5.0);
cv::Mat img = readImage(GetParam());
2012-05-23 20:58:01 +08:00
ASSERT_FALSE(img.empty());
cv::Mat rgba;
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);
cv::Mat dst;
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(rgba);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::meanShiftSegmentation(d_src, dst, 10, 10, 20);
}
}
else
{
2012-08-17 21:34:58 +08:00
FAIL();
}
2011-12-28 20:53:08 +08:00
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// BlendLinear
PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_32F), Values(1, 3, 4)))
2011-09-07 21:16:07 +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
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat img1(size, type);
fillRandom(img1);
2011-09-07 21:16:07 +08:00
cv::Mat img2(size, type);
fillRandom(img2);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_img1(img1);
cv::gpu::GpuMat d_img2(img2);
cv::gpu::GpuMat d_weights1(size, CV_32FC1, cv::Scalar::all(0.5));
cv::gpu::GpuMat d_weights2(size, CV_32FC1, cv::Scalar::all(0.5));
cv::gpu::GpuMat d_dst;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::blendLinear(d_img1, d_img2, d_weights1, d_weights2, d_dst);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Convolve
DEF_PARAM_TEST(Sz_KernelSz_Ccorr, cv::Size, int, bool);
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, Combine(GPU_TYPICAL_MAT_SIZES, Values(17, 27, 32, 64), Bool()))
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
declare.time(10.0);
2012-05-23 20:58:01 +08:00
cv::Size size = GET_PARAM(0);
int templ_size = GET_PARAM(1);
bool ccorr = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::Mat image(size, CV_32FC1);
image.setTo(1.0);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::Mat templ(templ_size, templ_size, CV_32FC1);
templ.setTo(1.0);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_image = cv::gpu::createContinuous(size, CV_32FC1);
d_image.upload(image);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::GpuMat d_templ = cv::gpu::createContinuous(templ_size, templ_size, CV_32FC1);
d_templ.upload(templ);
cv::gpu::GpuMat d_dst;
cv::gpu::ConvolveBuf d_buf;
2012-05-23 20:58:01 +08:00
cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::convolve(d_image, d_templ, d_dst, ccorr, d_buf);
}
}
else
{
ASSERT_FALSE(ccorr);
cv::Mat dst;
cv::filter2D(image, dst, image.depth(), templ);
TEST_CYCLE()
{
cv::filter2D(image, dst, image.depth(), templ);
}
2012-05-23 20:58:01 +08:00
}
}
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate8U
2012-05-23 20:58:01 +08:00
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
#define ALL_TEMPLATE_METHODS ValuesIn(TemplateMethod::all())
2012-05-23 20:58:01 +08:00
DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, int, TemplateMethod);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
Values(1, 3, 4),
ALL_TEMPLATE_METHODS))
2012-05-23 20:58:01 +08:00
{
cv::Size size = GET_PARAM(0);
cv::Size templ_size = GET_PARAM(1);
int cn = GET_PARAM(2);
int method = GET_PARAM(3);
2011-09-07 21:16:07 +08:00
cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn));
fillRandom(image);
2011-09-07 21:16:07 +08:00
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));
fillRandom(templ);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_templ(templ);
cv::gpu::GpuMat d_dst;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::matchTemplate(image, templ, dst, method);
TEST_CYCLE()
{
cv::matchTemplate(image, templ, dst, method);
}
2011-09-07 21:16:07 +08:00
}
2012-05-23 20:58:01 +08:00
};
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate32F
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
Values(1, 3, 4),
Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))))
2011-09-07 21:16:07 +08:00
{
cv::Size size = GET_PARAM(0);
cv::Size templ_size = GET_PARAM(1);
int cn = GET_PARAM(2);
int method = GET_PARAM(3);
2012-05-23 20:58:01 +08:00
cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn));
fillRandom(image);
2012-05-23 20:58:01 +08:00
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));
fillRandom(templ);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_templ(templ);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::matchTemplate(d_image, d_templ, d_dst, method);
}
}
else
2012-05-23 20:58:01 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::matchTemplate(image, templ, dst, method);
TEST_CYCLE()
{
cv::matchTemplate(image, templ, dst, method);
}
2012-05-23 20:58:01 +08:00
}
};
//////////////////////////////////////////////////////////////////////
// MulSpectrums
CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
DEF_PARAM_TEST(Sz_Flags, cv::Size, DftFlags);
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(0, DftFlags(cv::DFT_ROWS))))
{
cv::Size size = GET_PARAM(0);
int flag = GET_PARAM(1);
2011-09-07 21:16:07 +08:00
cv::Mat a(size, CV_32FC2);
fillRandom(a, 0, 100);
2011-09-07 21:16:07 +08:00
cv::Mat b(size, CV_32FC2);
fillRandom(b, 0, 100);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_a(a);
cv::gpu::GpuMat d_b(b);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::mulSpectrums(d_a, d_b, d_dst, flag);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::mulSpectrums(a, b, dst, flag);
TEST_CYCLE()
{
cv::mulSpectrums(a, b, dst, flag);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// MulAndScaleSpectrums
PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
float scale = 1.f / size.area();
2011-09-07 21:16:07 +08:00
cv::Mat src1(size, CV_32FC2);
fillRandom(src1, 0, 100);
2011-09-07 21:16:07 +08:00
cv::Mat src2(size, CV_32FC2);
fillRandom(src2, 0, 100);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_dst;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, d_dst, cv::DFT_ROWS, scale, false);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Dft
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Flags, ImgProc_Dft, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(0, DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))))
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
declare.time(10.0);
2011-09-07 21:16:07 +08:00
cv::Size size = GET_PARAM(0);
int flag = GET_PARAM(1);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, CV_32FC2);
fillRandom(src, 0, 100);
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
cv::gpu::dft(d_src, d_dst, size, flag);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::dft(d_src, d_dst, size, flag);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::dft(src, dst, flag);
TEST_CYCLE()
{
cv::dft(src, dst, flag);
}
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
//////////////////////////////////////////////////////////////////////
// CornerHarris
2011-09-07 21:16:07 +08:00
DEF_PARAM_TEST(Image_Type_Border_BlockSz_ApertureSz, string, MatType, BorderMode, int, int);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerHarris, Combine(
Values<string>("gpu/stereobm/aloe-L.png"),
Values(CV_8UC1, CV_32FC1),
Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
Values(3, 5, 7),
Values(0, 3, 5, 7)))
2011-09-07 21:16:07 +08:00
{
string fileName = GET_PARAM(0);
2012-05-23 20:58:01 +08:00
int type = GET_PARAM(1);
int borderMode = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int blockSize = GET_PARAM(3);
int apertureSize = GET_PARAM(4);
cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);
2011-09-07 21:16:07 +08:00
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
2012-08-17 21:34:58 +08:00
double k = 0.5;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_Dx;
cv::gpu::GpuMat d_Dy;
cv::gpu::GpuMat d_buf;
cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::cornerHarris(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, k, borderMode);
}
}
else
{
cv::Mat dst;
cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
TEST_CYCLE()
{
cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderMode);
}
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
//////////////////////////////////////////////////////////////////////
// CornerMinEigenVal
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Image_Type_Border_BlockSz_ApertureSz, ImgProc_CornerMinEigenVal, Combine(
Values<string>("gpu/stereobm/aloe-L.png"),
Values(CV_8UC1, CV_32FC1),
Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
Values(3, 5, 7),
Values(0, 3, 5, 7)))
2011-09-07 21:16:07 +08:00
{
string fileName = GET_PARAM(0);
2012-05-23 20:58:01 +08:00
int type = GET_PARAM(1);
int borderMode = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int blockSize = GET_PARAM(3);
int apertureSize = GET_PARAM(4);
cv::Mat img = readImage(fileName, cv::IMREAD_GRAYSCALE);
2011-09-07 21:16:07 +08:00
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_Dx;
cv::gpu::GpuMat d_Dy;
cv::gpu::GpuMat d_buf;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::cornerMinEigenVal(d_img, d_dst, d_Dx, d_Dy, d_buf, blockSize, apertureSize, borderMode);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
TEST_CYCLE()
{
cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderMode);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// BuildWarpPlaneMaps
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_BuildWarpPlaneMaps, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
cv::Mat T = cv::Mat::zeros(1, 3, CV_32F);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_map_x;
cv::gpu::GpuMat d_map_y;
2012-08-17 21:34:58 +08:00
cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, T, 1.0, d_map_x, d_map_y);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// BuildWarpCylindricalMaps
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_BuildWarpCylindricalMaps, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_map_x;
cv::gpu::GpuMat d_map_y;
2012-08-17 21:34:58 +08:00
cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::buildWarpCylindricalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// BuildWarpSphericalMaps
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz, ImgProc_BuildWarpSphericalMaps, GPU_TYPICAL_MAT_SIZES)
2011-09-07 21:16:07 +08:00
{
cv::Size size = GetParam();
2011-09-07 21:16:07 +08:00
2012-05-23 20:58:01 +08:00
cv::Mat K = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat R = cv::Mat::ones(3, 3, CV_32FC1);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_map_x;
cv::gpu::GpuMat d_map_y;
2012-08-17 21:34:58 +08:00
cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::buildWarpSphericalMaps(size, cv::Rect(0, 0, size.width, size.height), K, R, 1.0, d_map_x, d_map_y);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// Rotate
2011-09-07 21:16:07 +08:00
DEF_PARAM_TEST(Sz_Depth_Cn_Inter, cv::Size, MatDepth, int, Interpolation);
2012-05-23 20:58:01 +08:00
PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4),
Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int interpolation = GET_PARAM(3);
2011-09-07 21:16:07 +08:00
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, type);
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-08-17 21:34:58 +08:00
cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::rotate(d_src, d_dst, size, 30.0, 0, 0, interpolation);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// PyrDown
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrDown, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4)))
2011-09-07 21:16:07 +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
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, type);
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;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::pyrDown(d_src, d_dst);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::pyrDown(d_src, d_dst);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::pyrDown(src, dst);
TEST_CYCLE()
{
cv::pyrDown(src, dst);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// PyrUp
2011-09-07 21:16:07 +08:00
PERF_TEST_P(Sz_Depth_Cn, ImgProc_PyrUp, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(1, 3, 4)))
2011-09-07 21:16:07 +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
int type = CV_MAKE_TYPE(depth, channels);
2011-09-07 21:16:07 +08:00
cv::Mat src(size, type);
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;
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::pyrUp(d_src, d_dst);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::pyrUp(d_src, d_dst);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::pyrUp(src, dst);
TEST_CYCLE()
{
cv::pyrUp(src, dst);
}
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-05-23 20:58:01 +08:00
// CvtColor
DEF_PARAM_TEST(Sz_Depth_Code, cv::Size, MatDepth, CvtColorInfo);
PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor, Combine(
GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F),
Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),
CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),
CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),
CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),
CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),
CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),
CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),
CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),
CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),
CvtColorInfo(3, 3, cv::COLOR_RGB2Lab),
CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),
CvtColorInfo(3, 3, cv::COLOR_RGB2Luv),
CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),
CvtColorInfo(3, 3, cv::COLOR_Lab2RGB),
CvtColorInfo(3, 3, cv::COLOR_Luv2BGR),
CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),
CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR),
CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR),
CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR),
CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR),
CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA))))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
CvtColorInfo info = GET_PARAM(2);
cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
fillRandom(src);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2012-08-17 21:34:58 +08:00
cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);
2011-09-07 21:16:07 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::cvtColor(d_src, d_dst, info.code, info.dcn);
}
}
else
2011-09-07 21:16:07 +08:00
{
2012-08-17 21:34:58 +08:00
cv::Mat dst;
cv::cvtColor(src, dst, info.code, info.dcn);
TEST_CYCLE()
{
cv::cvtColor(src, dst, info.code, info.dcn);
}
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
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// SwapChannels
PERF_TEST_P(Sz, ImgProc_SwapChannels, GPU_TYPICAL_MAT_SIZES)
{
cv::Size size = GetParam();
cv::Mat src(size, CV_8UC4);
fillRandom(src);
2012-05-23 20:58:01 +08:00
const int dstOrder[] = {2, 1, 0, 3};
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
2012-08-17 21:34:58 +08:00
cv::gpu::swapChannels(d_src, dstOrder);
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::swapChannels(d_src, dstOrder);
}
}
else
{
2012-08-17 21:34:58 +08:00
FAIL();
}
2011-12-28 20:53:08 +08:00
}
//////////////////////////////////////////////////////////////////////
2012-05-23 20:58:01 +08:00
// AlphaComp
2011-12-28 20:53:08 +08:00
2012-05-23 20:58:01 +08:00
CV_ENUM(AlphaOp, cv::gpu::ALPHA_OVER, cv::gpu::ALPHA_IN, cv::gpu::ALPHA_OUT, cv::gpu::ALPHA_ATOP, cv::gpu::ALPHA_XOR, cv::gpu::ALPHA_PLUS, cv::gpu::ALPHA_OVER_PREMUL, cv::gpu::ALPHA_IN_PREMUL, cv::gpu::ALPHA_OUT_PREMUL, cv::gpu::ALPHA_ATOP_PREMUL, cv::gpu::ALPHA_XOR_PREMUL, cv::gpu::ALPHA_PLUS_PREMUL, cv::gpu::ALPHA_PREMUL)
#define ALL_ALPHA_OPS ValuesIn(AlphaOp::all())
2012-05-23 20:58:01 +08:00
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp);
PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4), ALL_ALPHA_OPS))
{
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int alpha_op = GET_PARAM(2);
cv::Mat img1(size, type);
fillRandom(img1);
2011-12-28 20:53:08 +08:00
cv::Mat img2(size, type);
fillRandom(img2);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_img1(img1);
cv::gpu::GpuMat d_img2(img2);
cv::gpu::GpuMat d_dst;
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);
2011-12-28 20:53:08 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
cv::gpu::alphaComp(d_img1, d_img2, d_dst, alpha_op);
}
}
else
2011-12-28 20:53:08 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
2011-12-28 20:53:08 +08:00
}
}
2011-12-28 20:53:08 +08:00
//////////////////////////////////////////////////////////////////////
// ImagePyramidBuild
2011-12-28 20:53:08 +08:00
PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), Values(1, 3, 4)))
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
2012-05-23 20:58:01 +08:00
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src(size, type);
fillRandom(src);
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
2012-08-17 21:34:58 +08:00
cv::gpu::ImagePyramid d_pyr;
2012-08-17 21:34:58 +08:00
d_pyr.build(d_src, 5);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
d_pyr.build(d_src, 5);
}
}
else
{
2012-08-17 21:34:58 +08:00
FAIL();
}
2011-12-28 20:53:08 +08:00
}
//////////////////////////////////////////////////////////////////////
// ImagePyramidGetLayer
PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F), Values(1, 3, 4)))
2011-12-28 20:53:08 +08:00
{
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
int type = CV_MAKE_TYPE(depth, channels);
2012-05-23 20:58:01 +08:00
cv::Mat src(size, type);
fillRandom(src);
cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10);
2011-12-28 20:53:08 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
2011-12-28 20:53:08 +08:00
2012-08-17 21:34:58 +08:00
cv::gpu::ImagePyramid d_pyr(d_src, 3);
2012-08-17 21:34:58 +08:00
d_pyr.getLayer(d_dst, dstSize);
2012-05-23 20:58:01 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
d_pyr.getLayer(d_dst, dstSize);
}
}
else
2011-12-28 20:53:08 +08:00
{
2012-08-17 21:34:58 +08:00
FAIL();
2011-12-28 20:53:08 +08:00
}
}
2011-12-28 20:53:08 +08:00
2012-08-14 15:36:32 +08:00
//////////////////////////////////////////////////////////////////////
// HoughLines
2012-08-23 20:54:48 +08:00
PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES)
2012-08-14 15:36:32 +08:00
{
declare.time(30.0);
2012-08-23 20:54:48 +08:00
const cv::Size size = GetParam();
2012-08-14 15:36:32 +08:00
const float rho = 1.0f;
const float theta = static_cast<float>(CV_PI / 180.0);
2012-08-14 15:36:32 +08:00
const int threshold = 300;
cv::RNG rng(123456789);
2012-08-14 15:36:32 +08:00
cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));
2012-08-14 15:36:32 +08:00
const int numLines = rng.uniform(100, 300);
for (int i = 0; i < numLines; ++i)
{
cv::Point p1(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
cv::Point p2(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
cv::line(src, p1, p2, cv::Scalar::all(255), 2);
}
2012-08-14 15:36:32 +08:00
2012-08-17 21:34:58 +08:00
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_lines;
2012-08-23 20:54:48 +08:00
cv::gpu::HoughLinesBuf d_buf;
2012-08-23 20:54:48 +08:00
cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);
2012-08-14 15:36:32 +08:00
2012-08-17 21:34:58 +08:00
TEST_CYCLE()
{
2012-08-23 20:54:48 +08:00
cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold);
2012-08-17 21:34:58 +08:00
}
}
else
2012-08-14 15:36:32 +08:00
{
2012-08-17 21:34:58 +08:00
std::vector<cv::Vec2f> lines;
cv::HoughLines(src, lines, rho, theta, threshold);
TEST_CYCLE()
{
cv::HoughLines(src, lines, rho, theta, threshold);
}
2012-08-14 15:36:32 +08:00
}
}
2012-08-23 20:54:48 +08:00
//////////////////////////////////////////////////////////////////////
// HoughCircles
DEF_PARAM_TEST(Sz_Dp_MinDist, cv::Size, float, float);
PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES, Values(1.0f, 2.0f, 4.0f), Values(1.0f, 10.0f)))
{
declare.time(30.0);
const cv::Size size = GET_PARAM(0);
const float dp = GET_PARAM(1);
const float minDist = GET_PARAM(2);
const int minRadius = 10;
const int maxRadius = 30;
const int cannyThreshold = 100;
const int votesThreshold = 15;
cv::RNG rng(123456789);
cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));
const int numCircles = rng.uniform(50, 100);
for (int i = 0; i < numCircles; ++i)
{
cv::Point center(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
const int radius = rng.uniform(minRadius, maxRadius + 1);
cv::circle(src, center, radius, cv::Scalar::all(255), -1);
}
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_circles;
cv::gpu::HoughCirclesBuf d_buf;
cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
TEST_CYCLE()
{
cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
}
}
else
{
std::vector<cv::Vec3f> circles;
cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
TEST_CYCLE()
{
cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
}
}
}
} // namespace