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

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

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

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

Python常用pytesseract進(jìn)行圖片上的文字識別,即OCR識別,完整的代碼比較簡單,只要下面一行即可,但是實(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

無法使用,往上找了很多教程,說是要使用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的方式查看是否成功,出現(xiàn)版本號則為安裝成功

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實(shí)現(xiàn)OCR識別之pytesseract案例詳解

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

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

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

標(biāo)簽: Python pytesseract OCR識別
主站蜘蛛池模板: 午夜网站在线播放 | 91私密视频 | 免费特黄视频 | 色婷婷影院在线视频免费播放 | 色综合久久天天综合绕观看 | 激情国产 | 久久99精品久久久久久三级 | 一个色综合网 | 欧美一级视频 | 中文字幕2022永久在线 | 国产欧美性综合视频性刺激 | 国产成人无精品久久久 | 亚洲在线综合 | 亚洲 中文 欧美 日韩 在线 | 桃花综合| 亚洲在线观看一区 | 一级生活黄色片 | 国产精品7m凸凹视频分类大全 | 9久久免费国产精品特黄 | 在线免费一区二区 | 欧美日韩亚洲综合另类ac | 欧美一区二区三区不卡免费 | 亚洲免费专区 | 欧美精品区 | 欧美a一级片 | 亚洲国产爱久久全部精品 | 精品三级国产精品经典三 | 综合久久久久综合体桃花网 | 国产亚洲精品久久久久91网站 | 222www免费观看 | 亚洲黄色片在线观看 | 黄色一级大片 | 国产精品高清m3u8在线播放 | 国产精品久久久久9999赢消 | 日韩在线中文字幕 | 色婷婷久久综合中文久久一本 | 国产黄色一级大片 | 国模精品一区二区三区 | 免费人成网址在线观看国内 | 中文字幕一区二区三区不卡 | 91香蕉视频在线播放 |