From e578cdb869f2c3aed1e23dd65da7305a179ff37e Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 25 Jul 2016 16:47:15 -0400 Subject: [PATCH] Add method range check Method can be only 0~5, if other number supply will default to TM_CCORR_NORMED. --- src/Matrix.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Matrix.cc b/src/Matrix.cc index 125b28c..b99baf8 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -2266,9 +2266,8 @@ NAN_METHOD(Matrix::MatchTemplateByMatrix) { */ int method = (info.Length() < 2) ? (int)cv::TM_CCORR_NORMED : info[1]->Uint32Value(); + if (!(method >= 0 && method <= 5)) method = (int)cv::TM_CCORR_NORMED; cv::matchTemplate(self->mat, templ->mat, m_out->mat, method); - cv::normalize(m_out->mat, m_out->mat, 0, 1, cv::NORM_MINMAX, -1, cv::Mat()); - info.GetReturnValue().Set(out); }