This source file includes following definitions.
- PERF_TEST_P
- PERF_TEST_P
#include "perf_precomp.hpp"
using namespace std;
using namespace testing;
using namespace perf;
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, MatCn, TemplateMethod);
PERF_TEST_P(Sz_TemplateSz_Cn_Method, MatchTemplate8U,
Combine(CUDA_TYPICAL_MAT_SIZES,
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
CUDA_CHANNELS_1_3_4,
TemplateMethod::all()))
{
declare.time(300.0);
const cv::Size size = GET_PARAM(0);
const cv::Size templ_size = GET_PARAM(1);
const int cn = GET_PARAM(2);
const int method = GET_PARAM(3);
cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn));
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));
declare.in(image, templ, WARMUP_RNG);
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_image(image);
const cv::cuda::GpuMat d_templ(templ);
cv::cuda::GpuMat dst;
cv::Ptr<cv::cuda::TemplateMatching> alg = cv::cuda::createTemplateMatching(image.type(), method);
TEST_CYCLE() alg->match(d_image, d_templ, dst);
CUDA_SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
}
else
{
cv::Mat dst;
TEST_CYCLE() cv::matchTemplate(image, templ, dst, method);
CPU_SANITY_CHECK(dst);
}
}
PERF_TEST_P(Sz_TemplateSz_Cn_Method, MatchTemplate32F,
Combine(CUDA_TYPICAL_MAT_SIZES,
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
CUDA_CHANNELS_1_3_4,
Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))))
{
declare.time(300.0);
const cv::Size size = GET_PARAM(0);
const cv::Size templ_size = GET_PARAM(1);
const int cn = GET_PARAM(2);
int method = GET_PARAM(3);
cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn));
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));
declare.in(image, templ, WARMUP_RNG);
if (PERF_RUN_CUDA())
{
const cv::cuda::GpuMat d_image(image);
const cv::cuda::GpuMat d_templ(templ);
cv::cuda::GpuMat dst;
cv::Ptr<cv::cuda::TemplateMatching> alg = cv::cuda::createTemplateMatching(image.type(), method);
TEST_CYCLE() alg->match(d_image, d_templ, dst);
CUDA_SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
else
{
cv::Mat dst;
TEST_CYCLE() cv::matchTemplate(image, templ, dst, method);
CPU_SANITY_CHECK(dst);
}
}