Skip to content

Commit 402bce1

Browse files
address template matching sqdiff bug
1 parent 0649a2f commit 402bce1

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

modules/imgproc/src/templmatch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst)
10361036
buffer.allocate( bufSize );
10371037

10381038
status = CV_INSTRUMENT_FUN_IPP(ippiSqrDistanceNorm, src.ptr(), (int)src.step, srcRoiSize, tpl.ptr(), (int)tpl.step, tplRoiSize, dst.ptr<Ipp32f>(), (int)dst.step, funCfg, buffer);
1039+
dst = cv::max(dst, 0); // handle edge case from rounding in variance computation which can result in negative values
10391040
return status >= 0;
10401041
}
10411042

0 commit comments

Comments
 (0)