Skip to content

Instantly share code, notes, and snippets.

@Temptationx
Created February 9, 2015 21:19
Show Gist options
  • Save Temptationx/29d7d6f5aebf0a7f1910 to your computer and use it in GitHub Desktop.
Save Temptationx/29d7d6f5aebf0a7f1910 to your computer and use it in GitHub Desktop.
opencv match template
void match(Mat &a, Mat &b)
{
Mat r;
matchTemplate(a, b, r, CV_TM_SQDIFF_NORMED);
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc(r, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
rectangle(a, maxLoc, Point(maxLoc.x + b.cols, maxLoc.y + b.rows), Scalar(255));
imshow("1", r);
imshow("2", a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment