mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
12eaf9bd4c
When computing TM_SQDIFF for 8-bit images, crossCorr stores intermediate results in CV_32F which loses precision for large patch sums (e.g. 25x25 patch of value 255 gives sum=40603125, exceeding float32's ~7 significant digits). This causes the final SQDIFF result to have incorrect non-zero values even when image and template are identical. Fix: use a CV_64F intermediate buffer for crossCorr and common_matchTemplate when depth==CV_8U and method is TM_SQDIFF or TM_SQDIFF_NORMED, then convert back to CV_32F for the final output. Fixes #21786