Ubuntu18.04 下python3简单提取图片中数字为文本

Ubuntu18.04 下python3简单提取图片中数字为文本

    1、首先确认相关模块是否已经安装!

                〔1〕tesseract 识别引擎

                        终端下输入 tesseract -v  获取识别引擎是否安装

Ubuntu18.04 下python3简单提取图片中数字为文本_第1张图片

                〔2〕pytesseract 模块

                        终端下输入 pip3 install pytesseract    等待安装完成  

    2、找到所需图片,我随便找了一个!放到你能知道到的目录下

                我放在了  /home/bingyan/Desktop/123.png    一会会用到   ps:其他图片格式也可以,可以自测

    3、进入python命令行,我用的是ipython  无所谓除了进入的方法不一样其他都一样

                〔1〕import pytesseract 

                〔2〕from PIL import Image

                〔3〕str = pytesseract.image_to_string(Image.open('/home/bingyan/Desktop/123.png '), lang='eng')

                〔4〕str

Ubuntu18.04 下python3简单提取图片中数字为文本_第2张图片

你可能感兴趣的:(Ubuntu18.04 下python3简单提取图片中数字为文本)