python pytesseract庫的實例用法
說明
1、pytesseract需要與安裝在本地的tesseract-ocr.exe文件一起使用。
2、需要注意的是,安裝時必須選擇中文包,默認(rèn)只支持英文識別。
安裝命令
pip install pytesseract
實例
import pytesseract from PIL import Image text = pytesseract.image_to_string(Image.open(r"d:\Desktop\39DEE621-40EA-4ad1-90CC-79EB51D39347.png")) print(text)
識別結(jié)果輸出
Using Tesseract OCR with Python
# import the necessary packages
from PIL import Image
import pytesseract
import ergperse
import cv2
import os
# construct the argument parse and parse the arguments
ap = argparse.ArgunentParser()
ap.add_argument("-i", "--image", required-True,
help="path to input image to be OCR'd")
ap.add_argument("-p", "--preprocess", typesstr, default="thresh",
helpe"type of preprocessing to be done")
args = vars (ap.parse_args())
實例擴(kuò)展:
Python使用pytesseract庫識別圖片文字
準(zhǔn)備
首先需在本機(jī)安裝Tesseract客戶端,然后安裝pytesseract庫:
pip install pytesseract
沒安裝過PIL的也要安裝一下,因為所調(diào)用的第一個參數(shù)是由Image類返回:
pip install PILLOW
實例
import pytesseract
from PIL import Image
img = Image.open("D://aa.jpg")
text = pytesseract.image_to_string(img, lang="chi_sim")
print(text)
到此這篇關(guān)于python pytesseract庫的實例用法的文章就介紹到這了,更多相關(guān)python pytesseract庫是什么內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python opencv相機(jī)標(biāo)定實現(xiàn)原理及步驟詳解
這篇文章主要介紹了Python opencv相機(jī)標(biāo)定實現(xiàn)原理及步驟詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-04-04
Python中字符串類型代碼的執(zhí)行函數(shù)——eval()、exec()和compile()詳解
這篇文章主要介紹了Python中字符串類型代碼的執(zhí)行函數(shù)——eval()、exec()和compile(),字符串類型代碼的執(zhí)行函數(shù)有三個,都是Python的內(nèi)置函數(shù),下面逐一對這三個函數(shù)詳細(xì)講解,需要的朋友可以參考下2023-02-02
json-server?如何快速搭建REST?API?服務(wù)器
json-server 是一個非常流行的開源工具,用于快速搭建一個完整的 REST API 服務(wù)器,它使用 JSON 文件作為數(shù)據(jù)源,通過簡單的配置即可模擬復(fù)雜的服務(wù)器功能,這篇文章主要介紹了json-server如何快速搭建REST API服務(wù)器,需要的朋友可以參考下2017-10-10
Python辦公自動化之?dāng)?shù)據(jù)預(yù)處理和數(shù)據(jù)校驗詳解
這篇文章主要為大家詳細(xì)介紹了Python辦公自動化中數(shù)據(jù)預(yù)處理和數(shù)據(jù)校驗的相關(guān)知識,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以參考一下2024-01-01

