Форум сайта python.su
Не получается нормально установить pytesseract ( Py 2.7 or 3.4) . Установил PIL , python-tesseract and tesseract-ocr. Например при вызове print pytesseract.image_to_string(Image.open('C:\Python27\lib\site-packages\PIL\test.png')) выдает: IOError: invalid mode ('rb') or filename: ‘C:\\Python27\\lib\\site-packages\\PIL\test.png’ .
Офлайн
\t в пути воспринимается как табуляция. Поставь r перед кавычками.
Офлайн
В этом случае:
>>> print pytesseract.image_to_string(Image.open(r'C:\Python27\lib\site-packages\PIL\test.png'))
Traceback (most recent call last):
File “<pyshell#26>”, line 1, in <module>
print pytesseract.image_to_string(Image.open(r'C:\Python27\lib\site-packages\PIL\test.png'))
File “build\bdist.win-amd64\egg\pytesseract\pytesseract.py”, line 142, in image_to_string
config=config)
File “build\bdist.win-amd64\egg\pytesseract\pytesseract.py”, line 75, in run_tesseract
stderr=subprocess.PIPE)
File “C:\Python27\lib\subprocess.py”, line 709, in __init__
errread, errwrite)
File “C:\Python27\lib\subprocess.py”, line 957, in _execute_child
startupinfo)
WindowsError: The system cannot find the file specified
Офлайн
img = Image.open(r'C:\Python27\lib\site-packages\PIL\test.png') print pytesseract.image_to_string(img)
import pytesseract help(pytesseract.image_to_string)
Офлайн
from PIL import Image import pytesseract img = Image.open(r'C:\Python27\lib\site-packages\PIL\test.png') print pytesseract.image_to_string(img)
import pytesseract.pytesseract
help(pytesseract.image_to_string)
Help on function image_to_string in module pytesseract.pytesseract: image_to_string(image, lang=None, boxes=False, config=None) Runs tesseract on the specified image. First, the image is written to disk, and then the tesseract command is run on the image. Resseract's result is read, and the temporary files are erased. also supports boxes and config. if boxes=True "batch.nochop makebox" gets added to the tesseract call if config is set, the config gets appended to the command. ex: config="-psm 6"
Отредактировано eddes (Янв. 11, 2015 12:44:02)
Офлайн