I tried to remove the part I got the result but only in reverse order. So my question here is that why are we using that part to splice the array.
import numpy as np
import cv2
img = cv2.imread("E:/tmp/pis.jpg")
template = cv2.imread("E:/tmp/pi templates.jpg",0)
img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
w,h = template.shape[::-1]
res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.6
loc = np.where(res>=threshold)
for pt in zip(*loc[::-1]):
cv2.rectangle(img,pt,(pt[0]+w,pt[1]+h),(255,255,255),1)
cv2.imshow("img",img)
cv2.waitKey(0)
cv2.destroyAllWindows()