import tesserocr from PIL import Image image = Image.open('222.jpg') image = image.convert('L') threshold = 127 table = [] for i in range(256): if i < threshold: table.append(0) else: table.append(1) image = image.point(table, '1') image.show() result = tesserocr.image_to_text(image) print(result)
import tesserocr from PIL import Image image = Image.open('111.jpg') result = tesserocr.image_to_text(image) print(result)
若是圖片未經處理直接交由tesserocr解析,也可能識別率很低。python
一般狀況下,咱們還須要作些額外的圖片處理,如轉灰度圖,二值化等。app