pythonで画像から文字起こしする事に挑戦しています。
sample.pyを実行すると下記の通りエラー表示されます。
対応方法をご教示願えないでしょうか。
【sample.py】
from PIL import Image
import sys
import pyocr
import pyocr.builders
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
tool = tools[0]
print("Will use tool '%s'" % (tool.get_name()))
langs = tool.get_available_languages()
print("Available languages: %s" % ", ".join(langs))
lang = langs[0]
print("Will use lang '%s'" % (lang))
txt = tool.image_to_string(
Image.open('abc.png'),
lang=lang,
builder=pyocr.builders.TextBuilder()
)
print(txt)
【エラー状況】
C:\Users****\Desktop>python sample.py
Will use tool 'Tesseract (sh)'
Available languages: Error opening data file ;C:\Users****\Tesseract-OCR\tessdata/eng.traineddata, Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory., Failed loading language 'eng', Tesseract couldn't load any languages!
Will use lang 'Error opening data file ;C:\Users****\Tesseract-OCR\tessdata/eng.traineddata'
Traceback (most recent call last):
File "sample.py", line 23, in <module>
builder=pyocr.builders.TextBuilder()
File "C:\Users****\Anaconda3\lib\site-packages\pyocr\tesseract.py", line 366, in image_to_string
raise TesseractError(status, errors)
pyocr.error.TesseractError: (1, b'Error opening data file ;C:\Users*\Tesseract-OCR\tessdata/Error opening data file ;C:\Users*\Tesseract-OCR\tessdata/eng.traineddata.traineddata\r\nPlease make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.\r\nFailed loading language 'Error opening data file ;C:\Users****\Tesseract-OCR\tessdata/eng.traineddata'\r\nTesseract couldn't load any languages!\r\nCould not initialize tesseract.\r\n')
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。