mirror of
https://github.com/opencv/opencv.git
synced 2026-11-24 02:07:54 -06:00
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