title: Template matching with multiple templates
body: <p>I am doing a project based on template matching using open-Cv. Here i need to check my source image with multiple templates an identify the correct template. The code is working perfectly for single template, but for multiple images i need to close the output window for every template. Although it matches correctly for respective template.kind of stuck here. Following is the code:</p>
  
  <pre><code>import cv2
  import numpy as np
  import os,sys
  import os.path
  import cv2, glob
  images=glob.glob(r'D:\python\template\Country\*.jpg')
  
  for image in images:
  img_rgb = cv2.imread(r'D:\python\EURO-10-F.jpg')
  img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
  
  template = cv2.imread(image,0)
  w, h = template.shape[::-1]
  
  print (img_gray.shape)
  r = 500.0 / img_gray.shape[1]
  dim = (500, int(img_gray.shape[0] * r))
  
  resized1 = cv2.resize(img_rgb, dim, interpolation = cv2.INTER_AREA)    
  resized2 = cv2.resize(img_gray, dim, interpolation = cv2.INTER_AREA)
  
  
  res = cv2.matchTemplate(resized2,template,cv2.TM_CCOEFF_NORMED)
  threshold = 0.5
  loc = np.where( res &gt;= threshold)
  
  
  for pt in zip(*loc[::-1]):
  cv2.rectangle(resized1,pt,(pt[0]+w,pt[1]+h),(0,255,255),2)
  
  cv2.imshow('detected',resized1)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>I was trying a for loop but dont know how to implement it getting error every time. </p>