如何解析图片文字进行文本分析

2021-11-16  本文已影响0人  dreampai

最近工作中需要解析图片中的文本信息,进行文本数据分析,首先需要提取图片中的文字,解决方案如下:

1、需要安装包

pip install Pillow
pip install pytesseract

2、提取示例

from PIL import Image
import pytesseract
im = Image.open('test.jpg')
print (pytesseract.image_to_string(im))

3、可能遇到问题

pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.

解决方案:

from PIL import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = "D:\\software\\tesseract_ocr\\tesseract.exe"
im = Image.open('test.jpg')
print (pytesseract.image_to_string(im))

4、参考链接

通过以上方案,完美解决了图片文字分析,英文文字识别率较高,你有什么好的解决方案,欢迎留言区交流学习。

如有需求,可以私聊合作。

上一篇 下一篇

猜你喜欢

热点阅读