コード例 #1
0
 def __patternmatch(cls, reference, target):
     L.debug("reference : %s" % reference)
     img_rgb = cv2.imread(reference)
     img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
     template = cv2.imread(target, 0)
     w, h = template.shape[::-1]
     res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
     loc = numpy.where( res >= THRESHOLD)
     result = None
     for pt in zip(*loc[::-1]):
         result = POINT(pt[0], pt[1], w, h)
     return result
コード例 #2
0
 def get_picture(cls, path):
     try:
         return Image.open(path, 'r')
     except IOError, (errno, strerror):
         L.debug("I/O error(%s): %s" % (errno, strerror))
         raise IOError(strerror)