前バージョンとは若干の記述(クラス)が違いますが、基本的には同じですね。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private OpenCvSharp.Point getTemplateAreaLocation(Mat matTarget, Mat matTemplate, int LocFlag) { | |
Mat result = new Mat(matTarget.Height - matTemplate.Height + 1, matTarget.Width - matTemplate.Width + 1, MatType.CV_8UC1); | |
OpenCvSharp.Point minPoint = new OpenCvSharp.Point(); | |
OpenCvSharp.Point maxPoint = new OpenCvSharp.Point(); | |
try { | |
Cv2.MatchTemplate(matTarget, matTemplate, result, TemplateMatchModes.CCoeff); | |
Cv2.MinMaxLoc(result, out minPoint, out maxPoint); | |
} | |
catch (OpenCvSharp.OpenCVException ee) { | |
System.Diagnostics.Debug.WriteLine(ee.ErrMsg); | |
} | |
if (LocFlag == 0) { | |
return minPoint; | |
} | |
else { | |
return maxPoint; | |
} | |
} |