国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python實現OCR識別之pytesseract案例詳解

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

2021-12-14 10:58Holidaylovesam Python

這篇文章主要介紹了Python實現OCR識別之pytesseract案例詳解,本篇文章通過簡要的案例,講解了該項技術的了解與使用,以下就是詳細內容,需要的朋友可以參考下

python實現ocr識別:pytesseract

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

?
1
2
3
4
5
from pil import image
import 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之后仍然提示錯誤,如圖:

?
1
2
3
4
alicedembp:~ alice$ pip3 install tesseract
requirement 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
?
1
alicedembp:~ alice$ ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/install)"
  • 再使用brew安裝leptonica
?
1
alicedembp:~ alice$ brew install leptonica
  • 使用brew安裝tesseract
?
1
alicedembp:~ alice$ brew install tesseract
  • 安裝成功,通過命令行tesseract -v的方式查看是否成功,出現版本號則為安裝成功
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
alicedembp:~ alice$ tesseract
usage:
  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:
  --help                show 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 -v
tesseract 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

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

?
1
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內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/alice_tl/article/details/89299405

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25
主站蜘蛛池模板: 欧美日韩一区二区三区在线观看 | 久久久免费少妇高潮毛片 | 91操碰| 免费成人高清在线视频 | 天堂v视频永久在线播放 | 欧美日韩一区二区三区在线观看 | 日韩在线观看一区 | 国产伊人av | 在线观看成人av | 男人的天堂中文字幕 | 综合色区 | 欧美成人综合 | 欧美精品日韩 | 国产成人精品免费 | 一区二区国产在线观看 | 久久精品在线 | 日韩精品在线观 | 黄色毛片免费视频 | 久色视频在线观看 | 日韩精品中文字幕在线 | baoyu123成人免费看视频 | 在线观看亚洲免费视频 | 日韩毛片一区二区三区 | 91av电影网| 日韩 欧美 中文 | 午夜影院久久 | 91国产精品 | 狠狠综合 | 国产精品久久久久久久午夜片 | 成人一区二区三区久久精品嫩草 | 一区二区三区欧美 | 欧美黄色一区 | 久久久久久久久99精品 | 欧美自拍一区 | 亚洲国产精品久久 | 日本久久精品视频 | 中文字幕日韩欧美一区二区三区 | 寡妇高潮免费视频一区二区三区 | 成人高清av| 成人精品国产 | 久久美女视频 |