From e383d39598e4f09063067ed2f4953d8dbd756b3a Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 9 Jan 2013 17:53:19 +0400 Subject: [PATCH] fixed bug #2679 --- modules/imgproc/src/templmatch.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 5e1ad20343..0a3b95d7c7 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -346,7 +346,10 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, } if( numType == 2 ) + { num = wndSum2 - 2*num + templSum2; + num = MAX(num, 0.); + } } if( isNormed )