2013-02-04 16:57:22 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace perf;
|
|
|
|
using std::tr1::make_tuple;
|
|
|
|
using std::tr1::get;
|
|
|
|
|
2013-04-06 22:16:51 +08:00
|
|
|
CV_ENUM(MethodType, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
|
2013-02-04 16:57:22 +08:00
|
|
|
|
|
|
|
typedef std::tr1::tuple<Size, Size, MethodType> ImgSize_TmplSize_Method_t;
|
|
|
|
typedef perf::TestBaseWithParam<ImgSize_TmplSize_Method_t> ImgSize_TmplSize_Method;
|
|
|
|
|
|
|
|
PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateSmall,
|
|
|
|
testing::Combine(
|
|
|
|
testing::Values(szSmall128, cv::Size(320, 240),
|
|
|
|
cv::Size(640, 480), cv::Size(800, 600),
|
|
|
|
cv::Size(1024, 768), cv::Size(1280, 1024)),
|
|
|
|
testing::Values(cv::Size(12, 12), cv::Size(28, 9),
|
|
|
|
cv::Size(8, 30), cv::Size(16, 16)),
|
2013-04-15 23:39:49 +08:00
|
|
|
MethodType::all()
|
2013-02-04 16:57:22 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Size imgSz = get<0>(GetParam());
|
|
|
|
Size tmplSz = get<1>(GetParam());
|
|
|
|
int method = get<2>(GetParam());
|
|
|
|
|
|
|
|
Mat img(imgSz, CV_8UC1);
|
|
|
|
Mat tmpl(tmplSz, CV_8UC1);
|
|
|
|
Mat result(imgSz - tmplSz + Size(1,1), CV_32F);
|
|
|
|
|
|
|
|
declare
|
|
|
|
.in(img, WARMUP_RNG)
|
|
|
|
.in(tmpl, WARMUP_RNG)
|
2013-02-20 20:59:17 +08:00
|
|
|
.out(result)
|
|
|
|
.time(30);
|
2013-02-04 16:57:22 +08:00
|
|
|
|
|
|
|
TEST_CYCLE() matchTemplate(img, tmpl, result, method);
|
|
|
|
|
2013-02-04 17:29:52 +08:00
|
|
|
bool isNormed =
|
2013-04-06 22:16:51 +08:00
|
|
|
method == TM_CCORR_NORMED ||
|
|
|
|
method == TM_SQDIFF_NORMED ||
|
|
|
|
method == TM_CCOEFF_NORMED;
|
2014-04-15 15:35:30 +08:00
|
|
|
double eps = isNormed ? 1e-5
|
2013-02-04 17:29:52 +08:00
|
|
|
: 255 * 255 * tmpl.total() * 1e-6;
|
|
|
|
|
|
|
|
SANITY_CHECK(result, eps);
|
2013-02-04 16:57:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateBig,
|
|
|
|
testing::Combine(
|
|
|
|
testing::Values(cv::Size(1280, 1024)),
|
|
|
|
testing::Values(cv::Size(1260, 1000), cv::Size(1261, 1013)),
|
2013-04-15 23:39:49 +08:00
|
|
|
MethodType::all()
|
2013-02-04 16:57:22 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Size imgSz = get<0>(GetParam());
|
|
|
|
Size tmplSz = get<1>(GetParam());
|
|
|
|
int method = get<2>(GetParam());
|
|
|
|
|
|
|
|
Mat img(imgSz, CV_8UC1);
|
|
|
|
Mat tmpl(tmplSz, CV_8UC1);
|
|
|
|
Mat result(imgSz - tmplSz + Size(1,1), CV_32F);
|
|
|
|
|
|
|
|
declare
|
|
|
|
.in(img, WARMUP_RNG)
|
|
|
|
.in(tmpl, WARMUP_RNG)
|
2013-02-20 20:59:17 +08:00
|
|
|
.out(result)
|
|
|
|
.time(30);
|
2013-02-04 16:57:22 +08:00
|
|
|
|
|
|
|
TEST_CYCLE() matchTemplate(img, tmpl, result, method);
|
|
|
|
|
2013-02-04 17:29:52 +08:00
|
|
|
bool isNormed =
|
2013-04-06 22:16:51 +08:00
|
|
|
method == TM_CCORR_NORMED ||
|
|
|
|
method == TM_SQDIFF_NORMED ||
|
|
|
|
method == TM_CCOEFF_NORMED;
|
2013-02-04 17:29:52 +08:00
|
|
|
double eps = isNormed ? 1e-6
|
2014-04-24 14:48:32 +08:00
|
|
|
: 255.0 * 255.0 * (double)tmpl.total() * 1e-6;
|
2013-02-04 17:29:52 +08:00
|
|
|
|
|
|
|
SANITY_CHECK(result, eps);
|
2013-02-04 16:57:22 +08:00
|
|
|
}
|