Bugfix for an overlapping size of image and template for matchTemplate.

Example: img of size 10x10 and templ of size 11x9.
In subsequent code this will results in either width or height of
corrSize to be zero (0).
Line 261 will call crossCorr which will then have a zero size of either
blocksize.width or blocksize.height resulting in a division by zero
crach in lines 137 or 138.
This commit is contained in:
Heinz Hofbauer 2013-07-03 14:58:40 +02:00
parent 6bf8f474fa
commit a26c4fa2a2

View File

@ -248,6 +248,8 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
CV_Assert( (img.depth() == CV_8U || img.depth() == CV_32F) &&
img.type() == templ.type() );
CV_Assert( img.rows >= templ.rows && img.cols >= templ.cols);
Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1);
_result.create(corrSize, CV_32F);
Mat result = _result.getMat();