Tôi đang sử dụng pytesseract và đã xem xét một số giải pháp nhóm của google nhưng chúng dường như không hoạt động đối với tôi.pytesseract không thể tìm thấy tệp được chỉ định
Mã của tôi là thẳng về phía trước và sau:
from PIL import ImageFilter
import sys
from PIL import Image
import PIL.ImageOps
import pytesseract
import time
image=Image.open("C:/temp/download.png")
image.load()
background = Image.new("RGB", image.size, (255, 255, 255))
background.paste(image, mask=image.split()[3]) # 3 is the alpha channel
background.save('C:/temp/foo.jpg', 'JPEG', quality=80)
img =Image.open('C:/temp/foo.jpg')
img.load()
print img
print '-------------------'
i = pytesseract.image_to_string(img)
print i
và phản ứng lỗi tôi nhận được lại là:
Traceback (most recent call last):
File "img.py", line 20, in <module>
i = pytesseract.image_to_string(img)
File "build\bdist.win32\egg\pytesseract\pytesseract.py", line 161, in image_to
_string
File "build\bdist.win32\egg\pytesseract\pytesseract.py", line 94, in run_tesse
ract
File "C:\Users\%USER%\AppData\Local\Continuum\Anaconda\lib\subprocess.py",
line 710, in __init__
errread, errwrite)
File "C:\Users\%USER%\AppData\Local\Continuum\Anaconda\lib\subprocess.py",
line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Bất kỳ hướng dẫn sẽ là tuyệt vời.
Thêm Tesseract để biến con đường của tôi giúp: C:\Program Files (x86)\Tesseract-OCR
Nhưng mã ngay bây giờ bị treo khi cố gắng chạy mảnh pytesseract.
Bạn có thể thử sử dụng thư viện này khác sử dụng Tesseract bằng Python: [pyslibtesseract] (https://github.com/brunomacabeusbr/pyslibtesseract). Thư viện này sử dụng một cách khác để tải hình ảnh. – Macabeus