def findAround(pic, pat, xy=None, r=None):
 if (xy and r):
  (h, w) = pat.shape[:2]
  (x, y) = xy
  pic = pic[(y - r):((y + h) + r), (x - r):((x + w) + r)]
 matches = cv2.matchTemplate(pat, pic, cv2.TM_CCOEFF_NORMED)
 (yf, xf) = np.unravel_index(matches.argmax(), matches.shape)
 return ((((x - r) + xf), ((y - r) + yf)) if (xy and r) else (xf, yf))

def findAround ( pic , pat , xy = None , r = None ) : if ( xy and r ) : ( h , w ) = pat . shape [ : 2 ] ( x , y ) = xy pic = pic [ ( y - r ) : ( ( y + h ) + r ) , ( x - r ) : ( ( x + w ) + r ) ] matches = cv2 . matchTemplate ( pat , pic , cv2 . TM_CCOEFF_NORMED ) ( yf , xf ) = np . unravel_index ( matches . argmax ( ) , matches . shape ) return ( ( ( ( x - r ) + xf ) , ( ( y - r ) + yf ) ) if ( xy and r ) else ( xf , yf ) )
find image pattern pat in pic[x +/- r .