code: def findAllMatches(self, needle, similarity):
          
          positions = []
          method = cv2.TM_CCOEFF_NORMED
  
          match = cv2.matchTemplate(self.haystack, self.needle, method)
  
          indices = (-match).argpartition(100, axis=None)[:100] # Review the 100 top matches
          unraveled_indices = numpy.array(numpy.unravel_index(indices, match.shape)).T
          for location in unraveled_indices:
              y, x = location
              confidence = match[y][x]
              if method == cv2.TM_SQDIFF_NORMED or method == cv2.TM_SQDIFF:
                  if confidence <= 1-similarity:
                      positions.append(((x, y), confidence))
              else:
                  if confidence >= similarity:
                      positions.append(((x, y), confidence))
  
          positions.sort(key=lambda x: (x[0][1], x[0][0]))
          return positions
docs: Find all matches for ``needle`` with confidence better than or equal to ``similarity``.
  
          Returns an array of tuples ``(position, confidence)`` if match(es) is/are found,
          or an empty array otherwise.