Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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) {
if (LocFlag == 0) {
return minPoint;
else {
return maxPoint;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.