Exemple #1
0
 def create_char(self, font, char, directory):
     im_size = (self.font_size * 2, self.font_size * 2)
     img = Image.new("RGB", im_size, (255, 255, 255))
     draw = ImageDraw.Draw(img)
     draw.text((2, 2), char, (0, 0, 0), font=font)
     img = autocrop(img, "white")
     img = center_on_bg(img, self.comparison_size, "white")
     img_path = path(directory).joinpath("%05d.png" % ord(char))
     img.save(img_path)
     return img
Exemple #2
0
 def ocr(self, img):
     split = char_split(img)
     print len(split)
     return "".join(self.ocr_char(center_on_bg(im, self.comparison_size, "white")) for im in split)