Your result will depend on the method you use for template matching, since in your case the values are binary (0 or 255), I expected the cross correlation to work well, I tried it and voilà:
It seems that it's not well documented how each method works.
But a good debugging method for these problems is to see the result of the matching to see where it's giving the maximum values, in your case the res variable.
I followed the tutorial in this website, my final code is:
import numpy as np
import matplotlib.pyplot as plt
import cv2
R = cv2.imread('image.png')
R = cv2.Canny(R, 50, 200)
template = cv2.imread('templ.png',0)
template = cv2.Canny(template, 50, 200)
w, h = template.shape[::-1]
res = cv2.matchTemplate(R,template,cv2.TM_CCORR )
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
top_left = max_loc
bottom_right = (top_left[0] + w, top_left[1] + h)
cv2.rectangle(R,top_left, bottom_right, 255, 2)
cv2.imwrite( './result.png', R)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…