圖片轉文字 ( OCR 圖片字元辨識 )

https://steam.oxxostudio.tw/category/python/example/image-ocr.html

from PIL import Image
import pytesseract

設定 Tesseract 的安裝路徑(如果需要)

pytesseract.pytesseract.tesseract_cmd = r’C:\Program Files\Tesseract-OCR\tesseract.exe’

讀取圖片

image_path = ‘img1.png’
image = Image.open(image_path)

使用繁體中文語言包進行 OCR 辨識

text = pytesseract.image_to_string(image, lang=’chi_tra’)

輸出辨識結果

print(text)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *