Skip to content

Instantly share code, notes, and snippets.

@parkkk123
Last active September 12, 2020 05:45
Show Gist options
  • Save parkkk123/45d89b3c58e3be4c596ec9b80d8329df to your computer and use it in GitHub Desktop.
Save parkkk123/45d89b3c58e3be4c596ec9b80d8329df to your computer and use it in GitHub Desktop.
Getting start tesseract with python
from tesserocr import PyTessBaseAPI
from PIL import Image
#ใส่ Path ที่เก็บไฟล์ภาษา .traineddata
with PyTessBaseAPI(path='/home/..../tessdata/' ,lang="tha") as api:
#ลบช่องว่างแต่ละตัวอักษร
api.SetVariable('preserve_interword_spaces', '1')
#Path ของรูปภาพ
api.SetImageFile("Image.jpeg")
print(api.GetUTF8Text())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment