I am a newbie in Image Processing and learning about Template Matching by getting some help from OpenCV documentation, but I didn\'t understand some lines of the code.
Here
The threshold 0.8 means the match should be at least 80% of template image and the source region of interest. Thus if it is greater than 80%, it is a coin. If you reduce the threshold the false positive results would increase even if it is not a coin.
for pt in zip(*loc[::-1]):
is for the points which have values greater than threshold. zip
is a container of all such points and it will iterate to all such points and draw rectangle around this closed entity i.e. coins here.
Threshold = 0.8 works according to lightness on the image you are working on. If lights are proper on your image then threshold > 0.8 will work but mostly in camera images brightness varies so lightness > 0.65 can work. To match more points you have to reduce your threshold value.