title: Want to speed up template matching in OpenCV python
body: <p>I am with the code below to detect multiple images on the screen using multiple source images to detect different object on screen.
  found this <a href="https://stackoverflow.com/questions/43339287/template-matching-with-multiple-source-images-in-opencv-and-python/43341663">link</a> with solution but when applied my fps drops down drastically</p>
  <pre><code>import cv2 as cv
  import numpy as np
  import os
  from time import time
  import mss
  
  
  os.chdir(os.path.dirname(os.path.abspath(__file__)))
  
  imgs = ['car.png', 'bear.png', 'computer.png', 'log.png', 'utensils.png',
          'bench.png', 'river.png', 'keepdistance.png', 'waste.png', 'player.png']
  
  
  def findClickPostion(needle_img_path, haystack_img):
  
      #    haystack_img = cv.imread('/Users/amanrai/Desktop/conquer2020/main.png', cv.IMREAD_UNCHANGED)
      needle_img = cv.imread(needle_img_path, cv.IMREAD_UNCHANGED)
  
      result = cv.matchTemplate(haystack_img, needle_img, cv.TM_CCOEFF_NORMED)
  
      min_val, max_val, min_loc, max_loc = cv.minMaxLoc(result)
  
      threshold = 0.8
      if max_val &gt;= threshold:
          needle_w = needle_img.shape[1]
          needle_h = needle_img.shape[0]
          top_left = max_loc
          bottom_left = (top_left[0] + needle_w, top_left[1] + needle_h)
          print('Found')
          cv.rectangle(haystack_img, top_left, bottom_left, color=(
              0, 255, 0), thickness=2, lineType=cv.LINE_4)
          cv.imshow('result', haystack_img)
          # cv.waitKey()
      else:
          print('Not Found')
  
  
  loop_time = time()
  with mss.mss() as sct:
      monitor = {&quot;top&quot;: 450, &quot;left&quot;: 0, &quot;width&quot;: 1438,
                 &quot;height&quot;: 450}  # &quot;width&quot;: 1500, &quot;height&quot;: 860
      while (True):
  
          screenshot = np.array(sct.grab(monitor))
          #screenshot = cv.cvtColor(screenshot, cv.COLOR_RGB2BGR)
  
          #cv.imshow('Computer Vision', screenshot)
          for ik in imgs:
              findClickPostion(ik, screenshot)
  
              print('FPS {}'.format(1 / (time() - loop_time)))
              loop_time = time()
  
          if cv.waitKey(1) == ord('q'):
              cv.destroyAllWindows()
              break
  
  
  print('done')
  </code></pre>
  <p>what I want to achieve is  to speed up the process so that it detects multiple objects on screen without losing any fps.
  I am using this without GPU.</p>