av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python實(shí)現(xiàn)OCR識(shí)別之pytesseract案例詳解

瀏覽:29日期:2022-06-14 17:34:51
Python實(shí)現(xiàn)OCR識(shí)別:pytesseract

Python常用pytesseract進(jìn)行圖片上的文字識(shí)別,即OCR識(shí)別,完整的代碼比較簡(jiǎn)單,只要下面一行即可,但是實(shí)際使用時(shí)環(huán)境配置上容易出錯(cuò)。

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

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

然而運(yùn)行時(shí)仍然報(bào)錯(cuò),raise TesseractNotFoundError()pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your path

原因是因?yàn)槲窗惭btesseract,然后使用pip3 install tesseract之后仍然提示錯(cuò)誤,如圖:

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

無(wú)法使用,往上找了很多教程,說(shuō)是要使用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 安裝成功,通過(guò)命令行tesseract -v的方式查看是否成功,出現(xiàn)版本號(hào)則為安裝成功

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

接下來(lái)就可以直接使用了,使用如下代碼:

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

打開(kāi)textinphoto.PNG的圖片,將文字輸出到output.txt,圖片如下

Python實(shí)現(xiàn)OCR識(shí)別之pytesseract案例詳解

運(yùn)行成功,產(chǎn)生output.txt文檔,里面的文本為圖片中識(shí)別出的文字。

Python實(shí)現(xiàn)OCR識(shí)別之pytesseract案例詳解

到此這篇關(guān)于Python實(shí)現(xiàn)OCR識(shí)別之pytesseract案例詳解的文章就介紹到這了,更多相關(guān)python OCR識(shí)別之pytesseract內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

主站蜘蛛池模板: 日本不卡一区二区三区 | 999久久久久久久久6666 | 97伦理影院 | 亚洲免费福利视频 | 6080亚洲精品一区二区 | 91在线观看免费视频 | 国产精品色一区二区三区 | 国产精品色哟哟网站 | 91免费观看在线 | 最新国产精品精品视频 | 成人精品一区二区户外勾搭野战 | com.国产| 91传媒在线观看 | 久久精品亚洲精品 | 91精品国产高清久久久久久久久 | 狠狠婷婷综合久久久久久妖精 | 免费观看一级特黄欧美大片 | 国产精品九九九 | 中文字幕亚洲区一区二 | 精品中文字幕在线观看 | 色婷婷久久久亚洲一区二区三区 | 91就要激情 | 最近日韩中文字幕 | 日韩成人免费在线视频 | 精品久久久久一区二区国产 | 亚洲一区二区日韩 | 欧美www在线| 91精品国产色综合久久不卡98口 | 香蕉超碰 | 夜夜艹| 久久在线看| a a毛片| 亚洲精品久久久久久一区二区 | 国产精品久久久久久婷婷天堂 | 天天操夜夜骑 | 日日碰狠狠躁久久躁96avv | 亚洲国产精品一区 | 亚洲精品日本 | 欧美成人精品激情在线观看 | 日韩一二三区视频 | 国产精品自在线 |