interested in computer vision and automation. Now I want to find a small image on another large image. For Python I have seen a large amount of code and everything just works for them.
But, it doesn’t work for me for some reason.
Source files:
var sourceImage = Cv2.ImRead("path");
var template = Cv2.ImRead("path");
var resultImage = new Mat();
Cv2.MatchTemplate(sourceImage, template, resultImage, TemplateMatchModes.CCoeffNormed);
Cv2.MinMaxLoc(resultImage, out _, out double maxVal, out _, out OpenCvSharp.Point maxLoc);
Rect rect = new Rect(maxLoc, new Size(template.Width, template.Height));
Cv2.Rectangle(sourceImage, rect, new Scalar(0, 255, 0), 2);
Cv2.ImShow("Result", sourceImage);
Cv2.WaitKey(0);
this is the result