安裝homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝完后進行測試
brew -v
返回結果
Homebrew 2.1.1-38-ge68fc53
Homebrew/homebrew-core (git revision 4465d; last commit 2019-04-22)
Homebrew/homebrew-cask (git revision f909; last commit 2019-04-20)
安裝tesseract
brew install tesseract
安裝完成后進行測試
tesseract -v
返回結果
tesseract 4.1.1
leptonica-1.79.0
libgif 5.2.1 : libjpeg 9d : libpng 1.6.37 : libtiff 4.1.0 : zlib 1.2.5 : libwebp 1.1.0 : libopenjp2 2.3.1
使用python調用使用
import pytesseract
from PIL import Image
img = Image.open("test.png")
text=pytesseract.image_to_string(img)
print(text)