Fix mask thresholding

This commit is contained in:
Dmitry Kurtaev 2023-05-26 18:51:33 +03:00
parent 6157db6462
commit c97942cf78

View File

@ -779,11 +779,9 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _
} }
if (mask.depth() == CV_8U) if (mask.depth() == CV_8U)
{ {
Mat mask_copy = mask.clone(); // Create a copy of the mask Mat maskBin;
threshold(mask, maskBin, 0/*threshold*/, 1.0/*maxVal*/, THRESH_BINARY);
threshold(mask_copy, mask_copy, 0/*threshold*/, 1.0/*maxVal*/, THRESH_BINARY); maskBin.convertTo(mask, CV_32F);
mask_copy.convertTo(mask_copy, CV_32F);
} }
Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1); Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1);