Mac上安装tesseract-OCR

时间:2022-07-25
本文章向大家介绍Mac上安装tesseract-OCR,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

安装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)