conda
だと2.7しかないようですね。
Bash
1$ conda install -c auto pyocr
2Solving environment: |
3Warning: 2 possible package resolutions (only showing differing packages):
4 - auto::mistune-0.2.0-py27_0, defaults::nbconvert-5.2.1-py27_0
5 - defaults::mistune-0.8.3-py27h14c3975_1, defaults::nbconvert-5.3.1-py27he041f76done
6 (略)
当方環境(Win10のWSL)にてpip
にて3.6.x環境に導入でき、OCR動作しました。
Bash
1$ pip install pyocr
2Collecting pyocr
3Requirement already satisfied: six in ./anaconda3/lib/python3.6/site-packages (from pyocr) (1.11.0)
4Requirement already satisfied: Pillow in ./anaconda3/lib/python3.6/site-packages (from pyocr) (5.1.0)
5Installing collected packages: pyocr
6Successfully installed pyocr-0.5.1
tesseract_test.py
Python
1from PIL import Image
2import sys
3import pyocr
4import pyocr.builders
5
6tools = pyocr.get_available_tools()
7if len(tools) == 0:
8 print("No OCR tool found")
9 sys.exit(1)
10tool = tools[0]
11print("Will use tool '%s'" % (tool.get_name()))
12
13langs = tool.get_available_languages()
14print("Available languages: %s" % ", ".join(langs))
15
16txt = tool.image_to_string( Image.open('tesseract.png'), lang='jpn', builder=pyocr.builders.TextBuilder())
17print(txt)
実行結果
Bash
1$ python tesseract_test.py
2Will use tool 'Tesseract (sh)'
3Available languages: eng, jpn
4d0g Cat
5
6犬 猫
7
8今日の天気は晴れです。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/04 10:27
2018/07/04 10:29