您好,登錄后才能下訂單哦!
這篇文章主要介紹“python pytesseract庫的用法”,在日常操作中,相信很多人在python pytesseract庫的用法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”python pytesseract庫的用法”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
1、pytesseract需要與安裝在本地的tesseract-ocr.exe文件一起使用。
2、需要注意的是,安裝時必須選擇中文包,默認只支持英文識別。
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)
識別結果輸出
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())
實例擴展:
Python使用pytesseract庫識別圖片文字
準備
首先需在本機安裝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)
到此,關于“python pytesseract庫的用法”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。