Merge pull request #2383 from ilya-lavrenov:perf_match_template

This commit is contained in:
Andrey Pavlenko 2014-02-20 21:36:30 +04:00 committed by OpenCV Buildbot
commit f04a158268

View File

@ -23,19 +23,14 @@ namespace ocl {
)
)
{
Size imgSz = get<0>(GetParam());
Size tmplSz = get<1>(GetParam());
int method = get<2>(GetParam());
const ImgSize_TmplSize_Method_t params = GetParam();
const Size imgSz = get<0>(params), tmplSz = get<1>(params);
const int method = get<2>(params);
UMat img(imgSz, CV_8UC1);
UMat tmpl(tmplSz, CV_8UC1);
UMat img(imgSz, CV_8UC1), tmpl(tmplSz, CV_8UC1);
UMat result(imgSz - tmplSz + Size(1, 1), CV_32F);
declare
.in(img, WARMUP_RNG)
.in(tmpl, WARMUP_RNG)
.out(result)
.time(30);
declare.in(img, tmpl, WARMUP_RNG).out(result);
OCL_TEST_CYCLE() matchTemplate(img, tmpl, result, method);
@ -51,7 +46,49 @@ namespace ocl {
else
SANITY_CHECK(result, eps);
}
}
/////////// matchTemplate (performance tests from 2.4) ////////////////////////
typedef Size_MatType CV_TM_CCORRFixture;
OCL_PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
::testing::Combine(::testing::Values(Size(1000, 1000), Size(2000, 2000)),
OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params), templSize(5, 5);
const int type = get<1>(params);
UMat src(srcSize, type), templ(templSize, type);
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
UMat dst(dstSize, CV_32F);
declare.in(src, templ, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR);
SANITY_CHECK(dst, 1e-4);
}
typedef TestBaseWithParam<Size> CV_TM_CCORR_NORMEDFixture;
OCL_PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate,
::testing::Values(Size(1000, 1000), Size(2000, 2000), Size(4000, 4000)))
{
const Size srcSize = GetParam(), templSize(5, 5);
UMat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1);
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
UMat dst(dstSize, CV_8UC1);
declare.in(src, templ, WARMUP_RNG).out(dst);
OCL_TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR_NORMED);
SANITY_CHECK(dst, 3e-2);
}
} }
#endif // HAVE_OPENCL