亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

Python實現OCR識別之pytesseract案例詳解

瀏覽:14日期:2022-06-14 17:34:51
Python實現OCR識別:pytesseract

Python常用pytesseract進行圖片上的文字識別,即OCR識別,完整的代碼比較簡單,只要下面一行即可,但是實際使用時環境配置上容易出錯。

from PIL import Imageimport pytesseract text = pytesseract.image_to_string(Image.open(’/Users/alice/Documents/Develop/PythonCode/textinphoto.PNG’))print(text)

因此使用前,需要先安裝pillow和pytesseract依賴包。

然而運行時仍然報錯,raise TesseractNotFoundError()pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your path

原因是因為未安裝tesseract,然后使用pip3 install tesseract之后仍然提示錯誤,如圖:

alicedembp:~ alice$ pip3 install tesseractRequirement already satisfied: tesseract in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.1.3)alicedembp:~ alice$ tesseract-bash: tesseract: command not found

無法使用,往上找了很多教程,說是要使用brew安裝,于是得以解決,步驟為:

先安裝brew

alicedembp:~ alice$ ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)' 再使用brew安裝leptonica

alicedembp:~ alice$ brew install leptonica 使用brew安裝tesseract

alicedembp:~ alice$ brew install tesseract 安裝成功,通過命令行tesseract -v的方式查看是否成功,出現版本號則為安裝成功

alicedembp:~ alice$ tesseractUsage: tesseract --help | --help-extra | --version tesseract --list-langs tesseract imagename outputbase [options...] [configfile...] OCR options: -l LANG[+LANG]Specify language(s) used for OCR.NOTE: These options must occur before any configfile. Single options: --helpShow this help message. --help-extra Show extra help for advanced users. --version Show version information. --list-langs List available languages for tesseract engine. alicedembp:~ alice$ tesseract -vtesseract 4.0.0 leptonica-1.78.0 libgif 5.1.4 : libjpeg 9c : libpng 1.6.36 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 1.0.2 : libopenjp2 2.3.1 Found AVX2 Found AVX Found SSE

接下來就可以直接使用了,使用如下代碼:

alicedembp:~ alice$ tesseract /Users/alice/Documents/Develop/PythonCode/textinphoto.png /Users/alice/Documents/Develop/PythonCode/output.txt

打開textinphoto.PNG的圖片,將文字輸出到output.txt,圖片如下

Python實現OCR識別之pytesseract案例詳解

運行成功,產生output.txt文檔,里面的文本為圖片中識別出的文字。

Python實現OCR識別之pytesseract案例詳解

到此這篇關于Python實現OCR識別之pytesseract案例詳解的文章就介紹到這了,更多相關python OCR識別之pytesseract內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

主站蜘蛛池模板: 奇米影视狠狠久久中文 | 国产成人久久精品一区二区三区 | 亚洲一区二区三区四区在线观看 | 亚洲三级免费 | 黄a视频| 亚洲国产精品久久网午夜 | 日本高清高色 | 欧美日韩亚洲综合在线一区二区 | 日韩精品一区二区三区 在线观看 | 多人性激烈的欧美三级视频 | 亚洲国产欧美在线观看 | 国产日韩欧美在线视频免费观看 | 国产毛片片精品天天看视频 | 亚洲精品久久久久午夜 | 一级三级黄色片 | 日韩欧美一区二区精品久久 | 精品久久久一二三区 | a级国产乱理论片在线观看ai | 美国一级毛片免费看成人 | 国产河南妇女毛片精品久久 | 免费www xxx| 2022色婷婷综合久久久 | 青草在线观看 | 玖玖爱在线观看视频在线 | 香港性特级黄录像片 | aaa免费视频 | 久草国产精品视频 | 青草青在线免费视频 | 欧美一级视| 国产激烈无遮挡免费床戏视频 | 国产igao激情在线观看 | 国产v片免费播放 | 精品欧美高清一区二区免费 | 亚洲一区有码 | 五月天爱爱激情视频在线观看 | 99久久亚洲综合精品网站 | 亚洲三页| 成人性生交大片免费看软件 | 九九草在线观看 | 久久精品国产99国产 | 91亚洲一区二区在线观看不卡 |