婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Python實現OCR識別之pytesseract案例詳解

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

熱門標簽:百應電話機器人總部 成都呼叫中心外呼系統哪家強 無錫智能外呼系統好用嗎 宿州電話機器人哪家好 南昌地圖標注 地圖標注與注銷 旅游廁所地圖標注怎么弄 電梯新時達系統外呼顯示e 西青語音電銷機器人哪家好

Python實現OCR識別:pytesseract

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

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之后仍然提示錯誤,如圖:

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
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$ 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

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

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

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

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

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

您可能感興趣的文章:
  • python3使用Pillow、tesseract-ocr與pytesseract模塊的圖片識別的方法
  • python3光學字符識別模塊tesserocr與pytesseract的使用詳解
  • python PaddleOCR庫用法及知識點詳解
  • python EasyOCR庫實例用法介紹
  • python muggle_ocr庫用法及實例代碼
  • python 如何做一個識別率百分百的OCR
  • Python 實現任意區域文字識別(OCR)操作

標簽:雅安 濰坊 渭南 贛州 西安 七臺河 許昌 辛集

巨人網絡通訊聲明:本文標題《Python實現OCR識別之pytesseract案例詳解》,本文關鍵詞  Python,實現,OCR,識別,之,pytesseract,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Python實現OCR識別之pytesseract案例詳解》相關的同類信息!
  • 本頁收集關于Python實現OCR識別之pytesseract案例詳解的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 汝阳县| 乐至县| 贡山| 涿鹿县| 涟源市| 澄城县| 阜宁县| 玛多县| 肥乡县| 乐山市| 元谋县| 南岸区| 胶州市| 文登市| 曲靖市| 黄梅县| 深圳市| 台江县| 陈巴尔虎旗| 尼玛县| 中西区| 福州市| 新兴县| 凤台县| 庆元县| 青神县| 濮阳市| 平和县| 柯坪县| 长葛市| 呼伦贝尔市| 濮阳县| 武乡县| 稻城县| 保康县| 林周县| 湾仔区| 班玛县| 滨海县| 牙克石市| 承德市|