pip install pytesseract
pip install pillow
python
import pytesseract
from PIL import Image
image = Image.open('image.jpg')
text = pytesseract.image_to_string(image, lang='chi_sim')
print(text)
python
import pytesseract
from PIL import Image
import os
directory = './images'
files = os.listdir(directory)
for file in files:
filepath = os.path.join(directory, file)
if filepath.lower().endswith(('.jpg', '.jpeg')):
image = Image.open(filepath)
text = pytesseract.image_to_string(image, lang='chi_sim')
print(text)