From 344ea4963d5b3aa765cdab53a38c8f6e2034687a Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 25 Jul 2016 13:54:55 -0400 Subject: [PATCH] change output MatchTemplateByMatrix now only return the result matrix --- src/Matrix.cc | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/src/Matrix.cc b/src/Matrix.cc index 2ec6d4f..125b28c 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -2268,43 +2268,8 @@ NAN_METHOD(Matrix::MatchTemplateByMatrix) { int method = (info.Length() < 2) ? (int)cv::TM_CCORR_NORMED : info[1]->Uint32Value(); 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()); - double minVal; - double maxVal; - cv::Point minLoc; - cv::Point maxLoc; - cv::Point matchLoc; - minMaxLoc(m_out->mat, &minVal, &maxVal, &minLoc, &maxLoc, cv::Mat()); - - if(method == CV_TM_SQDIFF || method == CV_TM_SQDIFF_NORMED) { - matchLoc = minLoc; - } - else { - matchLoc = maxLoc; - } - - //detected ROI - unsigned int roi_x = matchLoc.x; - unsigned int roi_y = matchLoc.y; - unsigned int roi_width = templ->mat.cols; - unsigned int roi_height = templ->mat.rows; - - //draw rectangle - if(info.Length() >= 3) { - cv::Rect roi(roi_x,roi_y,roi_width,roi_height); - cv::rectangle(self->mat, roi, cv::Scalar(0,0,255)); - } - - m_out->mat.convertTo(m_out->mat, CV_8UC1, 255, 0); - - v8::Local arr = Nan::New(5); - arr->Set(0, out); - arr->Set(1, Nan::New(roi_x)); - arr->Set(2, Nan::New(roi_y)); - arr->Set(3, Nan::New(roi_width)); - arr->Set(4, Nan::New(roi_height)); - - info.GetReturnValue().Set(arr); + info.GetReturnValue().Set(out); } // @author ytham