-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
The matchTemplate function changes the data of the mask. #23585
Copy link
Copy link
Closed
Description
System Information
OpenCV version: 4.7.0
Operating System / Platform: windows 10
Compiler & compiler version: visual studio 2019
Detailed description
When the matchTemplate function is used with a mask, the data of the mask changes and it is no longer usable.
mask is an InputArray and should not change, it should be read only.
Steps to reproduce
Mat src = Mat(1, 1, CV_8UC1, Scalar(255));
Mat templ = Mat(1, 1, CV_8UC1, Scalar(255));
Mat mask1 = Mat(1, 1, CV_8UC1, Scalar(255));
printf("before %d\n", mask1.at<uchar>(0, 0));
Mat res;
matchTemplate(src, templ, res, TemplateMatchModes::TM_CCOEFF_NORMED, mask1);
printf("after %d\n", mask1.at<uchar>(0, 0));Output:
before 255
after 1
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable