繁体   English   中英

使用pytesseract从图像中提取文本

[英]Extract text from image using pytesseract

我想使用Python从以下图像中提取文本:

在此处输入图片说明

我试过下面的代码,但它抛出了一个错误:

import pytesseract
from PIL import Image
img=Image.open(r'gif file path')
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract- 
OCR/tesseract'

r=pytesseract.image_to_string(img)
print(r)

And 

from PIL import Image
from pytesseract import image_to_string
img=Image.open('gif file path')
text=image_to_string(img)
print(text)

错误:

TesseractNotFoundError。

请帮助以任何方式使用Python获取文本。

注意: pytesseract已经安装。

一件事是安装库 pytesseract,另一件事是安装 Tesseract。

如果您使用的是 Linux,请尝试:

sudo apt install libtesseract-dev tesseract-ocr

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM