1 | initial version |
I guess you have read the documentation for matchTemplate: http://docs.opencv.org/modules/imgproc/doc/object_detection.html?highlight=matchtemplate#cv.MatchTemplate . If not please read it first.
So with matchTemplate you get a kinda probability-map and with minMaxLoc you get the location where it is the most probable that your template is located in the probability map (and thus also in your real image). So having the 5 maximas (or minimas depending on your template-matching method) which are pointing to the most probable locations in each image you can now just compare them. The heighest (lowest) value is the most probable match. The location of it relates to the top left corner of the template, i.e. the match you can then get by:
Mat match = image(cv::Rect(highest_maxLoc.x, highest_maxLoc.y, templateMat.cols, templateMat.rows));