前言:
相较于免费的第三方识别工具中,paddle-ocr的识别速度和准确率都相当的高,基本可以和商用的对标。
其它的识别ocr:
cnocr
tesseract
链接:
https://www.paddlepaddle.org.cn/
git:
https://github.com/PaddlePaddle/PaddleOCR
https://gitee.com/paddlepaddle/PaddleOCR
环境搭建:
python 3.7以上
python -m pip install paddlepaddle==2.4.2 -i https://mirror.baidu.com/pypi/simple
python -m pip install paddleocr -i https://mirror.baidu.com/pypi/simple
几个坑:
paddlepaddle 2.4.2 requires protobuf<=3.20.0,>=3.1.0, but you have protobuf 3.20.3 which is incompatible.
出现这个错误提示,可以试下下面的操作:
# 降版本
pip install onnx==1.12.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install protobuf==3.20.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
如果执行demo后出现OpenSSL错误
可以执行下面操作:
python -m pip install urllib3==1.26.6
运行demo:
from paddleocr import PaddleOCR
ocr = PaddleOCR(use_angle_cls=True, lang="ch")
img_path = 'tmp.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
print(line)