Embadded image into directory

Hello,
I try to find if a new image or a portion of the image if it corresponds to a list of images in a directory, I wrote this script but it is not very efficient
##############################
import cv2
import numpy as np
import os
import glob
path = “/home/tse/Images/pictures/20/.
for file in glob.glob(path):
print(file)
img_rgb = cv2.imread(file)
template = cv2.imread(‘redu.png’)
h, w = template.shape[:-1]
res = cv2.matchTemplate(img_rgb, template, cv2.TM_CCOEFF_NORMED)
threshold = .9
loc = np.where(res >= threshold)
for pt in zip(*loc[::-1]): # Switch collumns and rows
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2)
cv2.imwrite(‘result.png’, img_rgb)