私はtesserocrの問題を解決する方法に関する提案をお願いしたいと思います。Tesserocrはテキストを認識しませんでした
これは画像です。ソースはSimple Digit Recognition OCR in OpenCV-Python
コードからである
from PIL import Image
from tesserocr import PyTessBaseAPI, RIL
image = Image.open('test3.png')
with PyTessBaseAPI() as api:
api.SetImage(image)
boxes = api.GetComponentImages(RIL.TEXTLINE, True)
print 'Found {} textline image components.'.format(len(boxes))
for i, (im, box, _, _) in enumerate(boxes):
api.SetRectangle(box['x'], box['y'], box['w'], box['h'])
ocrResult = api.GetUTF8Text()
conf = api.MeanTextConf()
result = (u"Box[{0}]: x={x}, y={y}, w={w}, h={h}, "
"confidence: {1}, text: {2}").format(i, conf, ocrResult, **box)
print result
結果は、この
Found 5 textline image components.
Box[0]: x=10, y=5, w=582, h=29, confidence: 81, text: 9821480865132823066470938
Box[1]: x=9, y=55, w=581, h=30, confidence: 91, text: 4460955058223172535940812
Box[2]: x=10, y=106, w=575, h=30, confidence: 90, text: 8481117450284102701938521
Box[3]: x=12, y=157, w=580, h=30, confidence: 0, text:
Box[4]: x=11, y=208, w=581, h=30, confidence: 89, text: 6442881097566593344612847
それは私が何を追加する必要がありますボックス3の数を認識したり変更しなかったようなものですスクリプトは、ボックス3が適切な結果を表示するように?
ありがとうございました。
提案していただきありがとうございますが、 'tesseroc'を使って' tesseract'を 'v4.0'にアップグレードする方法について詳しく説明できますか? 'python virtual environment'に' pip install tesserocr'で 'tesserocr'バージョン2.1.3をインストールしました。私はどのように進めるべきですか? – Fang
@Fangアップグレードに関する回答のEDITを参照してください。私の返信が役に立って、それ以上の質問がなければ、答えをチェックして質問を閉じることができます。 – thewaywewere
遅く返事を申し訳ありません。私はリンクから提供された答えの指示に従った。 'git checkout tesseract4'を実行し、' pip install 'を実行します。しかし、上記のスクリプトを実行しても問題は解決しませんでした。他の依存関係を追加する/スクリプトをさらに変更する必要はありますか? – Fang