Code:
public static Point SearchOne(Image<Bgr, byte> srcImg, Image<Bgr, byte> smpImg, double treshold, Rectangle roi, out bool success)
{
srcImg.ROI = roi;
Image<Gray, float> matched = srcImg.MatchTemplate(smpImg, TemplateMatchingType.CcoeffNormed);
matched.MinMax(out double[] minValues, out double[] maxValues, out Point[] minLocations, out Point[] maxLocations);
matched.Dispose();
if (maxValues[0] > treshold)
{
success = true;
int x = roi.X + maxLocations[0].X;
int y = roi.Y + maxLocations[0].Y;
return new Point(x, y);
}
success = false;
return Point.Empty;
}